how to convert 0-60 scale to 0-255 scale in image

I am new in imaging. I want to ask that when we convert certain data to image then a scale is always set to 0-60. How can I rescale it to 0-255 so that better contrast is observed.

Answers (3)

Use mat2gray() to get it to the range 0-1, then multiply by 255 and cast to unsigned integer:
grayImage = uint8(255 * mat2gray(originalImage));

2 Comments

Thanks for the reply but I know how to convert mat to gray. Problem is that when I give the command 'image(result)' again the scale of the image set itself to 0-60. I need scale from 0-250 as shown in figure
It WON'T be 0-60. It WILL be 0-255. You did something wrong, so show me what you did. However if you want 0-250 instead of 0-255, do this:
grayImage = uint8(250 * mat2gray(originalImage));

Sign in to comment.

imadjust function from Image Processing Toolbox could help you.
Another cheap approach:
result = uint8((double(originalImage) / 60) * 255);
mat2gray of Image Analysts answer is smarter and safer. Prefer the functions of the Image Processing Toolbox, if you have it.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Asked:

on 17 Dec 2016

Commented:

on 18 Dec 2016

Community Treasure Hunt

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

Start Hunting!