How to crop object in image automatically?
Afficher commentaires plus anciens

I want to count pixel (binary =1) in object (in this case It is a pill) but this picture have noise so I think I should to crop the image to count How can I automatically crop the circle. or new suggestion how to count pixel
Réponse acceptée
Plus de réponses (1)
I guess you figured it out since you accepted the answer but I'll offer a different way. Simply call imclearborder followed by bwareafilt
binaryImage = imread('pillsc.png');
subplot(2, 1, 1);
imshow(binaryImage);
% Get rid of blobs touching border.
binaryImage = imclearborder(binaryImage);
% Take the largest of the blobs that are left.
binaryImage = bwareafilt(binaryImage, 1);
subplot(2, 1, 2);
imshow(binaryImage);
Catégories
En savoir plus sur Computer Vision with Simulink dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



