From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-13-2023 04:57 PM
Hello,
I have a program that locates and counts the objects in any image (see attached). It also locates the center of mass of the object but I am not sure how to extract those location coordinates. If you see attached image, it shows red dot at the center of objects found but I want to actually find the x and y coordinates so I can have a use of it. Can somebody please help?
Thanks
Veeshal
09-13-2023 05:58 PM
the VI you are using only counts objects. I suppose it would be super useful if you just wanted to count objects. Fast and easy to set up.
To get the center of mass (and a huge range of other data), you will need to use the particle analysis tool.
Check out the "Particle Analysis Report.vi" in LabVIEW examples.
You might be able to get away with the centroid tool.
Good luck!!
09-18-2023 04:08 PM
Hello,
I tried using "Particle Analysis Report.vi" as per your recommendation but it does not find all the objects as the "Find objects.vi" did. See attached programs.
Also, I am trying to make a rectangle on each object found with the help of location (pixels locations) from the report but it seems to not do it.
Can you or somebody suggest a correct way to approach it?
My main intention/goal is to locate all the objects in the attached image/screenshot and then make a bounding box around each object found.
Thanks
09-18-2023 06:01 PM
Particle Analysis Report should do everything you need. It even gives you the bounding box coordinates.
I can't open your code, so I have to guess. Did you threshold the image to make the dark objects bright and the background dark? If you run particle analysis on the image you posted, it will see one large white particle with a bunch of holes. I can't think of any other reason you would get different results.
Bruce
09-18-2023 06:52 PM
It does give me bounding box coordinates but it does not draw rectangles/boxes over the objects in the image and also I want to extract those coordinates to draw black squares/rectangles at those coordinate locations to make a dot peen like image.
No I did not threshold the image. Is it required to convert my black dots into white and the background into black?
I am not sure why you cannot open the code. It is in 2019 version. Attached is the code again. Let me know if you want me to save it in another version if you cannot open the attached code with this message.
Thank you so much for all the help.
09-18-2023 09:43 PM
I use LV 2017, but it isn't necessary for me to see your code.
The report just gives you all the data. You need to loop through the results and draw each rectangle on the image using Overlay Rectangle. If you wanted to, you could also draw a dot in the center and display a number next to each center. You have full control over the display in this case.
You do need to threshold the image, or use Invert or something. The report function is expecting a binary image where the zero pixels are not important and the non-zero pixels are particles.
If you open up the code for NI's count objects, you should see a sequence of steps. I would guess it thresholds, uses the report tool, then draws the results. It is easier, but it is a fixed sequence of steps. Learning to use the individual components lets you sequence them any way you please. Another advantage is you could check the size of the particles and make sure they are in a specific range to eliminate the small garbage particles.
Bruce
09-19-2023 06:24 PM
Hi Bruce,
I have already tried the overlay rectangle thing but for some reason I am not able to get it. See attached program saved in 2017 version. I think I am doing something wrong just not sure where.
For your comment on looking into details of count object program, I will look into it and see how it is recognizing centroids and making rectangles to see if it helps me. Currently, the program is finding 721 objects and that is too many.
Thanks
09-19-2023 08:26 PM
A few notes:
You don't need to run this in a loop. Once through is fine.
You need to wire "Image" into the shift register that draws the boxes. Otherwise it doesn't know what to draw the boxes on.
I used AutoBThreshold set to find dark objects and it worked pretty well. It reduced the number of objects to 111.
I would look at the area of the particle when drawing boxes and eliminate any small ones, like <50 pixels. That should just get the ones you care about.
I changed the draw mode to fill. Solid boxes are easier to see.
I attached the modified version.
Bruce
09-20-2023 11:48 AM
Thank you Bruce. I will read and understand the program.