image() display image and adjust contrast automatically

5 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2012-4-15
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 个评论
Sun
Sun 2012-4-16
Hi,
Thanks for the reply! This works and now it can display. Althouth I may still use 16-bit because this will not lose information. But at this moment it's good enough.
Sun Tao
Image Analyst
Image Analyst 2012-4-16
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by