sum of absolute differences

조회 수: 14 (최근 30일)
nomad nomad
nomad nomad 2012년 3월 30일
답변: indhumathi gunasekar 2016년 9월 29일
Good evening everyone,
I have two images which I seek correspondence by correlation using the sum of absolute differences (SAD) to find the disparity map.
I do not know how to apply the formula of SAD.
thank you
  댓글 수: 1
vimal
vimal 2012년 6월 26일
You can directly use correlation method..
corr2(im1,im2) is the code for calculating the correlation between two images.
for more details type
doc corr2
in command window..

댓글을 달려면 로그인하십시오.

답변 (3개)

Jan
Jan 2012년 6월 26일
While imabsdiff is implemented as efficient MEX (no temporary array created), you can calculate the "sum of absolute differences" easily by hand also:
img1 = rand(640, 480, 3);
img2 = rand(640, 480, 3);
difference = img1 - img2;
absolute = abs(difference);
result = sum(absolute(:));
It is less obvious for UINT8 images, because abs(uint8(10) - uint8(20)) is not uint8(10), uint8(0) due to the saturation effects. If this is not wanted, convert the UINT8 image to double at first.

Alex Taylor
Alex Taylor 2012년 3월 30일
If you have the Image Processing Toolbox, consider looking at the function imabsdiff as a starting point for computing the absolute difference between two images.
help imabsdiff

indhumathi gunasekar
indhumathi gunasekar 2016년 9월 29일
i have two 16*16 matrix,i need to find SAD between this. can anyone help me out?

Community Treasure Hunt

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

Start Hunting!

Translated by