MATLAB Answers

After dividing a 512*512 image into non overlapping two pixel blocks, why can't i perform operations on the pixel values? If i multiply a pixel value (163) with 5, it shows 255 everytime..what could be done to perform operations on the pixel values?

1 view (last 30 days)
Kiruba S
Kiruba S on 28 Jan 2019
Commented: Kiruba S on 10 Feb 2019
After dividing a 512*512 image into non overlapping two pixel blocks, why can't i perform operations on the pixel values?
If i multiply a pixel value (163) with 5, it shows 255 everytime..what could be done to perform operations on the pixel values?

  0 Comments

Sign in to comment.

Answers (1)

Munish Raj
Munish Raj on 7 Feb 2019
It is my understanding that you are not able to perform a multiplication operation (pixel*5) on individual pixels of your blocks. When you multiply your pixel by 5, it shows 255 every time.
This might be because the pixel values in MATLAB vary from 0 – 255 (0 being the minimum and 255 being the maximum).
When you try to modify a pixel to anything above 255, MATLAB will automatically keep the pixel at 255.
If your application requires you to scale a particular pixel by 5 times as compares to the other pixels,
you could scale all pixels down by a factor of 5 and then multiply the required pixel by 5.
I = imread('image_path'); %replace image with your image path e.g.: C://users/documents/1,jpg
I=I/5; %scale down all pixels by 5
%perform your operations here
%
%
%
%all the pixels will be dim, except the pixels you multiply by 5.
Munish Raj

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by