1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# -*- coding: utf-8 -*-
# This work is independent part of the Core Imaging Library developed by
# Visual Analytics and Imaging System Group of the Science Technology
# Facilities Council, STFC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ccpi.optimisation.operators import Operator, LinearOperator
from ccpi.framework import AcquisitionData, ImageData, DataContainer
from ccpi.optimisation.ops import PowerMethodNonsquare
from ccpi.astra.processors import AstraForwardProjector, AstraBackProjector, \
AstraForwardProjectorMC, AstraBackProjectorMC, AstraForwardProjector3D, \
AstraBackProjector3D
class AstraProjectorMC(LinearOperator):
"""ASTRA Multichannel projector"""
def __init__(self, geomv, geomp, device):
super(AstraProjectorMC, self).__init__()
# Store volume and sinogram geometries.
self.sinogram_geometry = geomp
self.volume_geometry = geomv
self.fp = AstraForwardProjectorMC(volume_geometry=geomv,
sinogram_geometry=geomp,
proj_id=None,
device=device)
self.bp = AstraBackProjectorMC(volume_geometry=geomv,
sinogram_geometry=geomp,
proj_id=None,
device=device)
# Initialise empty for singular value.
self.s1 = None
def direct(self, IM, out=None):
self.fp.set_input(IM)
if out is None:
return self.fp.get_output()
else:
out.fill(self.fp.get_output())
def adjoint(self, DATA, out=None):
self.bp.set_input(DATA)
if out is None:
return self.bp.get_output()
else:
out.fill(self.bp.get_output())
def domain_geometry(self):
return self.volume_geometry
def range_geometry(self):
return self.sinogram_geometry
def norm(self):
x0 = self.volume_geometry.allocate('random')
self.s1, sall, svec = PowerMethodNonsquare(self, 50, x0)
return self.s1
|