Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Filtering out particles from image based on circularity

Subject: Filtering out particles from image based on circularity

From: Erwasd W

Date: 17 May, 2010 18:54:04

Message: 1 of 2

My group and I need to filter out the right hand side particles from the image, to then calculate the area of the remaining left hand side particles (using bwarea). This is a sample image we created for testing, so in the real application the two types of particles will be mixed.

So far we have been able to use im2bw and its threshold argument to take advantage of the lighter colour of the unwanted particles. This created a binary image with the background as white. We then used imcomplement to invert the image so that the bwarea function could sum the area of the now white particles.

However using the threshold and im2bw does not filter out all the unwanted particles due to similar colour. We believe that we can eliminate more unwanted particles by taking advantage of the differences in circularity between the two types. The right hand side tend to exhibit thinner less circular shapes.

We have used this demo ( http://www.mathworks.com/products/imageb/indexb.html?sec=tour&subsec=demo&file=/products/demos/shipping/images/ipexroundness.html#5 ) to calculate circularity of objects, confirming that the unwanted particles are less circular. However, we are unsure how to erase these objects from the image. Any advice?

Here is the sample image.
http://img265.imageshack.us/img265/9640/sample1n.jpg

Subject: Filtering out particles from image based on circularity

From: Sean

Date: 17 May, 2010 19:52:03

Message: 2 of 2

"Erwasd W" <erwasd1@gmail.com> wrote in message <hss3cc$nq4$1@fred.mathworks.com>...
> My group and I need to filter out the right hand side particles from the image, to then calculate the area of the remaining left hand side particles (using bwarea). This is a sample image we created for testing, so in the real application the two types of particles will be mixed.
>
> So far we have been able to use im2bw and its threshold argument to take advantage of the lighter colour of the unwanted particles. This created a binary image with the background as white. We then used imcomplement to invert the image so that the bwarea function could sum the area of the now white particles.
>
> However using the threshold and im2bw does not filter out all the unwanted particles due to similar colour. We believe that we can eliminate more unwanted particles by taking advantage of the differences in circularity between the two types. The right hand side tend to exhibit thinner less circular shapes.
>
> We have used this demo ( http://www.mathworks.com/products/imageb/indexb.html?sec=tour&subsec=demo&file=/products/demos/shipping/images/ipexroundness.html#5 ) to calculate circularity of objects, confirming that the unwanted particles are less circular. However, we are unsure how to erase these objects from the image. Any advice?
>
> Here is the sample image.
> http://img265.imageshack.us/img265/9640/sample1n.jpg


If you use:
>>CC = bwconncomp(your_bwimage);
It will group all connected components together.
Then run:
>>props = regionprops(CC,'Area','Centroid') as in the demo
Then calculate circularities of each as it sounds like you've done. I think you've gotten this far.

Now you have a vector of circularities with each one corresponding to the respective object.
keepvec = circularities>some_thresh; %true for ones you want to keep (above threshold value)
newimage = zeros(size(old_image));% preallocate new image
newimage(CC.PixelIdxList{keepvec}) = 1; %turn the ones you want white.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us