How to Separate Connected Objects in an Image
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hannah Faustyn
el 31 de Mayo de 2021
I am trying to count the number of objects in a picture using bwconncomp, but the results are incorrect because some of the regions blend together. I used the image from https://www.publicdomainpictures.net/pictures/290000/velka/field-of-flowers-1553807209QZG.jpg to illustrate my problem.
This is the original image, and I'd like to write code that counts the total number of flowers in the picture.
I used the following code:
image = imread(fileName);
%Convert to grayscale
imageGray = rgb2gray(image);
%Remove noise
SE = strel('disk', 5);
afterOpening = imopen(image, SE);
%Convert to binary image and filter out small objects
imageBin = imbinarize(afterOpening);
imageBin = bwareaOpen(imageBin, 300);
%Count the number of objects
CC = bwconncomp(imageBin);
numObjects = CC.NumObjects;
I am pretty sure that bwconncomp will count the three flowers highlighted above as one region, thereby skewing the count in numObjects. Is there a way that I can get Matlab to recognize the highlighted box as having 3 objects instead of 1?
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!