Page 1 of 1

Reputation:

how to scale the intensity value of the image to [0, 255]

Posted 11 March 2010 - 12:54 AM

Hi everyone,

Please explain and give more examples related to this topic?
i can understand the book's explanation.

Thank you.
Is This A Good Question/Topic? -1

Replies To: how to scale the intensity value of the image to [0, 255]

#2 javabie

Reputation: 35
• Posts: 117
• Joined: 12-February 10

Re: how to scale the intensity value of the image to [0, 255]

Posted 17 March 2010 - 08:12 PM

sarmilla, on 10 March 2010 - 11:54 PM, said:

Hi everyone,

Please explain and give more examples related to this topic?
i can understand the book's explanation.

Thank you.

Let's say if you want to view an image but you know that image has intensity values out of the range [0 255]
then you could use the following command:
```im = imread('someImage.tif'); % read in the image
imshow(im, []);               % output the image which automatically scales it to the range 0 to 255

```

but let's say if you want to scale it down to the range [0 255] and then perform some other operation then

```im = imread('somePicture.tif'); % read in an image
im = im .* 3;      % some intensity values could be > 255
maxPixelValue = max(max(im)); % find the maximum
minPixelValue = min(min(im)); % find the minimum

% make it to the range between 0 to 1 and then multiply by 255.
im = ((im + minPixelValue)/maxPixelValue)*255;
```

Try these code on matlab.
If you find any mistakes then try to correct it.

Goodluck.