Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I extract a circular particle from inside a square line?

Hi!

I have a binarized image, where I have circles inside squares (see attached image "binarized.bmp").

I want to remove the square, and only keep the circle. But when I run a particle filter, it removes both the square and the circle. I have some circles left in my filtered image, but not as many as I would wish (see attached image "filtered.bmp").

This is my particle filter:
//Remove small and large blobs
filterCriteria[0].parameter = IMAQ_AREA;
filterCriteria[0].lower = 100;
filterCriteria[0].upper = 30000;
filterCriteria[0].exclude = TRUE;
//Remove squares
filterCriteria[1].parameter = IMAQ_HEYWOOD;
filterCriteria[1].lower = (float) 0.7;
filterCriteria[1].upper = (float)1.3;
fi
lterCriteria[1].exclude = TRUE;

//Set border size of the image to make imaqConvolve work
imaqSetBorderSize(myBinaryImage,3);

//Run the particle filter
if(!imaqParticleFilter (myBinaryImage, myBinaryImage, filterCriteria, 2,TRUE, TRUE)){
printf("ERROR: imaqParticleFilter(): '%s'\n",imaqGetErrorText(imaqGetLastError()));
}

How can I be sure to extract the circles?

Thanks!
Download All
0 Kudos
Message 1 of 4
(3,256 Views)
Try sorting on size first if you know approximately their size. Then sort on hydraulic radius, type, or elongation factor to get rid of particles with different shapes. I tried to keep size (remove with exclude) 60-300 pixels and exclude (remove) hydraulic radius 0,7-1,8 with success.
0 Kudos
Message 2 of 4
(3,256 Views)
Thanks, Torten!

What parameters would you suggest for "type" and "elongation factor"?

Torbjørn
0 Kudos
Message 3 of 4
(3,256 Views)
Good Afternoon,
I also experimented with your image. I used particle filtering techniques that were similiar to yours.

filterCriteria[0].parameter = IMAQ_AREA;
filterCriteria[0].lower = 275;
filterCriteria[0].upper = 30000;
filterCriteria[0].exclude = FALSE;
//Remove squares
filterCriteria[1].parameter = IMAQ_HEYWOOD;
filterCriteria[1].lower = (float) 0.7;
filterCriteria[1].upper = (float)1.5;
filterCriteria[1].exclude = TRUE;

filterCriteria[0].parameter = IMAQ_AREA;
filterCriteria[0].lower = 0;
filterCriteria[0].upper = 60;
filterCriteria[0].exclude = FALSE;

This also maintained all 5 of the circles.

Sincerely,
Will
0 Kudos
Message 4 of 4
(3,256 Views)