Why is my RGB image not displaying as expected using imshow?
古いコメントを表示
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:

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

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 件のコメント
Walter Roberson
2015 年 7 月 28 日
try imagesc(I)
Muhammad Usman Saleem
2015 年 7 月 28 日
please i want to understand for myself what is difference between imshow(I) or imagesc(I) @walter?
Walter Roberson
2015 年 7 月 28 日
When you use imshow() without specifying a range, then a default DisplayRange is defined only for grayscale images (that is, if the array is 2D.) The behaviour when you pass it a 3D array with values that do not span the full range 0 to 1 is unspecified but should be assumed to be as described in image() as imshow() must create an image() object. That behaviour is to treat the values as 'direct' mapping, directly specifying RGB. The behaviour of imshow() when you pass it a 3D array with values greater than 1.0 is unspecified as well, and again must be assumed to be as image() does, which is to treat values less than 0 as 0 and values greater than 1 as 1.
imagesc() always scales the data between the minimum and maximum value, even if the data is 3D, unless you specifically pass some other range.
My hypothesis is that the data array for Jon's image might not span the full range from 0 to 1, and that using imagesc() would scale the data for more visibility. imshow(I,[]) should do the same thing.
Jon
2015 年 7 月 28 日
Image Analyst
2015 年 7 月 29 日
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;

採用された回答
その他の回答 (1 件)
Muthu Annamalai
2015 年 7 月 28 日
Have you tried using a, colormap
>> doc colormap
may help.
2 件のコメント
Image Analyst
2015 年 7 月 29 日
That's incorrect. Color maps are not used and don't apply when an RGB image is displayed as Jon said.
カテゴリ
ヘルプ センター および File Exchange で Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
