简体   繁体   English

Matlab,图像大小相同,但我不能使用imabsdiff

[英]matlab, images are the same size but I can't use imabsdiff

I want to use imabsdiff in matlab to find the difference between two images. 我想在matlab中使用imabsdiff来查找两个图像之间的差异。 when I use it I have this error on the terminal (X and Y are the images) 当我使用它时,我在终端上出现此错误(X和Y是图像)

X and Y must be the same size. X和Y的大小必须相同。

but my problem is that when I use size function for checking the size of images one of them is 512, 512 and another one is 512, 512, 3 但是我的问题是,当我使用size函数检查图像的大小时,其中一个是512、512,另一个是512、512、3

I have no idea about this, what should I do? 我对此一无所知,该怎么办? :( :(

thanks in advance :) 提前致谢 :)

It sounds like one of the images is grayscale and the other is colour (3 channels). 听起来其中一幅图像是灰度图像,另一幅图像是彩色图像(3通道)。 One solution is to make both images grayscale rgb2gray and then run imabsdiff 一种解决方案是使两个图像均为灰度rgb2gray ,然后运行imabsdiff

imgA = ...;   % The 3 channel image (size [512, 512, 3])
imgB = ...;   % The single channel image (size [512, 512])
imabsdiff(rgb2gray(imgA), imgB);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM