[英]Matlab gui image incorrectly blue
I am creating a GUI containing an image using the following code: 我正在使用以下代码创建包含图像的GUI:
try
Imagenamehere = imread('Imagenamehere.jpg');
axes(handles.Logo)
image(Imagenamehere)
set(gca,'xtick',[],'ytick',[])
catch
msgbox('Please download all contents from the zipped file into working directory.')
end
The image shows up but for some reason is completely coloured blue as if put through a blue filter. 图像显示出来,但由于某种原因完全变成蓝色,就好像通过了蓝色滤镜一样。 I don't think it would be wise to upload the image but it is a simple logo coloured black and white.
我认为上传图片并不明智,但这是一个简单的黑色和白色徽标。
Anyone know what could be causing this? 有人知道是什么原因造成的吗?
Check the size, type (probably uint8
) and range of your image. 检查图像的大小,类型(可能是
uint8
)和范围。 It sounds like for some reason your images are being displayed with colormap
as jet (the default), and possibly also that your range is not what MATLAB expects (eg 0 to 1 not 0 to 255), resulting in all your values being relatively low (blue on the jet colormap). 听起来由于某种原因,图像以
colormap
图显示为喷射色(默认),并且可能还因为您的范围不是MATLAB期望的范围(例如0到1而不是0到255),导致所有值都相对较低(喷射彩色图上的蓝色)。
"black and white" is just one way of interpreting an image file which contains only two colors. “黑白”只是解释仅包含两种颜色的图像文件的一种方法。 MATLAB makes several assumptions when you pass data into a display function like
image
. 当您将数据传递到
image
等显示函数时,MATLAB会做出一些假设。 If you don't specify colormap and image data range, it will make a guess based off things like data type. 如果您未指定颜色图和图像数据范围,则会根据数据类型等信息进行猜测。
One possibility is that your logo file is an indexed image. 一种可能是徽标文件是索引图像。 In these cases you need to do:
在这些情况下,您需要执行以下操作:
[Imagenamehere map] = imread('Imagenamehere.jpg');
colormap(map);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.