# Constructing a rotation-invariant transform

In image processing and object recognition, certain characteristics are highly important to detect while other, such as rotation, are not. Here, we use the Radon transform to construct a system to detect image characteristics, independently of their rotation. As a side note, the Hough transform (see previous post) could also be used to this purpose. A rotation in the Radon transform causes the spectrum to shift. By using a simple DFT technique, this shift can be bypassed.

Using some example code form the Scikit-Image library for Python, we can obtain the following result.

We note that in the projection-angular domain, a 90 degree rotation causes a $\frac{\pi}{2}$ phase shift. However, the DFT transform is unaffected by this shift, as can be seen in the log-value plot.

Try it yourself with the code below.

from __future__ import print_function, division

import numpy as np
import matplotlib.pyplot as plt
from scipy import fftpack

from skimage import data_dir
from skimage.transform import radon, rescale, rotate

image = rescale(image, scale=0.4)

fig, ((ax1, ax2, ax3,), (ax4, ax5, ax6)) = plt.subplots(2, 3, figsize=(8, 4.5))

# Original image
image = rotate(image, 0)
ax1.set_title(&quot;Original&quot;)
ax1.imshow(image, cmap=plt.cm.Greys_r)

image_rot = rotate(image, 90)
ax4.set_title(&quot;(Rotated)&quot;)
ax4.imshow(image_rot, cmap=plt.cm.Greys_r)

theta = np.linspace(0., 180., max(image.shape), endpoint=False)

ax2.set_xlabel(&quot;Projection angle (deg)&quot;)
ax2.set_ylabel(&quot;Projection position (pixels)&quot;)

ax2.imshow(sinogram, cmap=plt.cm.Greys_r,
extent=(0, 180, 0, sinogram.shape[0]), aspect='auto')

ax5.imshow(sinogram_rot, cmap=plt.cm.Greys_r,
extent=(0, 180, 0, sinogram.shape[0]), aspect='auto')

# DFT / Make it rotation invariant
fourier_sine = fftpack.fft2(sinogram)
fourier_shifted = np.log(np.abs(fftpack.fftshift(fourier_sine)))

fourier_sine_rot = fftpack.fft2(sinogram_rot)
fourier_shifted_rot = np.log(np.abs(fftpack.fftshift(fourier_sine_rot)))

ax3.set_title(&quot;DFT transform (log)&quot;)

ax3.imshow(fourier_shifted)
ax6.imshow(fourier_shifted_rot)

# Plot the data
plt.show()