Reading uint16 image and converting to uint8 problem
Show older comments
I have been trying to convert my 16-bit TIF file to a 8-bit image inside MATLAB. When opening in ImageJ it looks great. After doing imread of the TIF the values do however already look strange. All the pixel value are extremely close to 0.5*2^16. After to conversion to 8-bit I only end up with a gray image (128 in pixel value all across the image).
Can I read the images in another way with MATLAB? Or is there a better way to convert them from 16-bit to 8-bit?
Please see the attached file.
5 Comments
A better way than what? You haven't actually shown any code for how you did the conversion. I don't work with tiff files, but a quick search of the Matlab documentation seems to suggest
doc read
works to read tiff files. I don't know how this differs from imread which also supposedly supports them.
Jan
on 12 Feb 2019
Thanks for the code. (I've formatted it today to improve the readability. Simply use the buttons for code formatting by your own in the future. Thanks) Now explain, why you use imadjust and where you observe the "extremely close to 0.5*2^16". When the data is converted to uint8, you cannot find a value above 255.
Oskar
on 12 Feb 2019
"I observe the image values (around 32769) all across the image." Now please explain, how you observe this: before or after imadjust and/or unit16? With which tool? Why you expect something else? What do you see for:
obj = Tiff(filepath);
Img = read(obj);
class(Img)
Img16 = im2uint16(Img);
figure
imshow(Img16);
ImgD = im2double(Img);
figure
image(ImgD)
Accepted Answer
More Answers (1)
Oskar
on 12 Feb 2019
Categories
Find more on Image Type Conversion 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!
