在MATLAB中加载此PNG时,为什么会得到全黑/灰度图像? [英] Why do I get an all-black/grayscale image when I load this PNG in MATLAB?

查看:350
本文介绍了在MATLAB中加载此PNG时,为什么会得到全黑/灰度图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此代码时:

>> 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:

推荐答案

啊,我明白了.问题是您有一个索引图像并且还需要从 imread 中获取colormap参数.试试这个:

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:

  • 二进制图像:该图像是 logical 数组,其中每个像素的值为0或1.
  • 索引图像 :图像中的像素将索引存储到一个颜色映射表中,该颜色映射表是RGB值的M×3数组.色彩图通常与索引图像一起存储在图像文件中.
  • 强度(灰度)图像 :图像中的每个像素都包含一个代表强度的值.
  • RGB(真彩色)图像 :图像是一个M×N×3的阵列,其中每个像素都有红色,绿色和蓝色的分量.
  • 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.

这篇关于在MATLAB中加载此PNG时,为什么会得到全黑/灰度图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆