This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: mode = 1 - return a sorted list of differences in ascending order global GL if nargin < 3 mode = 0 end % calculate B2 [rows cols] = size(A) S = ones(rows,cols) B2 = filter2(S,B.^2,'valid') % calculate sum over A squared sumA2 = sum(sum(A.^2)) % calculate A conv B AB = filter2(A,B,'valid') % calculate D D = (-2*(AB)+B2)+sumA2 [rows cols] = size(D) if mode tL = zeros(rows*cols,3) L = zeros(rows*cols,3) count = 0 else L = [D(1,1) 1 1] end for i=1:rows for j=1:cols if mode count=count+1 tL(count,1:3) = [D(i,j) i j] else if D(i,j) < L(1,1) L = [D(i,j) i j] end end end Sheet1 Page 2 end if mode [Y I] = sort(tL(:,1)) for i = 1:count L(i,1:3) = tL(I(i),1:3) end end if mode > 0 GL = L end...
View Full Document
This note was uploaded on 04/20/2008 for the course ENGR 190 taught by Professor Staff during the Spring '08 term at Santa Clara.
- Spring '08