MATLAB: Move a row of image to match with next row

Image Processing Toolboxpixel move and match

Hi, I am very new Matlap user with below problem
I have a burred image [512 x 512] witch was ramdom circle moved every rows.
How I can move each row until match with next row?
I think the adjacent row should have very close gray level.
Thanks, for your help.

Best Answer

You can convolve your blurred image with [1; -1]. Pixels where the row below have the same value with have a value of zero in the convolved result
result = conv2(double(blurryImage), [1; -1], 'same');
imshow(result, []);
That basically makes rows where the new row is the row below minus the row above. So if they're equal, the value is zero.