image() display image and adjust contrast automatically
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have a 16-bit gray image which has a intensity value between [0 5000].I want to use image to display the image matrix and automatically display the image. However, I don't find and image handle properties about this.I know imshow() can do this easily, but I have to use image() now.
Thanks, Sun Tao
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 15 Apr. 2012
I played around a bit with image with 16 bit images and various colormaps and couldn't get it to work (to display the complete range properly). The only way I could do it was to convert it to an 8 bit image.
% Create sample 16 bit image.
rows = 600;
columns = 800;
ramp = linspace(1, 5000, columns);
grayImage = uint16(repmat(ramp, [rows, 1]));
% imshow(grayImage, []); % This works.
% image(grayImage); % This doesn't seem to work no matter what colormap I used.
% Convert to normalized uint8 image.
g=uint8(255*mat2gray(grayImage));
image(g); % Now it works.
% Apply gray scale color map.
colormap(gray(256));
colorbar;
2 Kommentare
Image Analyst
am 16 Apr. 2012
Go ahead and use 16 bits everywhere you do math on it. I just converted to 8 bit for display only so no information is lost because you have only an 8 bit display (24 bit RGB) - you don't have a 16 bit per channel color display so even if you passed a 16 bit image to some display routine, it would have to convert to 8 bits internally *anyway* when it displayed it since the display can't handle 16 bits. Make sense?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Modify Image Colors finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!