计算matlab中图像之间的平方差的和

时间:2017-11-29 16:02:40

标签: matlab image-processing computer-vision

我无法让我的代码在Matlab中工作。我试图计算两个相同维度图像之间的平方差的总和。我得到一个超出矩阵尺寸的错误,我只想确认这是计算SSD的方法吗?这是我到目前为止的代码:     明确     CLC     关闭所有

imgL = imread('pentagon_L.png');
% image(imgL);
imgR = imread('pentagon_R.png');
% image(imgR);

imgL2 = double(imgL);
imgR2 = double(imgR);

% The height and width need only be computed once since images are the same
% size.
[height, width] = size(imgR2);

% maxShift = 0.08;
shiftPixels = 5;

for i = 1 : height
    for j = 1 : width
        ssd(imgL2,imgR2) = sum(sum((imgL2(i,j) imgR2(i+shiftPixels,j+shiftPixels)).^2))/(height*width);
    end
end

imshow(ssd)

0 个答案:

没有答案