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

Home » Public Forums » archive » Regarding the Fit_Ellipse Program
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Regarding the Fit_Ellipse Program [message #59006 is a reply to message #58903] Thu, 28 February 2008 08:53 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
plim.dream...@gmail.com wrote:
>> I don't think this is the right approach to the problem.
>> What I would do is to get a regularly gridded array
>> for rho first (for instance with trigrid, but there may
>> be other possibilities).
>> Once you have that, it is easy to produce an input array
>> suitable for fit_ellipse (just set all points higher (or lower)
>> than a threshold to 0, and the others to 1).
>>
>> Try something like:
>>
>> TRIANGULATE, x, y, Triangles
>> Result = TRIGRID( x,y,rho, Triangles,[dx,dy],[minx,miny,maxx,maxy]] )
>>
>> where dx and dy is the spacing of the regular grid and minx etc. are
>> the boundaries.
>>
>> Cheers,
>> Paolo>
>
> Hi Paolo,
> I understand that it would be simpler to use a regular gridded array
> but that is changing the whole situation.
> Part of the study I am doing is based on the fact that it isn't a
> regular gridded array with defined spacings dx and dy.

Exactly, so I was suggesting you *transform* your irregularly gridded
data into a regular grid (which is probably what contour is doing
behind
the curtains anyway, only is a bit harder to know and control what
contour is doing)!
Try this code:

np=1000
;creates irregular grid
x=randomu(seed,np)*4-2
y=randomu(seed,np)*4-2

;creates some mock data
a=2
b=3
z=1-sqrt((x/a)^2+(y/b)^2)
z=z+randomn(seed,np)*z*0.1

;this is the data the way contour sees it
contour,z,x,y,/irregular,/iso,levels=findgen(11)/10.*1.15
oplot,x,y,psym=6

;put the data into a regular grid
TRIANGULATE, X, Y, Triangles
Result = TRIGRID( X, Y, Z, Triangles,[0.01,0.01],[-3.,-3,3,3] )

;show regularly gridded data
loadct,5
tvscl,result

;fit ellipse to points above 0.5
ind=where(result GT 0.5)
ell=result*0
ell[ind]=1
data=fit_ellipse(ind,xsize=602,ysize=602)

;show data & best-fit ellipse
tvscl,ell
plots,data[0,*],data[1,*],color=128,/device,thick=2

I think this pretty much does what you want, right?

Paolo


> It seems we are straying from the problem which would be to fit an
> ellipse to a contour and obtain its parameters given the x and y
> positions of the contour. I'm getting amazed at how hard it is to fit
> an ellipse to it!
> I certainly don't understand why there isn't a fit_ellipse program
> that works with the x,y array of the contour vertices instead of the
> pixel indices of the image of a contour (I wish I knew how to make one
> myself).
> B
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Histogram: Normalised Occurrence Frequency
Next Topic: google summer of code 2008

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

Current Time: Fri Oct 10 15:22:52 PDT 2025

Total time taken to generate the page: 1.35870 seconds