matthiasm@8: function [overlap, normoverlap] = rectintSparseC(A,B) matthiasm@8: % matthiasm@8: % function [area, normarea] = rectintSparseC(A,B) matthiasm@8: % A(i,:) = [x y w h] matthiasm@8: % B(j,:) = [x y w h] matthiasm@8: % out(i,j) = area of intersection matthiasm@8: % matthiasm@8: % Same as built-in rectint, but uses less memory. matthiasm@8: % Also, returns area of overlap normalized by area of patch. matthiasm@8: % See rectintSparse matthiasm@8: matthiasm@8: if isempty(A) | isempty(B) matthiasm@8: overlap = []; matthiasm@8: normoverlap = []; matthiasm@8: return; matthiasm@8: end matthiasm@8: matthiasm@8: leftA = A(:,1); matthiasm@8: bottomA = A(:,2); matthiasm@8: rightA = leftA + A(:,3); matthiasm@8: topA = bottomA + A(:,4); matthiasm@8: matthiasm@8: leftB = B(:,1)'; matthiasm@8: bottomB = B(:,2)'; matthiasm@8: rightB = leftB + B(:,3)'; matthiasm@8: topB = bottomB + B(:,4)'; matthiasm@8: matthiasm@8: numRectA = size(A,1); matthiasm@8: numRectB = size(B,1); matthiasm@8: matthiasm@8: verbose = 0; matthiasm@8: [overlap, normoverlap] = rectintSparseLoopC(leftA, rightA, topA, bottomA, leftB, rightB, topB, bottomB, verbose);