How to filter the image for blobs of specified size
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdullah bashanfer
le 16 Juil 2016
Modifié(e) : Image Analyst
le 17 Juil 2016
This is the code I used, but it doesn't eliminate the blobs. I want to remove the obstacles only to determine the highest middle point for the robot to navigate.
rgb=imread('obstacle_scene_1.jpg');
figure, imshow(rgb);
[im,map] = rgb2ind(rgb,5);
figure, imshow(im,map)
[X_no_dither,map]= rgb2ind(rgb,5,'nodither');
figure, imshow(X_no_dither,map);
[im,map] = rgb2ind(rgb,5);
figure, imshow(im,map)
level = graythresh(X_no_dither);
bw = im2bw(X_no_dither,level);
bw = bwareaopen(bw, 50);
figure, imshow(bw)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154913/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154914/image.jpeg)
0 commentaires
Réponse acceptée
Image Analyst
le 16 Juil 2016
bwareaopen() removes blobs of a specified size and below. You're calling that, so that part is right. There are also related functions bwareafilt() and bwpropfilt().
Your problem is segmentation, not size filtering. You need to segment your image better. For that particular image I suggest you convert to HSV color space with rgb2hsv, then threshold the s channel to find vividly colored regions. See my demos in my File Exchange, or see the Color Thresholder on the Apps tab of the MATLAB tool ribbon.
2 commentaires
Image Analyst
le 17 Juil 2016
Modifié(e) : Image Analyst
le 17 Juil 2016
Fantastic! You might also want to use
% Fill holes
binaryImage = imfill(binaryImage, 'holes');
If you don't need holes filled, then don't do it since it will slow it down, but just slightly.
I'm glad I could help, and thanks for accepting the answer.
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!