Path: news.mathworks.com!not-for-mail
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$1@newscl01ah.mathworks.com>
References: <g1bsct$ggh$1@fred.mathworks.com> <g1c6l2$b04$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1313528310 17317 172.30.248.38 (16 Aug 2011 20:58:30 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Aug 2011 20:58:30 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2486811
Xref: news.mathworks.com comp.soft-sys.matlab:740212

"Roger Stafford" wrote in message <g1c6l2$b04$1@fred.mathworks.com>...
> "elflord woods" <elflord.woods@gmail.com> wrote in message <g1bsct$ggh
> $1@fred.mathworks.com>...
> > 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?

Thanks,
Cody