Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Clever particle filter

Solved!
Go to solution

Hello,

 

I am trying to solve a task, where I need to exclude blobs in binary image based on the blob size,

the size treshold changes with the blob position.

Since this is not doable through the standard particle filter, I made mask out of results.

The algorithm is not fast enough + it keeps bad blobs if the later bounding boxes overlap them.

 

snippy.png

 

Please suggest some other method.

 

Bublina

 

 

0 Kudos
Message 1 of 6
(3,926 Views)

Hi Bublina!

 

Your method is a really good start, I would like to add a few ideas to it. First of all, you can add many objects (rectangles, ovals, points, etc.) to a single ROI descriptor, so it's easier to have all removed objects listed in a single ROI, then you can do the masking all at once. You can also fasten execution by using Particle Analysis.vi, which only performs the measurements selected by you, not all of them.

Here's some example code of these changes: (sorry for the picture instead of a snippet, my LV is acting up a bit)

custom particle filter.jpg

Just replace the code at the red arrow with your decision-making code and it should work.

 

As you can see it is still quite a simple filter (it masks bounding rectangles), so if you have strangely shaped particles or your particles are too close together, some useful data might be erased. So if you need a more precise approach you could go by labeling your particles (so assigning a different color to each one), then deleting colors from the image based on criteria you specify.

 

I hope this helps.

 

Best regards:

 

Andrew Valko

NI Hungary

 

Andrew Valko
National Instruments Hungary
0 Kudos
Message 2 of 6
(3,903 Views)

Very nice,

it indeed works twice faster or more. Unfortunately, I get too many good blobs residing in bad blobs removed.

I am trying to use cvBlob library now.

 

Good advice anyway, have to remember the Particle Analysis.vi

0 Kudos
Message 3 of 6
(3,897 Views)
Solution
Accepted by topic author Bublina

Dear Bublina!

 

If masking rectangles away does not work properly, you can still try my other suggestion: Labeling particles and filtering them by label. Here's the core idea:

 

Object selection.png

 

Particle analysis returns particles in the same logical order (first pixel scanned from top to bottom, left to right) as IMAQ Label. For every particle returned, you can define whether to keep it or throw it away, then based on this decision you create an integer (1 or 0 respecively) and load the array created from these integers into a user-defined Look-Up Table.

 

For me this approach worked pretty well.

 

Best regards:

 

Andrew Valko

Andrew Valko
National Instruments Hungary
Message 4 of 6
(3,892 Views)

I was allways wondering what is that user LookUp good for 🙂

 

So I managed to do some extra 2 hours of work implementing that library Smiley Frustrated

 

Thanks a lot !

 

Anyone reading this, keep in mind you have to put extra element in the array start as for the background !

 

snippy.png

Message 5 of 6
(3,886 Views)

Dear Bublina!

 

Thanks for posting your solution code! Best of luck with your application.

 

Cheers:

 

Andrew V.

 

Andrew Valko
National Instruments Hungary
0 Kudos
Message 6 of 6
(3,882 Views)