LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please help this poor girl with a Gaussian fit

Hello everybody,

It's my first time here, I'm pretty new at using Labview and English is my second language so I hope you guys don't judge me too much xD.


My professor wants to make a program that analyses a laser beam in real time using a USB camera. We've developed the following program (that uses the "Image Processing" library and recquires a USB camera). This program shows the line profile on the left, and what my professor wants is to adjust that profile with a Gaussian fit. I have no clue about how I can do that.


I came here because I've searched a lot and everything seemed so advanced. Maybe my case is simpler, or not, but in anyway I need help 😕

 

Thanks in advance,
Luiza

PS: I'm not with the laser right now so I can't take a print screen of the program running, but when you get the image of the laser beam with this program you get a pattern in the line profile that looks pretty much like a gaussian curve, that's why we need the fit!

0 Kudos
Message 1 of 12
(4,034 Views)

Press CTRL + Space on your keyboard and type in Gaussian.  See if one of those VIs does what you need.  Not sure what a Gaussian Fit is so i am only guessing. Smiley Wink

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 12
(4,023 Views)

Hi!

 

http://zone.ni.com/reference/en-XX/help/371361H-01/gmath/gaussian_peak_fit/

 

This VI should be enough, but you should define initial guess parameters, therefore you need to extract that information from your line profile waveform. If you have sound and vibration toolkit, there's peak search function, that will help you get initial peak amplitude, and its position position, also there's standard deriviation VI that you can use. There is also peak detector in standard package (correct me if I'm wrong). 

 

So there're many ways to accomplish your goal - you just need to take some time and play with it. 

If you'll have any problems - feel free to ask!

 

PS: Dont do the print screen of the results of your measurements - it's better to save the values of function, so you can use it outside the lab;)

Message 3 of 12
(4,010 Views)

Well, since you are dealing with a picture, I assume that you have a 2D gaussian peak. Is it guaranteed to be symmetric or can it also be elongated, (e.g. if the laser hits the target at an angle).

 

If you just want to analyze a line profile, a 1D Gaussian fit is sufficient. There are plenty of examples in the forum here. But why not fit the 2D beam instead?

 

Maybe this long thread can give you some ideas on where to start.

 

 

The VI you have attached is pretty useless. Do you have a typical image of the beam profile instead?

Message 4 of 12
(4,003 Views)

Thanks everybody for the attention! Smiley Very Happy

 

I've seen these examples that you showed before, what I really don't know is which information to extract from my line profile to put in the gaussian peak fit vi and how to do it (in other words: everything hahah Smiley Embarassed ).

 

What I mean is, the line profile gives me the coordinates of a "global rectangle" and gives me the informations of the line like the maximum value of the pixel found in the line, the minimum, etc. But is this enough or useful for the gaussian vi? Because analyzing the math involved, it seems like totally different stuff.

 

I'm probably sounding like a dumb door, I'm lost with this and math is not my strongest point 😛

 

Thank you guys again!!

0 Kudos
Message 5 of 12
(3,932 Views)

Update: I think I'm almost there. But I need help: I downloaded set of vi's that makes a gaussian fit (I'll try to attach it here), what i need to put are arrays for X and Y.

The thing is: As you can see, the line profile also has X and Y data, observe how it changes with my face and with the lenght of the line:

1.png

2.png

(yes I was having fun with myself haha)

X is the lenght of the line and Y is the pixel value. But I can't separate those to put them in the gaussian fit program that I downloaded! Is it possible? Please help me guys, I have little time to deliver this Smiley Sad

PS: I can't install other browser in the computer lab, hence the internet explorer 😛 


 

0 Kudos
Message 6 of 12
(3,887 Views)

You don't need any of the ancient VIs that use obsolete functions. Discard them!

 

For a fit to a gaussian curve along a line profile, all you need is to generate xy pairs where x is the position along the line and y is the image intensity. As a first step you should convert your picture to greyscale or monochrome to get a single intensity value per pixel.

 

For a horizontal or vertical line, all you need is to take a row or column using "index array", then trim it down to the region of interest using "array subset". x for fitting would be the array index. For an arbitrary line, you might want to use bilinear interpolation to get the intensities, because most won't be perfectly aligned with actual pixels.

 

EDIT: It seems you already have the line profile from your software. Simply trim it to the region of interest. X is the position along the x-axis and y is the intensity.

 

Then use the gaussian fit from the fitting palette. If there is significant offset, make sure to also fit to the offset by changing parameter bounds accordingly (By default, the offset is forced to be zero).

 

0 Kudos
Message 7 of 12
(3,879 Views)

Hi altenbach, thank you for the reply!

To which obsolete functions are you referring to? The ones of the gaussian fit? 

0 Kudos
Message 8 of 12
(3,821 Views)

Whatever was in the zip file you have attached is ancient. Ignore it!

LabVIEW now has a Gaussian fitter here that you can use out-of-the-box.

 

(As I said, make sure you change the parameter bounds if your data has an non-zero offset.)

0 Kudos
Message 9 of 12
(3,814 Views)

I think I did it, the problem is: The program is so, so, so slow ! Smiley Frustrated
Here is what I did: I searched a bit more about the line profine vi and I got to this amazing vi that "splits" in X and Y like I needed to: (I dont know how it does it exaclty, like I said I'm new with labview 😞 )
https://decibel.ni.com/content/docs/DOC-20840

 

then I put that vi with what i had and voilà:
Sem título2.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 10 of 12
(3,805 Views)