Imshow

조회 수: 6 (최근 30일)
John
John 2012년 1월 31일
Hi,
I need to plot a set of png images using imagesc as a method of stitching them together.
I am curious about the colormap command.
Why does this set of commands:
[I,map] = imread('test.png','png');
imshow(I,map)
Not produce the same as:
[I,map] = imread('test.png','png');
imshow(I)
colormap(map)
This is really baffling me, as I would like to load the png image using imagesc, which doesn't ask for a colormap argument when you load the image, meaning that I have to set the colormap each time, which isn't correct at all.
Thank you in advance.

답변 (1개)

Image Analyst
Image Analyst 2012년 1월 31일
If it is an gray scale image and has a colormap stored in the file with it (making it an "indexed" image) then in one case you're using the map to pseudocolor it as intended by the person who saved the image, and in the second case you're using no color map so it shoudl show up as gray. imagesc() applied some weird colormap by default, even though you don't explicitly give one in its argument list - probably not what you want. You probably want either no colormap or the one it was stored with. So overall it seems like your best option is to use imshow with a colormap.
  댓글 수: 4
Image Analyst
Image Analyst 2012년 1월 31일
You can just do [a;b] or [a,b] to stitch together two arrays. Of course the dimensions along the seam have to match.
John
John 2012년 3월 9일
Sorry I didn't see this until now, knowing this (which actually seems pretty obvious now you've pointed it out!) will help me tremendously in speeding up my program. Much appreciated.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by