Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

i want to know the best way to detect two cross hair in image and how can i check if there are identical using labview

hello everybody ,

 

I want to know the best way to detect two cross hair in image and how can i check if there are identical using labview .you will find below an image as an example 

could you advise me with examples and tutorials

cross-hair.jpg

thank you 

0 Kudos
Message 1 of 11
(8,979 Views)

What you're asking about is definitely possible. I would recommend checking out the examples in LabVIEW, which you can find in LabVIEW by going to Help>>Find Examples...>>Browse>>Toolkits and Modules>>Vision

 

For you specifically, I would look at Pattern Matching.

Tanner B.
Systems R&D Engineer - Aerospace, Defense, and Government
National Instruments
0 Kudos
Message 2 of 11
(8,962 Views)

Looks like a collimator output 🙂 ?

 

From my experience, you can either use correlation based algorithms (and yes, that is Pattern Matching, which is nothing but normalized cross-correlation), or go the Particle Analysis route. These algorithms are simple to implement, but as usually the crosshairs can scale or be rotated, unessessarily slow. Sometimes, Geometric Shape Matching can be better, but I go the Particle Analysis route.

 

First of all, get more sample images. You need a series of them, like 10-20, try taking them with different environment conditions (intensity should vary).

 

What I usually do, is use Vision Assistant. In your case, I turn the image into something grayscale and apply a little lookup and a filter to get rid of the worst noise. At this point you could also do a flatfield correction (if only because I'm delighted at the newest addition to Vision 2015 :), but it's not really necessary).

 

Your image will look like this

smooth.png

Next step will be the crucial: Turn in into something binary. It is the key idea, and I'm using a local threshold called Niblack. It's pretty decent at segmenting things like that.

 

niblack.png

There is a lot of random stuff around, floating, but the good thing it is nicely separated and it looks quite different from what the rest is. What I'm oding now is applying a few closing operations. They will not affect the crosshairs too much, but they do turn the random background noise into more or less one big blob that can be easily removed.

closing.png

OK, now time for particle filtering. This is a bit tricky to get right. First, I remove everything with a very big area, then I remove everything with a too small area. I assume if you have different sample pictures, you will have to adjust this accordingly, maybe add some type factor or elongation factor or something like that into the image.

filter.png

Nicer, eh? Now all you have to do is use Particle Analysis. I use center of mass, area, and orientation. 
If I get 1 particle, nice. That means we are overlapping or almost overlapping. I calculate the center of my cross, and probe the original image around two search circle. From this information I can deduce exactly what is missing.

If I get more particles, I use the area to identify which is my main cross and proceed by either analysing the other particles, or again, search cycles.

 

The last part of the algorithm is a bit vague due to the lack of sample pictures. But I think you could get started this way 🙂

Message 3 of 11
(8,952 Views)

You could simply extract the green color plane prior to any processing in order to enhance the contrast of your cross(es).

Thresholding should then be even more reliable.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 4 of 11
(8,933 Views)

thank you Tanner for your response i will try your suggestion 

0 Kudos
Message 5 of 11
(8,926 Views)

thank you b.ploetzenede for your response ,it contains a lot of information that was new for me.

i have tried your suggestion but i am struggling with last step of the algorithm i do not know how to detect the overlapping between two cross hair
you will find attach my attempt and i am really grateful for your help 

0 Kudos
Message 6 of 11
(8,924 Views)

thank you Klemen for your response , would you please advise me with the steps after applying Thresholding in image

0 Kudos
Message 7 of 11
(8,923 Views)

Hello,

after thresholding only the cross, one possible way is:

1.) Use particle analysis to get max feret diameter and max feret orientation,
2.) Rotate the image by the feret orientation angle, so the longer cross is in horizonzal position,
3.) Calculate cross x center of mass and move it to the image center,
4.) Remove the left and the right part of the image along the vertical line. The idea is to shorten the longest line of the cross, so it is shorter than the other. You can base this on the calculated feret diameter,
5.) Use particle analysis to get the max feret diameter again, this time for the other cross,
6.) Compare the diameters.

Did you want to compare any other characteristics than lenght?

 

Also, try other threshold methods. Clustering for example produces better results in your case. You showed only one image though...

 



Hope this helps.
Best regards,
K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 8 of 11
(8,908 Views)

I think these images come from a collimator, so they are typically differently scaled (which makes no difference) and the question is whether they overlap and how to get there. The problem is trivial if you are far away from overlapping (as in the sample image), it gets a bit more tricky when they are almost overlapping because you can't distinguish no matter what threshold you use. The second cross actually comes from a mirror reflection of the first one, so it has exactly the same shape. The shape should be known and regular. 

But this is assuming we're talking about a collimator.

 

Without further sample images, it doesn't really make sense to further advise on that.

0 Kudos
Message 9 of 11
(8,900 Views)

thank you Klemen for your suggestion ,  i will try it .

0 Kudos
Message 10 of 11
(8,881 Views)