Hi
I’m assuming you want to extract the bounding box from the binarized image and then calculate the aspect ratio of the detected components for further processing.
After getting the binarized image from yellow.m, you can use imdilate with a structuring element as ones(19) to merge all the white components. After that you can just use regionprops to get the region of the detected component. I am also attaching the code for easy understanding.
Hope this helps.
I = imread('fogg1.jpg');
J = rgb2ycbcr(I);
CB = J(:,:,2);
histCB = imhist(CB)/numel(CB);
CCB = zeros(size(histCB));
for j = 1:length(CCB)
CCB(j) = sum(histCB(1:j));
end
inx = find(CCB < 0.01,1,'last');
B = CB <= inx-1;
se = ones(19);
dilated = imdilate(B, se);
info = regionprops(dilated,'Boundingbox') ;
imshow(dilated)
hold on
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',2) ;
end
lower_left_corner = [BB(1), BB(2)];
width = BB(3);
height = BB(4);
Best Answer