annotate toolboxes/FullBNT-1.0.7/KPMtools/rectintSparseC.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [overlap, normoverlap] = rectintSparseC(A,B)
wolffd@0 2 %
wolffd@0 3 % function [area, normarea] = rectintSparseC(A,B)
wolffd@0 4 % A(i,:) = [x y w h]
wolffd@0 5 % B(j,:) = [x y w h]
wolffd@0 6 % out(i,j) = area of intersection
wolffd@0 7 %
wolffd@0 8 % Same as built-in rectint, but uses less memory.
wolffd@0 9 % Also, returns area of overlap normalized by area of patch.
wolffd@0 10 % See rectintSparse
wolffd@0 11
wolffd@0 12 if isempty(A) | isempty(B)
wolffd@0 13 overlap = [];
wolffd@0 14 normoverlap = [];
wolffd@0 15 return;
wolffd@0 16 end
wolffd@0 17
wolffd@0 18 leftA = A(:,1);
wolffd@0 19 bottomA = A(:,2);
wolffd@0 20 rightA = leftA + A(:,3);
wolffd@0 21 topA = bottomA + A(:,4);
wolffd@0 22
wolffd@0 23 leftB = B(:,1)';
wolffd@0 24 bottomB = B(:,2)';
wolffd@0 25 rightB = leftB + B(:,3)';
wolffd@0 26 topB = bottomB + B(:,4)';
wolffd@0 27
wolffd@0 28 numRectA = size(A,1);
wolffd@0 29 numRectB = size(B,1);
wolffd@0 30
wolffd@0 31 verbose = 0;
wolffd@0 32 [overlap, normoverlap] = rectintSparseLoopC(leftA, rightA, topA, bottomA, leftB, rightB, topB, bottomB, verbose);