Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 图像分块和两幅图像的减法_Image_Matlab_Image Processing - Fatal编程技术网

Image 图像分块和两幅图像的减法

Image 图像分块和两幅图像的减法,image,matlab,image-processing,Image,Matlab,Image Processing,我有两个图像:一个是标准图像,另一个是参考图像。我需要找出标准图像的第一块与参考图像的第一块之间的差异,依此类推。我用于阻塞的代码是 S = imread ('standard image'); R = imread ('reference image'); % then converted images to grayscale images S = rgb2gray(S); R = rgb2gray (R); % blocking of both images( as both imag

我有两个图像:一个是标准图像,另一个是参考图像。我需要找出标准图像的第一块与参考图像的第一块之间的差异,依此类推。我用于阻塞的代码是

S = imread ('standard image'); R = imread ('reference image');
% then converted images to grayscale images 

S = rgb2gray(S); R = rgb2gray (R);
% blocking of both images( as both images have 1600x2560 size) so i'm dividing 
it into 16 blocks of 4*4 matrix with block size of 400x640

div1= [400 400 400 400]; div2 = [640 640 640 640];
Bs = mat2cell (S, div1, div2); Br = mat2cell (R, div1,div2);
为了查看块,我可以使用
imshow(Bs{1,1})
Bs{4,4}
,或者简单地通过
imshow
Br{1}
Br{16}


我需要通过减去像标准图像的第一块和参考图像的第一块这样的块来找出差异。我需要找到一种方法来查找每个块的索引,并在两幅图像上应用循环进行减法运算。

我会使用以下方法:

I=double(S)-double(R)
surf(I)
view(2)
shading interp
axis tight

这使我可以将强度视为曲面。

您可以使用类似的方法

for i=1:length(div1), for j=1:length(div2), D{i,j}=abs(Bs{i,j}-Br{i,j}); end, end
其中D是两者之间的差值,或者您也可以在将矩阵拆分为块之前对其进行休息

D = abs(S-R);

div1= [400 400 400 400]; div2 = [640 640 640 640];
Bs = mat2cell (S, div1, div2); Br = mat2cell (R, div1,div2);

我使用了abs,因为我不知道图片中是否可以有负数。

先生,我用它来减法这个Sub=cellfun(@减号,Br,Bs,'Un',0);我需要在每个单元格上启动一个循环,并显示那些子值大于零的单元格,如果所有图像没有一个值大于零,则称为相同的图像,否则称为不同的图像,我用于减法这个子=cellfun(@减号,Br,Bs,'Un',0);我需要在每个单元格上启动一个循环,显示那些子值大于零的单元格,如果所有图像都没有一个值大于零,则称为相同的图像,否则称为不同的图像