开发者

Problem with grayscale image

开发者 https://www.devze.com 2022-12-31 11:52 出处:网络
When I try to开发者_开发问答 show a grayscale image using : Img = imread(\'tr2.png\'); subplot(111);

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 ?


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.


code to get the grayscale:

Img = imread('tr2.png');
gray=rgb2gray(Img);
imshow(gray);

(Matlab)

0

精彩评论

暂无评论...
验证码 换一张
取 消