11-24-2012 03:26 PM
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
11-24-2012 03:34 PM - edited 11-24-2012 03:41 PM
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 .
11-24-2012 03:37 PM
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?
11-24-2012 03:43 PM - edited 11-24-2012 03:44 PM
@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.
11-24-2012 03:48 PM
My image looks like this.
11-24-2012 03:51 PM
All I want to do is to find the centroids of the two bright spots.
11-24-2012 04:03 PM - edited 11-24-2012 04:05 PM
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
01-17-2013 11:37 AM
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
01-17-2013 11:40 AM
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.
01-17-2013 02:26 PM
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. 😄