Effacer les filtres
Effacer les filtres

image() display image and adjust contrast automatically

5 vues (au cours des 30 derniers jours)
Sun
Sun le 15 Avr 2012
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

Réponse acceptée

Image Analyst
Image Analyst le 15 Avr 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 commentaires
Sun
Sun le 16 Avr 2012
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 le 16 Avr 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by