title: Best way to rotate the 3D image in python
body: <p>I have the 3D image with the voxel size of 1mmx1mmx1mm. It is a medical image. I am applying it to deep learning and I need to augment the dataset. I choose the rotation to augment the dataset. </p>
  
  <pre><code>from scipy.ndimage import rotate
  image_rotate=rotate(img, angle=angle, reshape=False, axes=axes)
  </code></pre>
  
  <p>I found that when I rotate to angle=10, then the result is rotated again to angle=-10, the obtained result is not so same the original image. It means I compute the mean square error (MSE) between them and it is non-zero. Do we have the better way to achieve a small MSE in python? </p>
  
  <p>The full code is</p>
  
  <pre><code>from scipy.ndimage import rotate
  from sklearn.metrics import mean_squared_error
  img_original = np.copy(img)
  image_rotate_10=rotate(img, angle=10, reshape=False, axes=axes)
  image_rotate_neg10=rotate(image_rotate_10, angle=-10, reshape=False, axes=axes)    
  mse = mean_squared_error(img_original, image_rotate_neg10)
  #Or compute number of different pixel
  error = ((label_original - labels) ** 2).sum(axis=None)
  </code></pre>