0

The scipy.ndimage.rotate is supposed to apply a spline filter before rotation. But with images of at least 3 dimensions, when I apply scipy.ndimage.prefilter before and I then call rotate with prefilter=False, the result is very different in comparison with a simple call to rotate with prefilter=True.

Here is a simple reproducer with a rotation of 0, which is supposed to let unchanged the input array:

from scipy import ndimage
import numpy as np

t = np.random.uniform(0,1000,size=(3,3,3))

trans1 = ndimage.rotate(t, angle=0, axes=(1,0), reshape=False, mode='constant', cval=0, prefilter=True)

trans2 = ndimage.spline_filter(t, mode='constant')
trans2 = ndimage.rotate(trans2, angle=0, axes=(1,0), reshape=False, mode='constant', cval=0, prefilter=False)

print(f"dist (t,trans1) = {abs(t-trans1).mean():.6f}")
print(f"dist (t,trans2) = {abs(t-trans2).mean():.6f}")

Example of output:

dist (t,trans1) = 0.000000
dist (t,trans2) = 240.582366

We can see that, when we apply prefilter before rotate, the result is very different and I don't understand why.

vincent59
  • 81
  • 2
  • 7

0 Answers0