MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在MATLAB中加载该PNG时,为什么会得到全黑/灰度图像? (https://www.labfans.com/bbs/showthread.php?t=23272)

poster 2019-12-10 20:30

在MATLAB中加载该PNG时,为什么会得到全黑/灰度图像?
 
当我运行此代码时:

>> I = imread('D:\Works\matlab\SecCode.php.png','png'); >> imshow(I); 它始终显示全黑图像。它出什么问题了?

我正在使用的图像是这个图像:

[URL="https://i.stack.imgur.com/jre74.png"][IMG]https://i.stack.imgur.com/jre74.png[/IMG][/URL]



[B]回答:[/B]

啊,我明白了。问题是您有一个[URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html#f2-155"]索引图像,[/URL]并且还需要从[URL="https://www.mathworks.com/help/matlab/ref/imread.html"]imread[/URL]获取colormap参数。尝试这个:

[I, map] = imread('D:\Works\matlab\SecCode.php.png', 'png'); imshow(I, map); 您可以在[URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html"]此处[/URL]找到有关MATLAB中不同类型图像的描述。这是一个简短的摘要:
[LIST][*] [B]二进制图像[/B] :图像是一个[URL="https://www.mathworks.com/help/matlab/ref/logical.html"]logical[/URL]数组,其中每个像素的值为0或1。[*] [URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html#f2-155"][B]索引图像[/B][/URL] : [URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html#f2-155"][B]图像中[/B][/URL]的像素将索引存储到一个色彩映射表中,色彩映射表是RGB值的M×3数组。色彩图通常与索引图像一起存储在图像文件中。[*] [URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html#f2-175"][B]强度(灰度)图像[/B][/URL] :图像中的每个像素都包含一个代表强度的值。[*] [URL="https://www.mathworks.com/help/matlab/creating_plots/image-types.html#f2-12468"][B]RGB(Truecolor)图像[/B][/URL] :图像是一个M×N×3的阵列,其中每个像素都有红色,绿色和蓝色的颜色分量。[/LIST]
[url=https://stackoverflow.com/questions/2586539]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 02:58

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.