Converting Image pixel range
Show older comments
Dear All, I have an image whose intensity values ranges from -15 to +20. I want to convert it to 8-bit and 16-bit values. Please let me know the algorithm/formula that I can use to program in matlab. In addition, how to save the image in 8-bit and 16 bit in matlab.
regards and thanks
Answers (1)
Image Analyst
on 26 Jun 2016
Try this:
image8 = uint8(mat2gray(yourDoubleImage) * intmax('uint8'));
imwrite(fullFileName, image8);
image16 = uint16(mat2gray(yourDoubleImage) * intmax('uint16'));
imwrite(fullFileName, image16);
4 Comments
try analyst
on 27 Jun 2016
Image Analyst
on 27 Jun 2016
Try wrapping intmax in double
double(intmax('uint8'))
try analyst
on 28 Jun 2016
Guillaume
on 28 Jun 2016
image8 = im2uint8(mat2gray(yourimage));
image16 = im2uint16(mat2gray(yourimage));
"the quality of the image is very bad"
If it's after saving the image, possibly it's because you're not using an appropriate image format.
If it's after the conversion to uint8 and uint16, then don't do the conversion! By definition, converting to integers is going to discretise your image. Although, with uint16 having 65536 levels of grey, it shouldn't be an issue.
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!