%Compute Rectangle and Bbox Features
BW = bwareaopen(binaryImage,200);
bboxImage = zeros(size(BW));
bboxes = regionprops(BW,'BoundingBox');
for k=1:1:length(bboxes)
bb = bboxes(k).BoundingBox;
bboxImage(round(max(1,bb(2))):round(bb(2)+bb(4)),round(max(1,bb(1)):round(bb(1)+bb(3)))) = 1;
end
bboxImage=bboxImage(1:size(BW,1),1:size(BW,2));
bboxFeatures(:,t) = bboxImage(:);
bFeatures = bboxImage(:);
y = double(mapClasses == t) .* unaries(:,t);
rFeatures = y;
rFeatures(bFeatures==0) = 0;
rectFeatures(:,t) = rFeatures;
matlab