Created
November 24, 2017 00:51
-
-
Save MatthewJA/12e74d26ba6f476cda88b8c85c3d8f84 to your computer and use it in GitHub Desktop.
Fast(ish) approximation to a radon transform.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import scipy.ndimage.interpolation | |
def radon_transform(ims): | |
"""Radon transform a batch of images. | |
Parameters | |
---------- | |
ims : numpy.ndarray | |
(N x W x H) NumPy array of N images. | |
Returns | |
------- | |
(N x W x W) NumPy array of radon-transformed images. | |
""" | |
projections = numpy.linspace(0, 360, ims.shape[1]) | |
rotations = numpy.transpose(numpy.stack([ | |
scipy.ndimage.interpolation.rotate(ims, projection, axes=(1, 2), reshape=False) | |
for projection in projections]), (1, 0, 2, 3)) | |
transformed = rotations.sum(axis=3) | |
return transformed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment