function testFindS3
% testFindS3 - Matching the Active Plate (S3) template.

mex mexc_FindS3.cpp
load Config partGainThreshold partInhibitionMethod partSize
imageName = dir(['positiveImage' '/*.jpg']);
load('working/S2Dict.mat','S2Dict','S2TNeighbors','canonicalS2IndByLoc', 'S2DictPaths', 'numCandPart', 'PartList');
partOnOff = zeros(1,numCandPart);
score = zeros(1,numCandPart);
for j = 1:numCandPart
	load(sprintf('working/LearnedPart_%d_%d.mat',PartList(1,j),PartList(2,j)));
    score(j) = aveMAX2score;
end
if strcmp(partInhibitionMethod,'none')
	partOnOff = double( score >= partGainThreshold );
elseif strcmp(partInhibitionMethod,'boundingbox')
    for k = 1:numCandPart
		[highest ind] = max(score);
		if highest < partGainThreshold
			break;
		end
		% select this partial template
		partOnOff(ind) = 1;
		loc = PartList(1:2,ind);
		% inhibit according to the bounding box center
		for j = 1:numCandPart
			loc2 = PartList(1:2,j);
			if abs( loc2(1) - loc(1) ) + abs(loc2(2)-loc(2)) <= partSize/4
				score(j) = min(0,partGainThreshold-1);
			end
		end
    end
end

% save the selected parts
save working/partOnOff.mat partOnOff

imageIDList = 1:length(imageName);
find_S3( imageIDList, partOnOff );
