Difference between two blocks of images?

1 visualizzazione (ultimi 30 giorni)
Emmanuel
Emmanuel il 23 Ott 2014
Modificato: Emmanuel il 23 Ott 2014
How can I extract a block of pixels from an image and subtract it with another block of different image to find minimum disparity? my block size is 8. How do I proceed with this?
iteration = 0;
subsub = zeros(8);
subblock = zeros(8);
x = rgb2gray(imread('testimage.jpg'));
J = imresize(x, 0.7);
x0 = imrotate(J,30);
r = randi(225-7);
c = randi(225-7); //random block of size 8 from original image
subblock = x(r:r+7, c:c+7);
imshow(subblock);
block = size(x0);
k =1; m= 8;
for i =1:8: (block(1)-7)
for j = k:m
submatrix = x0(i,j); // creating a block from second image
end
for w = 1 : 8
for y = 1:8
diff = (subblock(w,y) - submatrix(w,y))^2; // subtracting two blocks
end
end
k = m+1; // to move to the next block
m = m+8;
end
When I run the code, my submatrix is always zero. Why is that? please help me

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by