plz help me with this error "Matrix dimensions must agree."

1 view (last 30 days)
i1=imread('1.jpg');
i2=imread('3.jpg');
j1=rgb2gray(i1);
j2=rgb2gray(i2);
k=abs(j1-j2);
l=colfilt(k,[8 8],'sliding',@sum);
sad_result=imshow(l);
  2 Comments
Vignesh
Vignesh on 1 May 2015
Edited: Vignesh on 1 May 2015
sorry abt tat . lemme explain, my intention is to obtain sum of absolute difference between two images and to display the result, but i am facing some error for tat '-' operator .

Sign in to comment.

Accepted Answer

Roger Stafford
Roger Stafford on 1 May 2015
From your error message I would guess that the matrix created for i1 is of different size from that of i2, and consequently matlab complained at the line
k=abs(j1-j2);
since j1 and j2 would also be of different sizes. You can easily check this by displaying the respective sizes of i1 and i2 in your code.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!