comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Gauss2DFit question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Gauss2DFit question [message #19931] Tue, 09 May 2000 00:00
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
I'm trying to use the library routine GAUSS2DFIT to fit some smooth,
blobby functions. My experience so far has been ... ah ... suboptimal.
It does not converge quickly or well.

Example (modified from the example in the manual):

PRO TEST_GAUSS2D

nx = 128 ;x-dimension of array
ny = 100 ;y-dimension of array
x = FINDGEN(nx) ;Create x-coordinates
y = FINDGEN(ny) ;Create y-coordinates
xx = x # REPLICATE(1.0, ny) ;Create 2-D x-coordinates
yy = REPLICATE(1.0, nx) # y ;Create 2-D y-coordinates

; Offs Scale X width Y width X cen Y cen Rotation
; A0 A1 a b h k tilt
a = [5.0, 10.0, nx/6.0, ny/10.0, nx/2.0, 0.6*ny, !PI/4.0] ;Parameters

xr = (xx - a[4])*COS(a[6]) - (yy - a[4])*SIN(a[6]) ;Rotate x
yr = (xx - a[4])*SIN(a[6]) + (yy - a[4])*COS(a[6]) ;Rotate y
z = a[0] + a[1]*EXP(-((xr/a[2])^2 + (yr/a[3])^2)/2) ;Compute gaussian
z = z + RANDOMN(seed, nx, ny) ;Add random noise
yfit = GAUSS2DFIT(z, b, /TILT) ;Fit the function

PRINT,'Should be:', STRING(a, FORMAT='(6f10.4)')
PRINT,'Is: :', STRING(b, FORMAT='(6f10.4)')

!P.MULTI = [0, 2, 1, 0, 0]
CONTOUR, z, x, y
CONTOUR, yfit, x, y

END

Including the noise (RANDOMN line) produces unpredictable bad results.
Commenting that line out produces reproduceable bad results.

Does anyone have a more robust routine for fitting a 2-D Gaussian (with
rotation)?

Thanks, Ken
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Gauss2DFit question
Next Topic: Re: Objects and Widgets

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:12:03 PDT 2025

Total time taken to generate the page: 0.00714 seconds