views:

39

answers:

1

Hey,

When I try to show a grayscale image using :

Img = imread('tr2.png');

subplot(111);

imshow(Img);

it does not appear as the original image. Where is the problem ?

+1  A: 

Try to read colormap together with the image:

[Img, map] = imread('tr2.png');
imshow(Img,map);

EDIT:

I believe you have indexed image and you have to convert it to RGB before any processing. Use ind2rgb or ind2gray function.

See for example Steve's blog on indexed images.

yuk
It's work perfecty when I do it without any processing[Img, map] = imread('tr2.png');imshow(Img,map);But when I add this : ImgFinal = Img - ImgXsubplot(212);imshow(ImgFinal)
dotNET
Please add to your question what are you trying to do. I think your comment went unfinished.
yuk
Thank you so much yuk it's working perfectly.
dotNET
This is the final code :[Img, map] = imread('tr2.png');imshow(Img,map);if isempty(map) elseif ~isempty(map) Img = ind2gray(Img,map); end
dotNET

related questions