Why is my RGB image not displaying as expected using imshow?

조회 수: 39 (최근 30일)
Jon
Jon 2015년 7월 28일
편집: Jon 2015년 7월 29일
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
Jon
Jon 2015년 7월 28일
Unfortunately imagesc produces (exactly?) the same image:
Image Analyst
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;

댓글을 달려면 로그인하십시오.

채택된 답변

Jon
Jon 2015년 7월 28일
편집: Jon 2015년 7월 29일
The problem here is that I was expecting the wrong thing. Matlab is plotting the proper RGB values; ArcMap was automatically applying a "gamma stretch" unbeknownst to me. Now off to figure out how to Matlab a gamma stretch...

추가 답변 (1개)

Muthu Annamalai
Muthu Annamalai 2015년 7월 28일
Have you tried using a, colormap
>> doc colormap
may help.
  댓글 수: 2
Jon
Jon 2015년 7월 28일
편집: Jon 2015년 7월 28일
I don't understand why I'd need to create a colormap since the image already contains all the RGB values. The problem is that those RGB values are displaying different (darker) colors in Matlab versus ArcMap, and ArcMap's display agrees with the original data source's (EarthExplorer).
Image Analyst
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by