I need red circles white, and the rest as black. Exactly like binary image. I could filter out only red color, then do stuff but how to include only circles?
I tried many things but it just doesn't work. I guess because of deprecated functions of MATLAB. Because many of these topics are so old atleast 10 years old. I tried these:
https://nl.mathworks.com/help/images/ref/bwareaopen.html
https://nl.mathworks.com/matlabcentral/answers/19507-remove-non-circle-objects-from-image
I only came so close with this code, but it still leaves squares and hexagons around. I want them gone but don't know how. I tried increasing minExtend, or decreasing, but it doesn't do it.
I=imread('circlesColored.png');
% Get the image as a b&w indexed (non-rgb) image
R=I(:,:,1);
R=(R>35&R<255);
imshow(R);
bwareaopen(I, 50);
BW = gray2ind(R, 2);
%Calculate its connected regions
L = bwlabel(BW); % Not using bwconncomps() for older version users
stats = regionprops(L,'Extent','Area');
%Find the ones that are like a circle
minExtent = 0.75;
keepMask = [stats.Extent]>minExtent;
%Extract the image of circles only and display
BWcircles = ismember(L, find(keepMask));
BWnonCircles = BW & ~BWcircles;
%Show the circles
figure, imshow(BWcircles)

