Borrar filtros
Borrar filtros

How to select only round objects from this image?

3 visualizaciones (últimos 30 días)
Mohammad Farhad Aryan
Mohammad Farhad Aryan el 7 de Mzo. de 2020
Comentada: Image Analyst el 22 de Jul. de 2022
I am working on images that have round and some non-round objects and I want to select only the round objects. How can I select only round objects from the image in post https://www.mathworks.com/help/images/identifying-round-objects.html ?
Any help is appreciated.

Respuesta aceptada

Image Analyst
Image Analyst el 7 de Mzo. de 2020
Threshold the image to get the blobs, then compute circularities and filter to get those with circularities near 1:
mask = imbinarize(grayImage);
mask = imfill(mask, 'holes');
labeledImage = bwlabel(mask);
props = regionprops(mask, 'Area', 'Perimeter');
allAreas = [props.Area];
allPerimeters = [props.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
% Get those blobs with circularity near 1.
roundindexes = find(circularities > 0.8 & circularities < 1.5)
% Get new mask
roundBlobs = ismember(labeledImage, roundIndexes);
imshow(roundBlobs);
title('Only the round blobs')
  3 comentarios
Amal
Amal el 22 de Jul. de 2022
what is the function ismember
Image Analyst
Image Analyst el 22 de Jul. de 2022
ismember tells you if some or all of one list is contained in another list.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by