[SciPy-User] Difference in quality from different interpolation orders

Chris Weisiger cweisiger at msg.ucsf.edu
Thu Jun 16 19:08:00 EDT 2011


On Thu, Jun 16, 2011 at 3:51 PM, David Baddeley <david_baddeley at yahoo.com.au
> wrote:

> Are you doing the interpolation in order to test different alignments (ie
> within an alignment loop / minimisation problem), or are you calculating the
> shift using e.g. cross correlation and then just shifting the data once?
>

Yes. :)

The program's purpose is to find alignment parameters (XYZ shift, plus
rotate about Z and zoom in XY). scipy.optimize.fmin is used for finding
those parameters; this requires calculating many transformed 2D views of the
data, though we start off with a cross-correlation to generate our initial
guess. Once 2D alignment is done we calculate the Z offset using
scipy.ndimage.shift on the entire 3D volume. Finally we use affine_transform
to save the resulting transformed array to disk.

I'm using order = 1 for the 2D slices here and getting quite good results
(visually speaking), so evidently inaccuracy due to order isn't a problem
for that part. What I discovered was that for saving, I could also transform
the entire volume by stacking transformed 2D slices, much faster than I
could by using affine_transform...so long as the order was 1. If order = 2
then affine_transform is much faster.


> If you're doing it within a loop I could see how the performance could
> really bite you. That said, if it's as part of a minimisation problem I
> think you'd almost certainly want cubic spline due to the differentiability.
> If you are doing multiple interpolations from the same data, you can speed
> this up a lot by pre-calculating the spline coefficients. eg:
>
<snip>

I'll have to take a look at ndimage.spline_filter; it could speed up the
optimization problem significantly. I don't think it'll help with the saving
process though, since that's only looking at each slice once.

Thanks for the advice!

(As for noise reduction, this is getting into an area I don't have much
domain expertise in. We do do deconvolution as well as denoising, but I
don't think anyone here has done a study on the proper order to apply
alignment/denoising/deconvolution in for our data)

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110616/0952f19e/attachment.html>


More information about the SciPy-User mailing list