Can anyone explain how Sum of Squared Difference works?

3 views (last 30 days)
I have the following formula for Sum of Squared Difference:
To solve the formula in Matlab, i have came up with the following code:
firstTerm=conv2(imgR.^2,ones(size(t)),'same');
secondTerm= ???;
thirdTerm=2*conv2(imgR,rot90(t,2),'same');
metric=firstTerm + secondTerm - thirdTerm;
where imgR is the right image, and t is the template of imgL (image left).
However, I am unsure of what to fill in for the second Term.
Can anyone enlighten me on how to code the secondterm, as well as whether is there any error in my code?
if it helps, t is a 11x11 template.
Thanks in advance.

Answers (0)

Community Treasure Hunt

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

Start Hunting!