From: Erwasd W on
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
From: Ashish Uthama on
On Mon, 17 May 2010 14:53:04 -0400, Erwasd W <erwasd1(a)gmail.com> wrote:

> 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

How about using IMFILL (with 'Locations' argument) to 'erase' the objects
you deem as being nor circular enough? You could supply one of the points
(centroid?) for each non-circular blob.

Or, maybe you can do the next step of the processing only in blobs which
are circular. Why bother actually erasing them?

It might help to post code and/or intermediate images. I was surprised
that a circular measure was able to differentiate the two (until I
realized you were doing this on post thredholded images).

Another thought: Can you do something more with the light to help your
post processing? I assume you have control on the image acquisition. Maybe
you can create a image capture environment which increases the contrast
between the two types of particles? If you said more about the
particles/image capture process maybe other ppl here would be able to
offer some suggestions.
From: ImageAnalyst on
I don't see how circularity distinguishes anything. Both the black
and tan particles have a mixture of shapes, everything from nearly
round to very string-like. To distinguish the left side (black)
particles from the right side (tan) particles, I'd simply do a color
classification, like in this simple demo:
http://www.mathworks.com/matlabcentral/fileexchange/26420-simplecolordetection
In fact I see some particles on each side where you could make the
argument that they belong on the other side. It's not like all tan
particles on the left side are string-like where as all black
particles on the left side are round. So if these particles were all
jumbled together, I can't see how you'd tell if they were a "left
side" class or a "right side" class (whatever those classes may be).

By the way, you don't need to invert (complement) your binary image if
you choose your threshold range correctly in the first place.
From: Sean on
"Erwasd W" <erwasd1(a)gmail.com> wrote in message <hss3cc$nq4$1(a)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.