From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to find pixels inside ellipse ?
Date: Tue, 16 Aug 2011 20:58:30 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <j2ellm$gt5$>
References: <g1bsct$ggh$> <g1c6l2$b04$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1313528310 17317 (16 Aug 2011 20:58:30 GMT)
NNTP-Posting-Date: Tue, 16 Aug 2011 20:58:30 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2486811
Xref: comp.soft-sys.matlab:740212

"Roger Stafford" wrote in message <g1c6l2$b04$>...
> "elflord woods" <> wrote in message <g1bsct$ggh
> $>...
> > hi all
> > 
> > I have an ellipse region in an image and i know the size of
> > the ellipse axes and its orientation
> > 
> > how can i extract all the pixels inside this ellipse region .
> > 
> > thanks
> ------------------
>   I assume you also know the location of the ellipse's center.  Call that (x0,y0).  
> Let t be the counterclockwise angle the major axis makes with respect to the 
> x-axis.  Let a and b be the semi-major and semi-minor axes, respectively.  If 
> P = (x,y) is an arbitrary point then do this:
>  X = (x-x0)*cos(t)+(y-y0)*sin(t); % Translate and rotate coords.
>  Y = -(x-x0)*sin(t)+(y-y0)*cos(t); % to align with ellipse
> If
>  X^2/a^2+Y^2/b^2
> is less than 1, the point P lies inside the ellipse.  If it equals 1, it is right on 
> the ellipse.  If it is greater than 1, P is outside.
> Roger Stafford

I was curious how to do this with lat lon points. I have data describing a rotated ellipse (the center of the ellipse in lat lon coordinates, the lengths of the major and minor axes in kilometers, and the angle that the ellipse is oriented). I do not know the location of the foci, but assume there is a way to figure them out somehow. How can I determine if a specific lat lon point is within this ellipse?