[SciPy-User] Gaussian filter on an angle
Mon Jun 7 06:27:46 CDT 2010
Sorry for the long delay, I didn't want to get over this on the week-end.
I dealt a great deal with the topological issue (after all, my PhD was
on data reduction on Riemannian manifolds), so I know the issues I'm
facing. Well, almost.
Anne > my issues ae the defect after the smoothing. The angle field is
an azimuth for a tilt in 3D. The problem is that when the vertical
angle is very smooth, the azimuth becomes less accurate and flip from
0 to pi. This causes my issues. Even when I smooth the original data
before the conversion, the locations where those flips occure remain
small and causes the next computation to diverge. I don't know if I
can reconstruct the original data (the data I have are the result of
the resolution of an inverse problem where the original data is
I guess I will have to find another solution or in the end look
further into phase smoothing...
Thanks a lot of all your answers!
2010/6/4 Zachary Pincus <email@example.com>:
> On Jun 4, 2010, at 6:38 AM, Anne Archibald wrote:
>> On 4 June 2010 06:00, Matthieu Brucher <firstname.lastname@example.org>
>>> I'm trying to blur an angle field, but it's not easy ;)
>>> Applying gaussian_filter (from ndimage) on the sinus and the cos is
>>> not enough to have a smooth angle field, and of course applying
>>> gaussian_filter directly on the angle field does not yeild
>>> satisfactiry results.
>>> Does anyone know of a function (even if it not in Python yet) that
>>> could gaussian filter an angle field? Something like a Riemanian
>>> filter (instead of an Euclidian one)...
>> This isn't my field, but I suspect you will have problems with this.
>> In particular, there is a *topological* obstacle to blurring angle
>> fields. In the blurred field, you want each angle to be close to that
>> of nearby pixels. But imagine following the angle around the image in
>> a circle: the angle changes by one full turn as you go around this
>> loop. Any smoothing mechanism must either introduce a discontinuity in
>> this loop or retain one full turn around the loop.
> Anne's quite right -- I've banged my head on things like this before
> too. I have a different idea about how to get around these issues, in
> a killing-a-gnat-with-a-bazooka kind of way, though: you might be able
> to pose this question as one of smoothing via curve-fitting instead of
> via filtering?
> E.g. fit a bivariate spline or some other polynomial surface to your
> angles in such a was as to minimize not the squared residuals
> directly, but the square of the minimum angle between the fit surface
> at that point and the data (going clockwise or counterclockwise,
> whichever is smaller... I forget exactly but there's a closed-form way
> to calculate that). This way you get a smooth underlying fit in a way
> that is (I think?) immune to discontinuities in the angle data.
> Problem is either this will be very slow (fitting a many-parameter
> surface) or probably over-smooth (fitting a low-parameter surface).
> There are probably some multi-resolution methods you could use. I
> think the nonlinear least squares optimizers in scipy would be the way
> to go here?
>> The former is
>> unlikely to be desirable, and the latter is asking rather a lot of a
>> smoothing method, and in any case still results in rapidly-changing
>> angles around small loops. You could look into "phase unwrapping",
>> techniques to reconstruct a function from its values modulo 2 pi;
>> obviously once you had an unwrapped function blurring would work
>> normally. In this setting unwrapping simply fails when there are
>> topological obstacles. The alternative I would suggest is what you
>> already tried, converting your angles to a vector field and smoothing
>> that. You'll still get defects where the angles change rapidly, but I
>> don't think that can be avoided, and the length of the resulting
>> vectors will tell you something about the degree of defectiveness.
>> The key to making any of this work is having original angles that are
>> not too noisy. If you're extracting the angles from some underlying
>> data, say by calculating an average direction over squares of an
>> image, I recommend using enough averaging to get the noise on the
>> angle quite small, so that defects will be rare. You may find yourself
>> needing to resolve defects manually if you can't just live with them.
>> P.S. This sort of topological obstruction is the origin for
>> hypothetical "cosmic strings" as well as some of the neat dynamics of
>> vortices in inviscid fluids and magnetic fields in type II
>> superconductors. -A
>>> Information System Engineer, Ph.D.
>>> Blog: http://matt.eifelle.com
>>> LinkedIn: http://www.linkedin.com/in/matthieubrucher
>>> SciPy-User mailing list
>> SciPy-User mailing list
> SciPy-User mailing list
Information System Engineer, Ph.D.
More information about the SciPy-User