diff options
Diffstat (limited to 'Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py')
-rw-r--r-- | Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py b/Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py index 9a982a5..fb0375f 100644 --- a/Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py +++ b/Wrappers/Python/ccpi/astra/operators/AstraProjectorMC.py @@ -1,25 +1,29 @@ -# -*- 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. +#======================================================================== +# Copyright 2019 Science Technology Facilities Council +# Copyright 2019 University of Manchester # -# 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. +# This work is part of the Core Imaging Library developed by Science Technology +# Facilities Council and University of Manchester # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#========================================================================= + + +from ccpi.optimisation.operators import LinearOperator +from ccpi.astra.processors import AstraForwardProjectorMC, AstraBackProjectorMC +from ccpi.astra.operators import AstraProjectorSimple -from ccpi.optimisation.operators import Operator, LinearOperator -from ccpi.framework import AcquisitionData, ImageData, DataContainer -from ccpi.astra.processors import AstraForwardProjector, AstraBackProjector, \ - AstraForwardProjectorMC, AstraBackProjectorMC, AstraForwardProjector3D, \ - AstraBackProjector3D class AstraProjectorMC(LinearOperator): """ASTRA Multichannel projector""" @@ -42,6 +46,7 @@ class AstraProjectorMC(LinearOperator): # Initialise empty for singular value. self.s1 = None + self.device = device def direct(self, IM, out=None): self.fp.set_input(IM) @@ -63,9 +68,40 @@ class AstraProjectorMC(LinearOperator): return self.volume_geometry def range_geometry(self): - return self.sinogram_geometry + return self.sinogram_geometry - def norm(self): - x0 = self.volume_geometry.allocate('random') - self.s1, sall, svec = LinearOperator.PowerMethod(self, 50, x0) - return self.s1 + def calculate_norm(self): + + igtmp = self.volume_geometry.clone() + igtmp.shape = self.volume_geometry.shape[1:] + igtmp.dimension_labels = ['horizontal_y', 'horizontal_x'] + igtmp.channels = 1 + + agtmp = self.sinogram_geometry.clone() + agtmp.shape = self.sinogram_geometry.shape[1:] + agtmp.dimension_labels = ['angle', 'horizontal'] + agtmp.channels = 1 + + Atmp = AstraProjectorSimple(igtmp, agtmp, device = self.device) + + return Atmp.norm() + + + +if __name__ == '__main__': + + from ccpi.framework import ImageGeometry, AcquisitionGeometry + import numpy as np + + N = 30 + angles = np.linspace(0, np.pi, 180) + ig = ImageGeometry(N, N, channels = 5) + ag = AcquisitionGeometry('parallel','2D', angles, pixel_num_h = N, channels = 5) + + A = AstraProjectorMC(ig, ag, 'gpu') + print(A.norm()) + + + + + |