LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loop

  • this is my problem :


I have 4 circles, I detect their edges, then I find the best circle and I want in output the center, the radius, the area and the perimeter for each circle.

My program works but just for the first circle.

 

I found a VI named IMAQ Count Objects 2. (in Red on the image)
I tried to do a For loop and put "number of object" into it but I didn't succeed.
How can I have the same parameters for circle 2, circle 3 and circle 4 ?


  • My second problem is circle in green on the image. I want my original image AND my edge detection on the same image. What I've done works, but the original image winks. I just want to superimpose the two images.


thanks a lot !

 

Sans titre.png

0 Kudos
Message 1 of 3
(2,264 Views)

Hi,

 

Can you put up the .png file you are using to test your code?

 

I haven't used the edge detection but I'm assuming the output is the edges on a tranparent background. If so the IMAQ ImageToImage 2 will let you copy the edges onto your original image. Alternatively (when you've detected your circles using the fitting algorithm) you can use the co-ordinates of the circles to overlay a circle on your original image (IMAQ Overlay Oval). If you want ot save this image make sure you use 'Merge Overlays' before saving because otherwise you will just save the original image.

 

For your circle detection the Circle Fit is only picking up one of the cirlces because 'This VI requires a minimum of three points. The resulting circle may take into account only a subset of the points you provide.'. So the first circle (in this case) is probably the best one! However to be sure you should divide your image into 4 sub images and process them individually.

 

Probably the easiest thing to use is the 'count objects' vi you found. Feed in your edges and with the correct settings (pixel value)  this will give you out an array (called Objects - this is what you feed into a 'for loop') with one item in the array for each object. The 'bounding box' item in each array element will give you co-ordinates of each circle. Use a vi (IMAQ Extract I think...I haven't worked with images in ages) to pull out each sub image and then detect the circles using circle fit.

 

You could also write a simple search algorithm to detect where each circle starts and finishes as an alternative to 'count object' if you want. And of course if your grid isn't changing and you need a quick solution you could hard-code the space between the images - not recommended of course!

 

There is probably a much easier way to do this but (as I said) I haven't worked with IMAQ in ages. If you still struggle put up the png and I'll have another look.

 

Good luck,

DeltaJ 

0 Kudos
Message 2 of 3
(2,207 Views)

One other little thing - in your code in the stacked sequence structure your image reference wire is not wired correctly! In this case (because its a reference) it makes no difference but if the wire was carrying data (a string or a number for example) your results would appear as if 'case 0' didn't exist! Just a small thing to watch out for!

0 Kudos
Message 3 of 3
(2,203 Views)