I have a task that requires analyzing an image filled with colored shapes and highlighting the blue circles in the image. To do this, I have split the image into its RGB channels and created a binary image of only the blue pixels. Using blob detection I've managed to segment the image and find the roundness for each of the shapes. However, when I try to place a boundary line on the round shapes, it places the boundary around ALL shapes, not just the circles. The relevant section of code is shown below;
imshow(BBinEro)
for cnt = 1:length(BlueProps)
%disp(score);
if score(cnt) >= 0.98 %
text(BlueProps(cnt).Centroid(1),BlueProps(cnt).Centroid(2),num2str(score(cnt)),'color','red');
boundaries = bwboundaries(BBinEro);
numberOfBoundaries = size(boundaries);
hold on
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
if score(cnt) >= 0.98 %Only showing for circles
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
end
hold off
end
end
"Score" is a measure of the circularity of the blob. A score of 1 means that the blob is perfectly round. The program displays the circularity of the round shapes at their centroid; using the same if-statement, I've attempted to incorporate inserting a boundary line around them. Any suggestions or observations on how I can fix this code so that it only shows the boundaries on the circles would be greatly appreciated.
The attached image shows what the program is currently doing. I want to get rid of the green boundaries around the triangle and the square.