LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fit Double Gaussian to a 2D array

Hi,

Is there a way to fit my 2D array data with a Double Gaussian, instead of Gaussian peak fit, I have two peaks.  Is there a function available?  If not, how can I achieve it?  

What I really need to do is to fit an image with two separate gaussian distributed bright spots to find the center coordinates of these two spots using double gaussian.  I guess the easiest way is to convert it to an array and then fit using double gaussian.

 

Thank you very much!!!

 

Best,

Charles

0 Kudos
Message 1 of 20
(5,313 Views)

Are the 2D gaussians symmetric or elliptic? Can you show us some typical data?

 

Are you looking for something similar to this (scroll down for the latest version). except with two peaks? You could probably re-use most of the code, simply add a second peak and correspondingly more parameters .

 

Message 2 of 20
(5,311 Views)

I think they are symmetric (or at least they are supposed to be, even though from the image it's a little elliptical maybe due to slight out of focus).  Can I attach an array here? 

0 Kudos
Message 3 of 20
(5,309 Views)

@soljiang wrote:

Can I attach an array here? 


Out of focus does no make them elliptical. If they are, you have a tilt or some other anisotropy. Is the main axis aligned with X or Y or can the tilt angle be random.

 

Create a small VI containing your data in an array control or intensity graph. Make current values default, then save and attach the VI here.

0 Kudos
Message 4 of 20
(5,306 Views)

Untitled.png  My image looks like this.

0 Kudos
Message 5 of 20
(5,301 Views)

All I want to do is to find the centroids of the two bright spots.

0 Kudos
Message 6 of 20
(5,299 Views)

They look pretty symmetric and even seem to have about the same amplitude and width. Is that a valid assumption?

 

The background seems curved and dips below the average plane around the peaks. You might need a more complicated model, though.

 

Start with this and simply add a second 2D gaussian. For the starting estimate of the xy positions, I would initially use manual cursors

Message 7 of 20
(5,295 Views)

Hi, Altenbach,

I have a new question.  How to use your 2D Gussian with Rotation?  I have an image that looks very similar to your simulated elliptial spot with an angle.  I modified your code so that I have a single input as a 2D array converted from image.  I haven't been able to get it to work.  It detects the maximum and its position as first guess correctly but I can't get a gaussian back.  Could you enlighten me more on your code?  Also what are six 50 used for?  Thank you very much!

 

Best,

Charles

0 Kudos
Message 8 of 20
(5,199 Views)

Would the image with an off work?  I think my image has background but I don't know if that's what causes the problem.  

0 Kudos
Message 9 of 20
(5,195 Views)

If you have a background, you need to fit with an offset, of course.

 

You need parameter guesses, one or each parameter. some are 50, so I start out with an array of all 50s and replace the others to generate the set of guesses. If your peak is shaped very differently, you might want to modify these numbers.

 

If you have problems, please attach your data and your code.  A picture of my code does not help identify what you are doing wrong. 😄 

0 Kudos
Message 10 of 20
(5,185 Views)