01-10-2019 03:09 PM
Let's say I have a binary image on the FPGA. What's the best way to count how many particles are in the image? Is there a solution that keeps the image on the FPGA?
If the answer is "no", one option is to transfer the image to the CPU. Is the best option for image transfer to use a FIFO? I'm looking to minimize worst case latency. Image size is ~2000 pixels.
01-10-2019 03:28 PM
What do you know about the particles? Are they convex all the way around? Are they regular shapes? How many might you see in a single row of pixels?
My initial thought is to scan each line of image, and keep track of starting and ending points of each particle. Increase particle count if a new section is not touching section from previous line. This only works if the particles are all convex, and only works if there is a limited number of particles per row.
It seems like you could store 2000 pixels in memory on the FPGA. You can store and retrieve one value at a time.
Bruce
01-10-2019 03:44 PM
Particles are only a few pixels in area (like 10 px) so they can be rather irregular. I'm not expecting a very large number of px (maybe 5 or fewer)
I wasn't totally clear on what you meant by starting and ending point. I might need a diagram.
Here's a crop from a typical image with 3 particles.
01-10-2019 06:33 PM
I would probably use a variation of the image labeling routine. This would require storing the previous line of the image, but that wouldn't be a big deal.
Start by scanning across each row. If there is a pixel to the left, assign the current pixel the same value. If no left pixel, check if there is a pixel above it and use that value. Otherwise, increment your count and use that value. If there is a pixel above it and there was a pixel to the left, if the values are different, increment your extra counter (only once per value). At the end, subtract the extra from the count to get the correct count.
This is probably quite difficult to follow without a sketch and some examples. Unfortunately I don't have time to do all that.
Bruce
01-11-2019 12:16 PM - edited 01-11-2019 12:42 PM
Are you describing the two pass method here:
01-11-2019 01:50 PM
If you are using Vision Development Module from NI.
There is a function Partical Analysis Report for FPGA.
Should be doing what you need.
I am working on NI PCIe-1477 and NI PCIe-1473R-LX110.
Seems like the function is available for both.
Did you review this function?
I attach the help for this function.
01-11-2019 03:21 PM
I don't think that outputs "count". Here's the doc:
http://zone.ni.com/reference/en-XX/help/370281AA-01/visionfpga/imaq_fpga_particleanalysisreport/
01-11-2019 04:46 PM
I haven't tried yet. But usually you just need to count the number of elements in the array of measurements to get the partical number.
01-11-2019 04:54 PM
I don't see an "array of measurements" as an output in the documentation.
01-11-2019 07:49 PM
Nanocyte,
That does look like what I was describing. If you just want a count, you don't need the second pass. You just need to count the extra labels and subtract that from the count at the end.
Bruce