04-19-2013 07:43 PM
Your algorithm was just too complicated. I couldn't figure out what you were trying to do.
I tried out your image in Vision Assistant. I used auto-threshold with clustering, then I used Basic Morphology to do a 5x5 open, which eliminated all the small spots. After that, Particle Analysis very quickly gave me the bounding rectangle of each particle. Threshold took 4 ms, Open took 7 ms, and Particle Analysis took 4 ms. You can't get much faster.
Bruce
04-19-2013 11:40 PM
04-22-2013 10:34 AM
Hello Bruce,
any help on this algorithm.
Lazer
04-22-2013 01:17 PM
I haven't written any code. I only used Vision Assistant briefly. I don't really want to rewrite your code for you. I see no reason to write a long, complicated algorithm when Particle Analysis does it much faster.
I would suggest doing everything in pixel coordinates, then convert them to real world when you are done. As long as your real world coordinates are parallel to the pixel coordinates, you will get the same results. If your real world coordinates are rotated, perhaps you should rotate the image to match, then use pixel coordinates.
Bruce
04-24-2013 08:25 AM
Hello Bruce,
You said in one of your reply " The bounding boxes can be combined into a single box by using the max of the maxes and the min of the mins." and I am trying to do it but could not find a way. Can you tell, how can I do this please?
Many Thanks,
Lazer
04-24-2013 02:33 PM
Use a for loop to autoindex through the results. For each value (top, left, bottom, right) output the value on the right of the loop and use autoindexing to get arrays. Use array min/max to get min of top array (new top), min of left array (new left), max of bottom array (new bottom), and max of right array (new right). Put them together to get your bounding box.
Bruce
04-24-2013 04:04 PM
Hello Bruce,
Thanks for advice. Can you look at my code, am I on the right track.
Many Thanks
Lazer