[Numpy-discussion] nd_image.affine_transform edge effects

James Turner jturner@gemini....
Sat Mar 24 00:41:21 CDT 2007


Hi Zach,

> Hmm, this is worrisome. There really shouldn't be ringing on
> continuous-tone images like Lena  -- right? (And at no step in an
> image like that should gaussian filtering be necessary if you're
> doing spline interpolation -- also right?)

That's hard to say. Just because it's mainly a continuous-tone image
doesn't necessarily mean it is well sampled everywhere. This depends
both on the subject and the camera optics. Unlike the data I usually
work with, I think everyday digital photographs (probably a photo
scan in the case of Lena) do not generally have the detector sampling
frequency matched to the optical resolution of the image. If that's
true, the presence of aliasing in interpolated images depends on the
structure of the subject and whether the scene has edges or high-
frequency patterns in it.

Stefan's rotated Lena example is indeed a bit bizarre on zooming in!
However, the artefacts are clearly localized to distinct edges, so I
suspect this is indeed some kind of aliasing. Moreover, it looks like
Lena has been decimated (reduced in size) prior to the rotation. That
is definitely a good way to get artefacts, unless an anti-aliasing
filter is applied before shrinking the image. My impression is that
this image is probably somewhat undersampled (to understand exactly
what that means, read up on the Sampling Theorem).

I can't say that the green blobs are *not* caused by a flaw in the
algorithm. In particular, I am not used to working with colour images
of this kind, so I don't have a good feeling for what aliasing looks
like in a case like this. However, I definitely would not rule out
intrinsic aliasing effects as the cause of this problem without
investigating it further. One experiment might be to blur the original
Lena with a Gaussian whose sigma is 1 pixel of the shrunken image
before actually shrinking her, then do the rotation.

> The first was on Stefan's artificial data which had sharp edges, and
> got very nasty ringing artifacts even with 3rd order splines. From
> your recollection, is this expected behavior based on splines and the
> nature of Stefan's image, or more likely to be a bug?

Your question was aimed at Travis, so I don't want to discourage him
from answering it :-), but looking at this in more detail, I do think
the amplitude of the artefacts here is greater than I might expect due
to ringing with a quadratic b-spline kernel, which I think has minima
with amplitudes <10% of the central peak. There has to be SOME
oscillation, but in Stefan's "rotate_artifacts" example it seems to be
at the level of ~100%. Also, it is not present on one of the inner
edges for some reason. So I do wonder if the algorithm in nd_image is
making this worse than it needs to be. These thoughts seem consistent
with Travis's comments. Is it possible to transform the same data
using the fitpack routines that Stefan mentioned in post 026641 and
compare the results? I just tried doing a similar rotation in PyRAF on
a monochrome image with a bicubic spline, and see considerably smaller
artefacts (just a compact overshoot of probably a few % at the edge).

Cheers,

James.



More information about the Numpy-discussion mailing list