Why is my RGB image not displaying as expected using imshow?
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a Landsat "natural" image with three color bands (rgb values ranging from 0-256). When I display the image in ArcMap, it looks correct:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147479/image.png)
However, when I display the image in Matlab with the following code:
[I, cmap] = imread('imname')
imshow(I)
(cmap is empty, I is M x N x 3 uint8)
the resulting image is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147481/image.png)
It appears to be drawing from all three color bands, but the coloration is much different than what I expect (i.e. what ArcMap and Landsat's website display). Does anyone have any ideas about how to get Matlab to display the image like Arcmap?
5 Commenti
Image Analyst
il 29 Lug 2015
It can be confusing. No scaling takes place with uint8 RGB images so imshow(), imshow([]), and imagesc() all produce the same thing:
% Read in standard demo image and make it dark by dividing by 4.
rgbImage = imread('peppers.png') / 4;
% Display 3 different ways.
subplot(1,3,1);
imshow(rgbImage)
title('imshow(rgbImage)', 'FontSize', 20);
subplot(1,3,2);
imshow(rgbImage, [])
title('imshow(rgbImage, [])', 'FontSize', 20);
subplot(1,3,3);
imagesc(rgbImage)
title('imagesc(rgbImage)', 'FontSize', 20);
axis image;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179988/image.jpeg)
Risposta accettata
Più risposte (1)
Muthu Annamalai
il 28 Lug 2015
Have you tried using a, colormap
>> doc colormap
may help.
2 Commenti
Image Analyst
il 29 Lug 2015
That's incorrect. Color maps are not used and don't apply when an RGB image is displayed as Jon said.
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!