LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak detection of a surface - laser spot tracking

Hi, I am trying to make a laser spot detector using Labview 8.2.  I am shining the laser on a CCD camera and getting the signal as an 800 x 600 array where the 8-bit integer data represents the intensity of the light that hits each pixel of the camera.  The laser spot moves slowly and I would like to track the position of the peak intensity (center of the spot) every second or so with as much precision as possible.  The shape of the laser spot is roughly a Gaussian surface.  

So far I’m using the Array Max function to get the coordinates of the maximum value (the signal can be a bit noisy), then read the row that corresponds to that maximum and use the Gaussian Peak Fit function to get the most precise peak X position.  I then repeat the same process with the column to get the most precise peak Y position.  This works relatively well, but it is not very efficient and I can get a bad peak position if I get the wrong maximum value from the Array Max function (for example, if the camera has a stuck high pixel that has nothing to do with the light intensity).  

I guess there must be a better way to achieve the same results and make sure that I don’t get bad peak position once in a while.  I checked the peak detection functions available in Labview 8.2, but I think that none can be used for finding the peak of a surface.  Any suggestion would be greatly appreciated.  Thanks.

0 Kudos
Message 1 of 32
(9,134 Views)
Hi, Sz0987,
 
There is an example in LabVIEW named "Fit gaussian sufface with offset.vi" which might help. Also how large is the laser spot? How many pixals will the laser spot cover? And how large is the noise?
If possible, would you please attach the result from the CCD camera, so I can learn more about the data.
 
Regards,
Michael
Message 2 of 32
(9,089 Views)
You could also add a filter to the image processing to minimize the noise.
Randall Pursley
Message 3 of 32
(9,087 Views)
Ok, here is a bitmap file of the laser spot that we have along with a horizontal cross section.  The size varies between 100 and 300 pixels.  The noise isn't that bad, but as you can see there are small fluctuations that might be higher than the amplitude at the center of the spot.  Therefore, it's not such a good idea to use the maximum value to track the center of the spot.  It would be probably much better to make a fit and get the center of that fit.  Thanks.
0 Kudos
Message 4 of 32
(9,070 Views)
Hi Sz0987,

An understanding of image processing and object detection/recognition would definitely be beneficial for this problem.  Unfortunately, my knowledge in this area is very limited!

However, I was able to adapt your original solution to provide a quick and accurate center location, even with noise present.  What I did was to look only at the red (RGB) values of the pixels in the image.  I applied a uniform 3x3 blur filter using the convolution VI (simple, but effective in getting rid of point noise.  You could play around with other sizes, weightings, or types of filters).  I then went through each row and found the max, then fit a Gaussian curve through these values to find the Y coordinate.  Similarly, the maximum values in each column were used to find the X coordinate.  This implementation is different than your procedure of finding the absolute max and then using a curve to find the max in that row and column.  I also experimented with fitting a Gaussian curve through each row and column, then fitting another curve based on the center values of the curves.  This worked better than just using the max in each row, but slowed the program down a LOT.

I have attached the VI I created (saved in 8.0) and the pictures I used for testing.  I hope this helps!

Edit: My example uses VIs from NI-IMAQ to open the file and convert it to an array.  You can downlad NI-IMAQ from NI's website:
http://joule.ni.com/nidu/cds/view/p/id/758/lang/en

Regards,


Message Edited by Devin_K on 12-28-2007 03:36 PM
Download All
Message 5 of 32
(9,032 Views)
Thanks Devin for the vi.  In fact, the picture that was attached came directly from Labview and the colors came from the intensity chart.  It is monochromatic, so I guess I can skip the RGB part.  I'll play around with the blur filter and I'll let you know if I come across other problems.  Thanks.
0 Kudos
Message 6 of 32
(8,967 Views)
Sz0987,

You're very welcome.  Looking back at the VI, I noticed it could be simplified a bit further.  I didn't realize that you can actually set the output size of the convolution VI to be the size of the X input, so the array resizing I did after the convolution was unneccessary.  This simplifies things in case you were planning on trying different filter sizes, since you won't have to worry resizing the output to manually getting rid of the outside pixels.

I've attached an updated version of the VI.  I didn't bother making the monochrome change you mentioned, but you should easily be able to adapt this so that it works in your actual VI.


Message Edited by Devin_K on 01-04-2008 02:27 PM
Message 7 of 32
(8,956 Views)
You may want to try using a more conventional approach:
 
Use an automatic threshold function like IMAQ AutoBThreshold 2 to find a good threshold value.
 
Generate an image mask using this threshold value; you could use IMAQ Threshold for this purpose.
 
Find the pixel value weighted centroid of the non-masked portion of the image; you can use IMAQ Centroid for this.
 
as long as the threshold is calculated properly, the energy weighted centroid of the non-masked portion of the image should give you the center coordinates of the beam, even with a non-symmetric beam distribution.

global variables make robots angry


0 Kudos
Message 8 of 32
(8,939 Views)
Root Canal,
Those are also good suggestions, but require the NI Vision Development Module.  Based on Sz0987's original approach, I assumed (perhaps incorrectly?) that he did not have access to NI's image processing functions.  The examples I posted only use VI's included free with the NI-IMAQ driver.

Sz0987:
If you do have access to this module, there are likely easier and more efficient ways of doing what you are asking, as Root Canal suggests.  I personally do not have experience using that module, but I'm sure there are other members here that can help you.  Let us know and we'll do what we can!
Message 9 of 32
(8,905 Views)
No, I don't have access to that module, so I'll try the IMAQ method first.  The results that I have so far seem fine, but I'll have to test several samples before I can tell if this is the best approach.  Thanks again. 


0 Kudos
Message 10 of 32
(8,871 Views)