How to use blob analysis and morphological operations to improve detection of occluded fruit?
25 views (last 30 days)
Show older comments
I am trying to detect fruits using machine vision and I am now removing the noise and keep only the (occluded) fruit. So far I used on the resulting binary images morphologic operations to remove the noise and keep the fruit. Using the disk element only the clear rounded fruits are detected and the rest is removed. Even if a part of the pixels is a disk only that part is kept and the other white pixels are removed (see picture below). However, I want that this part is also kept, as it is part of the fruit.
For example using a disk element with a radius of 4 pixels (3rd subplot) or with a radius of 7 pixels (4rd subplot) results in:
diskElem = strel('disk',4);
BW_clean = imopen(BW_Image, diskElem);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/836210/image.png)
How is it possible to keep after applying the disk element with a radius of 4 pixels the complete occluded fruit (so not as in the 4rd subplot) and remove the other noise? I have added these subplots and another example as attachement (.fig file) if you want to try. I have tried multiple morphologic operations, but didn't succeed. Or does anybody know a better way of noise removal of the binary image?
Moreover, for these occluded fruits I want to recognize them (first goal) and detect the centre/approximate the shape if possible (second goal).
Lastly, how is it possible to show an image after applying blobanalysis as I did below? And whats the difference between doing morphologic operations and blobanalysis?
Hblob = vision.BlobAnalysis('MinimumBlobArea', 315, ...
'MaximumBlobArea', 10000);
[objArea,centroid,bbox] = step(Hblob, BW_clean);
1 Comment
yanqi liu
on 17 Dec 2021
yes,sir,may be consider regionprops to get Circularity and Solidity property to analysis
Answers (1)
Image Analyst
on 17 Dec 2021
I don't know how you're doing your segmentation but it looks like you might be making the typical beginner mistake of using edge detection. That's not good -- there are edges all over the place.
Since you know your fruit have a different, and very specific color, you'd be best off using color segmentation by using the Color Thresholder on the Apps tab of the tool ribbon. That way you can be sure you you get orange and only orange blobs. You can do further clean up by using bwareaopen() or bwareafilt() to extract blobs only in a certain size range.
Attach your original full size image if you still need more help.
3 Comments
Image Analyst
on 10 Jan 2022
Not sure what you're going to do with that binary image. Are you just going to get the area to know how much fruit is on the tree? If so, then that is probably good enough. Why? Well consider that if you just swing around the tree to look at the same oranges from a slightly different angle, then you'll get a vastly different result. So obviously accuracy is not really needed here. But if you were doing something like driving past your orchard snapping pictures adjacent to each other in the scene, you would have some rough idea of how many oranges you now have in your orchard and that might give you some idea of the optimal time to go in and harvest the trees.
Juan Gomez
on 14 May 2022
Hello good, what is your email? I would like to ask you about a particular exercise that I have some doubts. Greetings and excuse me
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!