开发者

Why do I get an all-black/grayscale image when I load this PNG in MATLAB?

When I run this code:

>> I = imread('D:\Works\matlab\SecCode.php.png','png');
>> imshow(I);

It always shows an all-black image. 开发者_运维技巧What's wrong with it?

The image I'm using is this one:

Why do I get an all-black/grayscale image when I load this PNG in MATLAB?


Ahhh, I see now. The problem is you have an indexed image and need to get the colormap argument from imread as well. Try this:

[I, map] = imread('D:\Works\matlab\SecCode.php.png', 'png');
imshow(I, map);

A description of the different types of images in MATLAB can be found here. Here's a brief summary:

  • Binary images: The image is a logical array where each pixel has the value 0 or 1.
  • Indexed images: The pixels in the image store indices into a colormap, which is an M-by-3 array of RGB values. The colormap is often stored with the indexed image in the image file.
  • Intensity (Grayscale) images: The pixels in the image each contain a single value representing the intensity.
  • RGB (Truecolor) images: The image is an M-by-N-by-3 array where each pixel has a red, green, and blue color component.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜