how to convert 0-60 scale to 0-255 scale in image
Show older comments
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)
Image Analyst
on 17 Dec 2016
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
akash tondon
on 18 Dec 2016
Image Analyst
on 18 Dec 2016
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));
michio
on 17 Dec 2016
0 votes
imadjust function from Image Processing Toolbox could help you.
Jan
on 17 Dec 2016
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
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!