Imshow

3 views (last 30 days)
John
John on 31 Jan 2012
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.

Answers (1)

Image Analyst
Image Analyst on 31 Jan 2012
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 Comments
Image Analyst
Image Analyst on 31 Jan 2012
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 on 9 Mar 2012
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.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!