image() display image and adjust contrast automatically
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Image Analyst
el 15 de Abr. de 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 comentarios
Image Analyst
el 16 de Abr. de 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?
Más respuestas (0)
Ver también
Categorías
Más información sobre Modify Image Colors en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!