Skip to content

Commit

Permalink
Get the simple Backproject back
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarago committed Mar 25, 2014
1 parent 24f1b54 commit 483bdaa
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions concert/ext/ufo.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,62 @@ class Backproject(InjectProcess):
rotation.
"""

def __init__(self, axis_pos=None):
self.pm = PluginManager()
self.fft = self.pm.get_task('fft', dimensions=1)
self.ifft = self.pm.get_task('ifft', dimensions=1)
self.fltr = self.pm.get_task('filter')
self.backprojector = self.pm.get_task('backproject')

if axis_pos:
self.backprojector.props.axis_pos = axis_pos

graph = Ufo.TaskGraph()
graph.connect_nodes(self.fft, self.fltr)
graph.connect_nodes(self.fltr, self.ifft)
graph.connect_nodes(self.ifft, self.backprojector)

super(Backproject, self).__init__(graph, get_output=True)

@property
def axis_position(self):
return self.backprojector.props.axis_pos

@axis_position.setter
def axis_position(self, position):
self.backprojector.props.axis_pos = position

@coroutine
def __call__(self, consumer):
"""Get a sinogram, do filtered backprojection and send it to *consumer*."""
slice = None
if not self._started:
self.start()

while True:
sinogram = yield

if slice is None:
width = sinogram.shape[1]
slice = np.empty((width, width), dtype=np.float32)

self.insert(sinogram)
slice = self.result()[:width, :width]

consumer.send(slice)


class FlatCorrectedBackproject(InjectProcess):

"""
Coroutine to reconstruct slices from sinograms using filtered
backprojection.
*axis_pos* specifies the center of rotation in pixels within the sinogram.
If not specified, the center of the image is assumed to be the center of
rotation.
"""

def __init__(self, flat_row, dark_row, axis_pos=None):
self.pm = PluginManager()
self.sino_convert = self.pm.get_task('opencl')
Expand Down

0 comments on commit 483bdaa

Please sign in to comment.