Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB image processing of small circles

I have an image which looks like this:

Bottle

I have a task in which I should circle all the bottles around their opening. I created a simple algorithm and started working it. My algorithm follows:

  • Threshold the original image
  • Do some morphological opening in it
  • Fill the empty holes
  • Separate the portion of the image using region props such that only the area equivalent to the mouth of the bottles is selected.
  • Find the centroid for each and draw circle around each bottle.

I did according to the algorithm above and but I have some portion of the image around which I draw a circle. This is because I have selected the area since the area of the mouth of bottle and the remained noise is almost same. And so I yielded a figure like this.

The processing applied on the image look like this:

Enter image description here

And my final image after plotting the circle over the original image is like this:

Enter image description here

I think I can deal with the extra circle, that is, because of some white portion of the image remained as shown in the figure 2 below. This can be filtered out using regionproping for eccentricity. Is that a good idea or there are some other approaches to this? How would I deal with other bottles behind the glass and select them?

like image 886
Sandeep Avatar asked Nov 13 '11 15:11

Sandeep


People also ask

What are the 4 image types in Matlab?

Image types determine how MATLAB® interprets data matrix elements as pixel intensity values. The toolbox supports many image types including binary, grayscale, truecolor, multispectral, and label images.

How does Imfindcircles work Matlab?

Description. centers = imfindcircles( A , radius ) finds the circles in image A whose radii are approximately equal to radius . The output, centers , is a two-column matrix containing the (x,y) coordinates of the circle centers in the image.

What is Bwareafilt Matlab?

bwareafilt returns a binary image BW2 containing only those objects that meet the criteria. example. BW2 = bwareafilt( BW , n ) keeps the n largest objects. In the event of a tie for n -th place, only the first n objects are included in BW2 .


1 Answers

Nice example images you provide for your question!

One thing you can use to detect the remaining bottles (if there are any) is the well defined structure of the placement of the bottles. The 4 by 5 grid of the bottle should be relatively easy to locate, and when the grid is located you can test if a bottle is detected at each expected bottle location.

With respect to the extra detected bottle, you can use shape features like

  • eccentricity,
  • the first Hu moment
  • a ratio between the perimeter length squared over the area (which is minimized for a circle) details here

If you are able to detect the grid, it should be easy to located it as an outlier (far from an expected bottle location) and discard accordingly.

Good luck with your project!

like image 69
midtiby Avatar answered Nov 16 '22 03:11

midtiby