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.

Risposte (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 Commenti

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));

Accedi per commentare.

michio
michio il 17 Dic 2016
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.

Categorie

Scopri di più su Convert Image Type in Centro assistenza e File Exchange

Tag

Richiesto:

il 17 Dic 2016

Commentato:

il 18 Dic 2016

Community Treasure Hunt

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

Start Hunting!

Translated by