Detecting circular shaped fruit in 2D images using circular Hough transform or alternative algorithm

10 visualizzazioni (ultimi 30 giorni)
I am trying to detect circular fruits using the circular Hough transform after applying edge detection. However, the circular Hough transform parameters seem to be very sensitive, i.e. the ''Sensitivity'' and ''EdgeTreshold''. A small change in one of these parameters has huge impact on the amount of circles that are detected. How can I avoid this or is there a better algorithm to detect the circular shaped fruits? Moreover, I need to use the Rmax of 85 for optimal results, while the absolute maximum Rmax is 55, after measuring the distance with imdistline.
I am using now the following parameters:
[centers,radii, metric] = imfindcircles(BW_Canny,[30 85],'Sensitivity',0.95,'EdgeThreshold',0.15);
viscircles(centers, radii,'EdgeColor','b');
I have added the original RGB image, the images after color thresholding and edge detection, and beneath my own results.

Risposte (1)

Image Analyst
Image Analyst il 10 Gen 2022
You don't need to find circular shapes. From your other posts, you're trying to find oranges on a tree. The oranges are almost always overlapping with other oranges so the combined blob is not round, or don't have a circular shape because there is shine on the rind, or leaves are obscuring the shape, making it not round. If you limit your segmentation to only round blobs, you're going to miss the majority of blobs.
That said, there is a 'circularity' property in regionprops that gives you the circularity of blobs. You can also use bwpropfilt() to remove blobs outside the acceptable range of circularity. Again, I recommend not doing that.
  10 Commenti
S.
S. il 26 Gen 2022
Modificato: S. il 27 Gen 2022
I did Canny on my original mask, as it performs better with the Circular Hough Transform if you only see the edges. However, after using the original binary image, regionprops() indeed performs better than initially (i.e.with Canny on the original mask). Do you know why?
However, I see also the following differences:
When I use regionprops():
  • Every blob is recognized as an orange and therefore it performs good when an orange is for a large part occluded by a leaf/trunk. However, if an orange is splitted in two different blobs, it is also recognized as two different oranges.
  • Two overlaying blobs (two overlaying oranges) are recognized as one area and therefore one orange.
When I use the CHT:
  • Two overlaying blobs (two overlaying oranges) are recognized as two different oranges, due to two different edge patterns.
  • If an orange is splitted in two different blobs, it is recognized as one orange due to the circular shape.
  • It doesn't perform good when an orange is for a large part occluded by a leaf/trunk due to the weird shape.
However, as I mentioned earlier, the CHT is very sensitive, changing the ''Sensitivity'' or the ''Edge threshold'' parameter slightly changes the performance drastically. Moreover, I still don't know why I need to set the minimum radius to 20 and the maximum radius to 60 for best results, while the maximum radius in reality is 50.
I don't know whether there are other techniques than regionprops() and CHT that I could try.
''Train the model by going out and actually physically counting the oranges and then make up a model that gives an estimate of the number of oranges there based on the area fraction and blob count." --> The goal is to detect the center of an orange as accurate as possible to be clear. I did indeed physically count the oranges to determine the true oranges. Do you think its necessary to make a train and test set? Maybe I can make a train set to train the algorithm for different settings and see which settings give the best performance.
Image Analyst
Image Analyst il 28 Gen 2022
I can see that we're never going to see eye-to-eye on this. For another example you want to measure things that I say don't matter, like the location of the center of an orange, which of course varies tremendously depending on where the photographer was standing and how he was aiming the camera, and literally how the wind was blowing. Things like finding only round blobs, counting blobs, etc. will always be problematic and that's why, based on my 40+ years of image processing, you should look for other things like area fraction for determining when to harvest your crop or how much the oranges have grown.
So good luck to you with your approach.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by