Gaussian along an ellipse
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Best way to describe what I mean is with an example; I know how to generate a "Gaussian along a line":
$$e^-h_2^2((x-h_5)cos(h_3)+(y-h_6)sin(h_3)).^2$$
Some example matlab code:
h1 = 0.025;
h2 = 0.5;
h3 = pi/16;
h4 = pi/2.25;
h5 = 50;
h6 = 60;
[y,x] = ndgrid(1:120,1:120);
figure;
imshow(exp(-h2^2*((x-h5).*cos(h3)+(y-h6).*sin(h3)).^2),)
This is a "Gaussian along a line". How would I go about doing the same thing, but for an ellipse instead? Preferably where the function is equal to 1 along the ellipse boundary like it is for this equation of the line:
$$(x-h_5)cos(h_3)+(y-h_6)sin(h_3)$$
and also has a parameter like $h_2$ where I can control the spread (i.e. variance).
EDIT:
When using:
h = 30;
k = 40;
a = 5;
b = 6;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
h = 30;
k = 40;
a = 25;
b = 30;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
Even though $h_2$ is the same the variance seems to increase:
probability geometry statistics
add a comment |Â
up vote
1
down vote
favorite
Best way to describe what I mean is with an example; I know how to generate a "Gaussian along a line":
$$e^-h_2^2((x-h_5)cos(h_3)+(y-h_6)sin(h_3)).^2$$
Some example matlab code:
h1 = 0.025;
h2 = 0.5;
h3 = pi/16;
h4 = pi/2.25;
h5 = 50;
h6 = 60;
[y,x] = ndgrid(1:120,1:120);
figure;
imshow(exp(-h2^2*((x-h5).*cos(h3)+(y-h6).*sin(h3)).^2),)
This is a "Gaussian along a line". How would I go about doing the same thing, but for an ellipse instead? Preferably where the function is equal to 1 along the ellipse boundary like it is for this equation of the line:
$$(x-h_5)cos(h_3)+(y-h_6)sin(h_3)$$
and also has a parameter like $h_2$ where I can control the spread (i.e. variance).
EDIT:
When using:
h = 30;
k = 40;
a = 5;
b = 6;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
h = 30;
k = 40;
a = 25;
b = 30;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
Even though $h_2$ is the same the variance seems to increase:
probability geometry statistics
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Best way to describe what I mean is with an example; I know how to generate a "Gaussian along a line":
$$e^-h_2^2((x-h_5)cos(h_3)+(y-h_6)sin(h_3)).^2$$
Some example matlab code:
h1 = 0.025;
h2 = 0.5;
h3 = pi/16;
h4 = pi/2.25;
h5 = 50;
h6 = 60;
[y,x] = ndgrid(1:120,1:120);
figure;
imshow(exp(-h2^2*((x-h5).*cos(h3)+(y-h6).*sin(h3)).^2),)
This is a "Gaussian along a line". How would I go about doing the same thing, but for an ellipse instead? Preferably where the function is equal to 1 along the ellipse boundary like it is for this equation of the line:
$$(x-h_5)cos(h_3)+(y-h_6)sin(h_3)$$
and also has a parameter like $h_2$ where I can control the spread (i.e. variance).
EDIT:
When using:
h = 30;
k = 40;
a = 5;
b = 6;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
h = 30;
k = 40;
a = 25;
b = 30;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
Even though $h_2$ is the same the variance seems to increase:
probability geometry statistics
Best way to describe what I mean is with an example; I know how to generate a "Gaussian along a line":
$$e^-h_2^2((x-h_5)cos(h_3)+(y-h_6)sin(h_3)).^2$$
Some example matlab code:
h1 = 0.025;
h2 = 0.5;
h3 = pi/16;
h4 = pi/2.25;
h5 = 50;
h6 = 60;
[y,x] = ndgrid(1:120,1:120);
figure;
imshow(exp(-h2^2*((x-h5).*cos(h3)+(y-h6).*sin(h3)).^2),)
This is a "Gaussian along a line". How would I go about doing the same thing, but for an ellipse instead? Preferably where the function is equal to 1 along the ellipse boundary like it is for this equation of the line:
$$(x-h_5)cos(h_3)+(y-h_6)sin(h_3)$$
and also has a parameter like $h_2$ where I can control the spread (i.e. variance).
EDIT:
When using:
h = 30;
k = 40;
a = 5;
b = 6;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
h = 30;
k = 40;
a = 25;
b = 30;
h2 = 4;
figure;
imshow(exp(-h2^2*( (x-h).^2/a^2 + (y-k).^2/b^2 - 1).^2),)
Even though $h_2$ is the same the variance seems to increase:
probability geometry statistics
edited Jul 30 at 1:10
Michael Hardy
204k23186461
204k23186461
asked Jul 26 at 15:41
Justin
1351112
1351112
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
The trick is to build a function that cancels along the curve and is nonzero elsewhere.
In the case of a line,
$$f(x,y)=ax+by+c$$ is a perfect candidate.
For an axis aligned, centered ellipse,
$$f(x,y)=fracx^2a^2+fracy^2b^2-1.$$
In both cases, the Gaussian takes the form
$$e^-h^2f^2(x,y)$$ giving, for the ellipse
$$e^-h^2left(fracx^2a^2+fracy^2b^2-1right)^2.$$
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
 |Â
show 1 more comment
up vote
1
down vote
One thing you can try is the following- let $C=C(s)$ be a curve defined for $sin I$, so maybe a line, or a curve like $y=x^2$ or an ellipse. Then define for $mathbf x = (x,y)$,
$$ f_C(mathbf x) = e^mathbf x - C(s)$$
The quantity $inf_sin I |mathbf x - C(s)|$ is the shortest distance to the curve $C$.
In the case $C$ is a line, this should be the same as yours after some redefining of constants, as the shortest distance to a line is obtained by dropping a perpendicular, and hence you will see the intensity die out as you move out perpendicularly from the line, with the exponential decay matching the 1D Gaussian with variance $sigma^2$.
The function $g(s) := |mathbf x - C(s)|^2$ is differentiable if $C$ is, with derivative
$$g'(s) = 2(mathbf x - C(s))cdot C'(s)$$
so the infimum is at a point $C_* = C(s_*)$ where the tangent of the curve is perpendicular to the line joining $mathbf x$ and $C_*$, or in other words, $mathbf x-C_*$ needs to be parallel to the normal vector of the curve. This is a nice picture, but I don't know how it translates into code.
In the case of an ellipse, say of the form
$$C(s) = (a cos s, b sin s), s in [0,2ÃÂ)$$
Then $C'(s) = (-a sin s, bcos s)$, and the equation to solve is
$$0 = (mathbf x - C(s))cdot C'(s) = -a(x-acos s)sin s + b(y-bsin s)cos s$$
I don't see this having an easy-to-write-down solution. You'll also need to check that the second derivative is positive, and then choose the smallest value of $g(s)$ out of all the minimum points.
On a quick google, I found the following document https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf which seems to go into detail for computing such closest points on an ellipse.
In the case of a circle of radius $R$, its not so hard. Recenter so that the circle $C$ is entered at the origin, and write $mathbf x = r mathbf u$ where $mathbf u $ is a unit vector, and $r=r(mathbf x) = |mathbf x|$ is the distance of $mathbf x$ to 0. Then
$$f_C(mathbf x) = e^^2 / 2sigma^2$$
For an arbitrarily located circle $ = R$, you just need to use $r(mathbf x) = |mathbf x - mathbf x_0|$ instead. If $mathbf x_0 = (x_0,y_0)$, then we arrive at
$$f_C(x,y) = expleft(frac-left2sigma^2 right)$$
Naively substituting the circle formula $|mathbf x - mathbf x_0| = R$ with the similar formula for the ellipse $|mathbf x - mathbf x_0| + |mathbf x - mathbf x_1| = R$ ,
$$f_C(mathbf x) = expleft(frac^22sigma^2right) ?$$
gives you something that looks reasonable, but you can see that the level sets are not perfect. Regardless, the spread of the variance doesn't depend on how big the ellipse is.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The trick is to build a function that cancels along the curve and is nonzero elsewhere.
In the case of a line,
$$f(x,y)=ax+by+c$$ is a perfect candidate.
For an axis aligned, centered ellipse,
$$f(x,y)=fracx^2a^2+fracy^2b^2-1.$$
In both cases, the Gaussian takes the form
$$e^-h^2f^2(x,y)$$ giving, for the ellipse
$$e^-h^2left(fracx^2a^2+fracy^2b^2-1right)^2.$$
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
 |Â
show 1 more comment
up vote
1
down vote
The trick is to build a function that cancels along the curve and is nonzero elsewhere.
In the case of a line,
$$f(x,y)=ax+by+c$$ is a perfect candidate.
For an axis aligned, centered ellipse,
$$f(x,y)=fracx^2a^2+fracy^2b^2-1.$$
In both cases, the Gaussian takes the form
$$e^-h^2f^2(x,y)$$ giving, for the ellipse
$$e^-h^2left(fracx^2a^2+fracy^2b^2-1right)^2.$$
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
 |Â
show 1 more comment
up vote
1
down vote
up vote
1
down vote
The trick is to build a function that cancels along the curve and is nonzero elsewhere.
In the case of a line,
$$f(x,y)=ax+by+c$$ is a perfect candidate.
For an axis aligned, centered ellipse,
$$f(x,y)=fracx^2a^2+fracy^2b^2-1.$$
In both cases, the Gaussian takes the form
$$e^-h^2f^2(x,y)$$ giving, for the ellipse
$$e^-h^2left(fracx^2a^2+fracy^2b^2-1right)^2.$$
The trick is to build a function that cancels along the curve and is nonzero elsewhere.
In the case of a line,
$$f(x,y)=ax+by+c$$ is a perfect candidate.
For an axis aligned, centered ellipse,
$$f(x,y)=fracx^2a^2+fracy^2b^2-1.$$
In both cases, the Gaussian takes the form
$$e^-h^2f^2(x,y)$$ giving, for the ellipse
$$e^-h^2left(fracx^2a^2+fracy^2b^2-1right)^2.$$
answered Jul 26 at 15:55
Yves Daoust
110k665203
110k665203
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
 |Â
show 1 more comment
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The problem isn't precisely specified, but maybe you want $f$ to be linear to first order? eg for fixed $y$, your gaussian looks like $A exp (-B(x^2 - C)^2)$
â Calvin Khor
Jul 26 at 16:07
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
The variance seems to scale with $a$ and $b$. i.e. the white area is "thicker" when the major and minor axes are increased. Is there a way to make it constant even if these parameters are modified?
â Justin
Jul 26 at 16:09
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
Can you check my edits to see what I mean?
â Justin
Jul 26 at 16:12
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@Justin: yep, you must adjust $h$, and this simple approach won't ensure a constant thickness.
â Yves Daoust
Jul 26 at 16:27
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
@YvesDaoust Any tips for how I can ensure constant thickness?
â Justin
Jul 26 at 16:34
 |Â
show 1 more comment
up vote
1
down vote
One thing you can try is the following- let $C=C(s)$ be a curve defined for $sin I$, so maybe a line, or a curve like $y=x^2$ or an ellipse. Then define for $mathbf x = (x,y)$,
$$ f_C(mathbf x) = e^mathbf x - C(s)$$
The quantity $inf_sin I |mathbf x - C(s)|$ is the shortest distance to the curve $C$.
In the case $C$ is a line, this should be the same as yours after some redefining of constants, as the shortest distance to a line is obtained by dropping a perpendicular, and hence you will see the intensity die out as you move out perpendicularly from the line, with the exponential decay matching the 1D Gaussian with variance $sigma^2$.
The function $g(s) := |mathbf x - C(s)|^2$ is differentiable if $C$ is, with derivative
$$g'(s) = 2(mathbf x - C(s))cdot C'(s)$$
so the infimum is at a point $C_* = C(s_*)$ where the tangent of the curve is perpendicular to the line joining $mathbf x$ and $C_*$, or in other words, $mathbf x-C_*$ needs to be parallel to the normal vector of the curve. This is a nice picture, but I don't know how it translates into code.
In the case of an ellipse, say of the form
$$C(s) = (a cos s, b sin s), s in [0,2ÃÂ)$$
Then $C'(s) = (-a sin s, bcos s)$, and the equation to solve is
$$0 = (mathbf x - C(s))cdot C'(s) = -a(x-acos s)sin s + b(y-bsin s)cos s$$
I don't see this having an easy-to-write-down solution. You'll also need to check that the second derivative is positive, and then choose the smallest value of $g(s)$ out of all the minimum points.
On a quick google, I found the following document https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf which seems to go into detail for computing such closest points on an ellipse.
In the case of a circle of radius $R$, its not so hard. Recenter so that the circle $C$ is entered at the origin, and write $mathbf x = r mathbf u$ where $mathbf u $ is a unit vector, and $r=r(mathbf x) = |mathbf x|$ is the distance of $mathbf x$ to 0. Then
$$f_C(mathbf x) = e^^2 / 2sigma^2$$
For an arbitrarily located circle $ = R$, you just need to use $r(mathbf x) = |mathbf x - mathbf x_0|$ instead. If $mathbf x_0 = (x_0,y_0)$, then we arrive at
$$f_C(x,y) = expleft(frac-left2sigma^2 right)$$
Naively substituting the circle formula $|mathbf x - mathbf x_0| = R$ with the similar formula for the ellipse $|mathbf x - mathbf x_0| + |mathbf x - mathbf x_1| = R$ ,
$$f_C(mathbf x) = expleft(frac^22sigma^2right) ?$$
gives you something that looks reasonable, but you can see that the level sets are not perfect. Regardless, the spread of the variance doesn't depend on how big the ellipse is.
add a comment |Â
up vote
1
down vote
One thing you can try is the following- let $C=C(s)$ be a curve defined for $sin I$, so maybe a line, or a curve like $y=x^2$ or an ellipse. Then define for $mathbf x = (x,y)$,
$$ f_C(mathbf x) = e^mathbf x - C(s)$$
The quantity $inf_sin I |mathbf x - C(s)|$ is the shortest distance to the curve $C$.
In the case $C$ is a line, this should be the same as yours after some redefining of constants, as the shortest distance to a line is obtained by dropping a perpendicular, and hence you will see the intensity die out as you move out perpendicularly from the line, with the exponential decay matching the 1D Gaussian with variance $sigma^2$.
The function $g(s) := |mathbf x - C(s)|^2$ is differentiable if $C$ is, with derivative
$$g'(s) = 2(mathbf x - C(s))cdot C'(s)$$
so the infimum is at a point $C_* = C(s_*)$ where the tangent of the curve is perpendicular to the line joining $mathbf x$ and $C_*$, or in other words, $mathbf x-C_*$ needs to be parallel to the normal vector of the curve. This is a nice picture, but I don't know how it translates into code.
In the case of an ellipse, say of the form
$$C(s) = (a cos s, b sin s), s in [0,2ÃÂ)$$
Then $C'(s) = (-a sin s, bcos s)$, and the equation to solve is
$$0 = (mathbf x - C(s))cdot C'(s) = -a(x-acos s)sin s + b(y-bsin s)cos s$$
I don't see this having an easy-to-write-down solution. You'll also need to check that the second derivative is positive, and then choose the smallest value of $g(s)$ out of all the minimum points.
On a quick google, I found the following document https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf which seems to go into detail for computing such closest points on an ellipse.
In the case of a circle of radius $R$, its not so hard. Recenter so that the circle $C$ is entered at the origin, and write $mathbf x = r mathbf u$ where $mathbf u $ is a unit vector, and $r=r(mathbf x) = |mathbf x|$ is the distance of $mathbf x$ to 0. Then
$$f_C(mathbf x) = e^^2 / 2sigma^2$$
For an arbitrarily located circle $ = R$, you just need to use $r(mathbf x) = |mathbf x - mathbf x_0|$ instead. If $mathbf x_0 = (x_0,y_0)$, then we arrive at
$$f_C(x,y) = expleft(frac-left2sigma^2 right)$$
Naively substituting the circle formula $|mathbf x - mathbf x_0| = R$ with the similar formula for the ellipse $|mathbf x - mathbf x_0| + |mathbf x - mathbf x_1| = R$ ,
$$f_C(mathbf x) = expleft(frac^22sigma^2right) ?$$
gives you something that looks reasonable, but you can see that the level sets are not perfect. Regardless, the spread of the variance doesn't depend on how big the ellipse is.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
One thing you can try is the following- let $C=C(s)$ be a curve defined for $sin I$, so maybe a line, or a curve like $y=x^2$ or an ellipse. Then define for $mathbf x = (x,y)$,
$$ f_C(mathbf x) = e^mathbf x - C(s)$$
The quantity $inf_sin I |mathbf x - C(s)|$ is the shortest distance to the curve $C$.
In the case $C$ is a line, this should be the same as yours after some redefining of constants, as the shortest distance to a line is obtained by dropping a perpendicular, and hence you will see the intensity die out as you move out perpendicularly from the line, with the exponential decay matching the 1D Gaussian with variance $sigma^2$.
The function $g(s) := |mathbf x - C(s)|^2$ is differentiable if $C$ is, with derivative
$$g'(s) = 2(mathbf x - C(s))cdot C'(s)$$
so the infimum is at a point $C_* = C(s_*)$ where the tangent of the curve is perpendicular to the line joining $mathbf x$ and $C_*$, or in other words, $mathbf x-C_*$ needs to be parallel to the normal vector of the curve. This is a nice picture, but I don't know how it translates into code.
In the case of an ellipse, say of the form
$$C(s) = (a cos s, b sin s), s in [0,2ÃÂ)$$
Then $C'(s) = (-a sin s, bcos s)$, and the equation to solve is
$$0 = (mathbf x - C(s))cdot C'(s) = -a(x-acos s)sin s + b(y-bsin s)cos s$$
I don't see this having an easy-to-write-down solution. You'll also need to check that the second derivative is positive, and then choose the smallest value of $g(s)$ out of all the minimum points.
On a quick google, I found the following document https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf which seems to go into detail for computing such closest points on an ellipse.
In the case of a circle of radius $R$, its not so hard. Recenter so that the circle $C$ is entered at the origin, and write $mathbf x = r mathbf u$ where $mathbf u $ is a unit vector, and $r=r(mathbf x) = |mathbf x|$ is the distance of $mathbf x$ to 0. Then
$$f_C(mathbf x) = e^^2 / 2sigma^2$$
For an arbitrarily located circle $ = R$, you just need to use $r(mathbf x) = |mathbf x - mathbf x_0|$ instead. If $mathbf x_0 = (x_0,y_0)$, then we arrive at
$$f_C(x,y) = expleft(frac-left2sigma^2 right)$$
Naively substituting the circle formula $|mathbf x - mathbf x_0| = R$ with the similar formula for the ellipse $|mathbf x - mathbf x_0| + |mathbf x - mathbf x_1| = R$ ,
$$f_C(mathbf x) = expleft(frac^22sigma^2right) ?$$
gives you something that looks reasonable, but you can see that the level sets are not perfect. Regardless, the spread of the variance doesn't depend on how big the ellipse is.
One thing you can try is the following- let $C=C(s)$ be a curve defined for $sin I$, so maybe a line, or a curve like $y=x^2$ or an ellipse. Then define for $mathbf x = (x,y)$,
$$ f_C(mathbf x) = e^mathbf x - C(s)$$
The quantity $inf_sin I |mathbf x - C(s)|$ is the shortest distance to the curve $C$.
In the case $C$ is a line, this should be the same as yours after some redefining of constants, as the shortest distance to a line is obtained by dropping a perpendicular, and hence you will see the intensity die out as you move out perpendicularly from the line, with the exponential decay matching the 1D Gaussian with variance $sigma^2$.
The function $g(s) := |mathbf x - C(s)|^2$ is differentiable if $C$ is, with derivative
$$g'(s) = 2(mathbf x - C(s))cdot C'(s)$$
so the infimum is at a point $C_* = C(s_*)$ where the tangent of the curve is perpendicular to the line joining $mathbf x$ and $C_*$, or in other words, $mathbf x-C_*$ needs to be parallel to the normal vector of the curve. This is a nice picture, but I don't know how it translates into code.
In the case of an ellipse, say of the form
$$C(s) = (a cos s, b sin s), s in [0,2ÃÂ)$$
Then $C'(s) = (-a sin s, bcos s)$, and the equation to solve is
$$0 = (mathbf x - C(s))cdot C'(s) = -a(x-acos s)sin s + b(y-bsin s)cos s$$
I don't see this having an easy-to-write-down solution. You'll also need to check that the second derivative is positive, and then choose the smallest value of $g(s)$ out of all the minimum points.
On a quick google, I found the following document https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf which seems to go into detail for computing such closest points on an ellipse.
In the case of a circle of radius $R$, its not so hard. Recenter so that the circle $C$ is entered at the origin, and write $mathbf x = r mathbf u$ where $mathbf u $ is a unit vector, and $r=r(mathbf x) = |mathbf x|$ is the distance of $mathbf x$ to 0. Then
$$f_C(mathbf x) = e^^2 / 2sigma^2$$
For an arbitrarily located circle $ = R$, you just need to use $r(mathbf x) = |mathbf x - mathbf x_0|$ instead. If $mathbf x_0 = (x_0,y_0)$, then we arrive at
$$f_C(x,y) = expleft(frac-left2sigma^2 right)$$
Naively substituting the circle formula $|mathbf x - mathbf x_0| = R$ with the similar formula for the ellipse $|mathbf x - mathbf x_0| + |mathbf x - mathbf x_1| = R$ ,
$$f_C(mathbf x) = expleft(frac^22sigma^2right) ?$$
gives you something that looks reasonable, but you can see that the level sets are not perfect. Regardless, the spread of the variance doesn't depend on how big the ellipse is.
edited Jul 26 at 21:48
answered Jul 26 at 16:49
Calvin Khor
8,03911132
8,03911132
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2863523%2fgaussian-along-an-ellipse%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password