def BACKPROJ(self, sinogram): if (self.geom == '2D'): from tomobar.supp.astraOP import AstraTools Atools = AstraTools(self.DetectorsDimH, self.AnglesVec, self.ObjSize, self.device) # initiate 2D ASTRA class object image = Atools.backproj(sinogram) if (self.geom == '3D'): from tomobar.supp.astraOP import AstraTools3D Atools = AstraTools3D(self.DetectorsDimH, self.DetectorsDimV, self.AnglesVec, self.CenterRotOffset, self.ObjSize) # initiate 3D ASTRA class object image = Atools.backproj(sinogram) return image
def FORWPROJ(self, image): if (self.geom == '2D'): from tomobar.supp.astraOP import AstraTools Atools = AstraTools(self.DetectorsDimH, self.AnglesVec, self.ObjSize, self.device) # initiate 2D ASTRA class object sinogram = Atools.forwproj(image) if (self.geom == '3D'): from tomobar.supp.astraOP import AstraTools3D Atools = AstraTools3D(self.DetectorsDimH, self.DetectorsDimV, self.AnglesVec, self.ObjSize) # initiate 3D ASTRA class object sinogram = Atools.forwproj(image) return sinogram
def FBP(self, sinogram): from tomobar.supp.astraOP import AstraTools if (self.geom == '2D'): Atools = AstraTools( self.DetectorsDimH, self.AnglesVec, self.CenterRotOffset, self.ObjSize, self.device_projector) # initiate 2D ASTRA class object 'dealing with FBP 2D not working for parallel_vec geometry and CPU' if (self.device_projector == 'gpu'): FBP_rec = Atools.fbp2D(sinogram) # GPU reconstruction else: filtered_sino = filtersinc2D(sinogram) # filtering sinogram FBP_rec = Atools.backproj(filtered_sino) # backproject if ((self.geom == '3D') and (self.CenterRotOffset is None)): FBP_rec = np.zeros( (self.DetectorsDimV, self.ObjSize, self.ObjSize), dtype='float32') Atools = AstraTools( self.DetectorsDimH, self.AnglesVec - np.pi, self.CenterRotOffset, self.ObjSize, self.device_projector) # initiate 2D ASTRA class object for i in range(0, self.DetectorsDimV): FBP_rec[i, :, :] = Atools.fbp2D(np.flipud(sinogram[i, :, :])) if ((self.geom == '3D') and (self.CenterRotOffset is not None)): # perform FBP using custom filtration from tomobar.supp.astraOP import AstraTools3D Atools = AstraTools3D( self.DetectorsDimH, self.DetectorsDimV, self.AnglesVec, self.CenterRotOffset, self.ObjSize) # initiate 3D ASTRA class object filtered_sino = filtersinc3D(sinogram) # filtering sinogram FBP_rec = Atools.backproj(filtered_sino) # backproject return FBP_rec
def FBP(self, sinogram): from tomobar.supp.astraOP import AstraTools if (self.geom == '2D'): Atools = AstraTools(self.DetectorsDimH, self.AnglesVec, self.ObjSize, self.device) # initiate 2D ASTRA class object FBP_rec = Atools.fbp2D(sinogram) if (self.geom == '3D'): FBP_rec = np.zeros( (self.DetectorsDimV, self.ObjSize, self.ObjSize), dtype='float32') Atools = AstraTools(self.DetectorsDimH, self.AnglesVec - np.pi, self.ObjSize, self.device) # initiate 2D ASTRA class object for i in range(0, self.DetectorsDimV): FBP_rec[i, :, :] = Atools.fbp2D(np.flipud(sinogram[i, :, :])) return FBP_rec
def __init__( self, DetectorsDimH, # DetectorsDimH # detector dimension (horizontal) DetectorsDimV, # DetectorsDimV # detector dimension (vertical) for 3D case only CenterRotOffset, # Center of Rotation (CoR) scalar (for 3D case only) AnglesVec, # array of angles in radians OR a (N,12) matrix containing the actual geometry. ObjSize, # a scalar to define reconstructed object dimensions datafidelity, # data fidelity, choose 'LS', 'PWLS', 'GH' (wip), 'Student' (wip) nonnegativity, # select 'nonnegativity' constraint (set to 'ENABLE') OS_number, # the number of subsets, NONE/(or > 1) ~ classical / ordered subsets tolerance, # tolerance to stop OUTER iterations earlier device): if ObjSize is tuple: raise ( " Reconstruction is currently available for square or cubic objects only, provide a scalar " ) else: self.ObjSize = ObjSize # size of the object self.tolerance = tolerance self.datafidelity = datafidelity self.OS_number = OS_number self.DetectorsDimV = DetectorsDimV self.DetectorsDimH = DetectorsDimH if AnglesVec.ndim == 1: self.angles_number = len(AnglesVec) else: self.angles_number = AnglesVec.shape[0] if CenterRotOffset is None: self.CenterRotOffset = 0.0 else: self.CenterRotOffset = CenterRotOffset # enables nonnegativity constraint if nonnegativity == 'ENABLE': self.nonnegativity = 1 else: self.nonnegativity = 0 if device is None: self.device = 'gpu' else: self.device = device if ((datafidelity != 'LS') and (datafidelity != 'PWLS')): raise ('Unknown data fidelity type, select: LS, PWLS') if DetectorsDimV is None: # Creating Astra class specific to 2D parallel geometry if ((OS_number is None) or (OS_number <= 1)): # classical approach from tomobar.supp.astraOP import AstraTools self.Atools = AstraTools( DetectorsDimH, AnglesVec, ObjSize, device) # initiate 2D ASTRA class object self.OS_number = 1 else: # Ordered-subset approach from tomobar.supp.astraOP import AstraToolsOS self.Atools = AstraToolsOS( DetectorsDimH, AnglesVec, ObjSize, self.OS_number, device) # initiate 2D ASTRA class OS object self.geom = '2D' else: # Creating Astra class specific to 3D parallel geometry self.geom = '3D' if ((OS_number is None) or (OS_number <= 1)): from tomobar.supp.astraOP import AstraTools3D self.Atools = AstraTools3D( DetectorsDimH, DetectorsDimV, AnglesVec, self.CenterRotOffset, ObjSize) # initiate 3D ASTRA class object self.OS_number = 1 else: # Ordered-subset from tomobar.supp.astraOP import AstraToolsOS3D self.Atools = AstraToolsOS3D( DetectorsDimH, DetectorsDimV, AnglesVec, self.CenterRotOffset, ObjSize, self.OS_number) # initiate 3D ASTRA class OS object