02-06-2018 06:55 AM - edited 02-06-2018 06:57 AM
Hello All!
I want to find the set of pixels inside each blob(in my case: they are circles) in an AVI file/ a image. I am aware that by using IMAQ Particle Analysis VI, I can get the number of particles detected and also a 2D Array of requested measurements of the particles. From there, I can easily exrtract the 'First Pixel X and Y' , 'Centre of Mass X and Y' ,'Area' and also the 'Perimeter' of the particles. But,I also want all the pixel coordinates inside each blob .
Can someone give me a hint or help me out how to extract all the coordinates of the blob?
Solved! Go to Solution.
02-06-2018 09:35 AM
Might not be the most high-performance solution, but when you have your binarized image, you could go through your image pixel by pixel and check if it's 1 or 0 and output the coordinate accordingly. You can remove all but 1 blob to get the coordinates for just 1 blob.
Also, to increase the performance of this function you could cut out the part of the image with the blob, and use the bounding rect +5 px or so to determine what needs to be cut.
Maybe there's a function that I don't know, though.
02-06-2018 11:11 AM
Look at the example and the code it calls I have attached here. I think this does what you are asking?
02-07-2018 03:24 AM
wrote:
Look at the example and the code it calls I have attached here. I think this does what you are asking?
Thank you. But, I am not able to open your VI since I am having an older version of LabVIEW 2014. It would be great if you can convert our VI into an older Version (preferable 14 or older) and sent me?
02-07-2018 03:24 AM
wrote:
Might not be the most high-performance solution, but when you have your binarized image, you could go through your image pixel by pixel and check if it's 1 or 0 and output the coordinate accordingly. You can remove all but 1 blob to get the coordinates for just 1 blob.
Also, to increase the performance of this function you could cut out the part of the image with the blob, and use the bounding rect +5 px or so to determine what needs to be cut.
Maybe there's a function that I don't know, though.
Thanks for the information. I will look into it.
02-08-2018 11:24 AM
This should be compiled in 2014 I think.
02-09-2018 04:52 AM
So, I finally got my LabVIEW back up and running and did a little example. It should give you all the Pixels, but you will need to check if the x- and y- coordinates are ok.
02-12-2018 05:24 AM - edited 02-12-2018 05:33 AM
wrote:
So, I finally got my LabVIEW back up and running and did a little example. It should give you all the Pixels, but you will need to check if the x- and y- coordinates are ok.
Yes, the x and y coordinates are fine. I would be grateful if you could explain what exactly the two inner for-loops are trying to accomplish. I meant if you could explain how the coordinates of a particle are read i.e how the coordinates are displayed in the 'coordinates array indicator'. Also, how the values of the input clusters in the 'unbundle by name' are added/considered. Thanks again.
02-12-2018 05:49 AM
Sure!
The basic idea is exactly what I described before: Enter all pixel coordinates into the array, that are 1 in the binarized image. Now, since you have 2 M pixels and probably around 30 images per second, performance optimization is a good idea and the best way to achieve it is by limiting the evaluated area in the image.
So, after you filtered twice by bounding rect coordinates you have an image with only one particle in it (not in 100% of cases, as there could be a smaller particle at the upper left corner of the larger rect, so you should probably filter by bounding rect right and bottom also). After filtering you cut out the image, get the pixels and pass them to the two for loops. In the two for loops, the index represents the coordinates of the pixels within that cutout. So 0,0 is the bottom left pixel in the cut out, but if the cutout itself isn't in the bottom left corner of the image you need to add the coordinate of the cutout to the local coordinates.
I didn't quite get the last part of your question. I don't use unbundle in my code.
In case you mean the values for range lower/upper: I have to filter by something to get rid of all the other particles before evaluating the image parts. Again, this isn't necessary if performance isn't an issue. Then you could just iterate through the entire image and the algorithm gets a lot simpler, since you don't need any filtering, image copies and basic math...
02-12-2018 07:32 AM - edited 02-12-2018 07:47 AM
wrote:
Sure!
The basic idea is exactly what I described before: Enter all pixel coordinates into the array, that are 1 in the binarized image. Now, since you have 2 M pixels and probably around 30 images per second, performance optimization is a good idea and the best way to achieve it is by limiting the evaluated area in the image.
So, after you filtered twice by bounding rect coordinates you have an image with only one particle in it (not in 100% of cases, as there could be a smaller particle at the upper left corner of the larger rect, so you should probably filter by bounding rect right and bottom also). After filtering you cut out the image, get the pixels and pass them to the two for loops. In the two for loops, the index represents the coordinates of the pixels within that cutout. So 0,0 is the bottom left pixel in the cut out, but if the cutout itself isn't in the bottom left corner of the image you need to add the coordinate of the cutout to the local coordinates.
I didn't quite get the last part of your question. I don't use unbundle in my code.
In case you mean the values for range lower/upper: I have to filter by something to get rid of all the other particles before evaluating the image parts. Again, this isn't necessary if performance isn't an issue. Then you could just iterate through the entire image and the algorithm gets a lot simpler, since you don't need any filtering, image copies and basic math...
Thanks for explaining it. Sorry, I meant the constant values of the input Clusters in 'Bundle by name'.
I still have confusion in what the other coordinates of the pixels within the cutout means (in the attached images). What exactly does it convey when N2=50 and N3=56?
PS: Please check the attached image of the front panel.