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

后端 未结 1 1013
野趣味
野趣味 2020-12-15 00:14

When I run this code:

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

It always shows an all-black

相关标签:
1条回答
  • 2020-12-15 00:58

    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 讨论(0)
提交回复
热议问题