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 already rad the books.
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

• D.I.C Head

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 already rad the books.
i can understand the book's explanation.

Thank you.

Please always use spell checker and re-read your post after posting.
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.
Was This Post Helpful? 2

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }