Exemplo n.º 1
0
    def process(self, out=None):

        IM = self.get_input()

        pad = False
        if len(IM.shape) == 2:
            #for 2D cases
            pad = True
            data_temp = numpy.expand_dims(IM.as_array(), axis=0)
        else:
            data_temp = IM.as_array()

        sinogram_id, arr_out = astra.create_sino3d_gpu(data_temp,
                                                       self.proj_geom,
                                                       self.vol_geom)

        astra.data3d.delete(sinogram_id)

        if pad is True:
            arr_out = numpy.squeeze(arr_out, axis=0)

        if out is None:
            out = AcquisitionData(arr_out,
                                  deep_copy=False,
                                  geometry=self.sinogram_geometry.copy(),
                                  suppress_warning=True)
            return out
        else:
            out.fill(arr_out)
    def process(self, out=None):

        IM = self.get_input()
        sinogram_id, arr_out = astra.create_sino(IM.as_array(), self.proj_id)
        astra.data2d.delete(sinogram_id)

        if out is None:
            out = AcquisitionData(arr_out,
                                  deep_copy=False,
                                  geometry=self.sinogram_geometry.copy(),
                                  suppress_warning=True)
            return out
        else:
            out.fill(arr_out)
Exemplo n.º 3
0
    def direct(self, x, out=None):

        if self.tigre_geom.is2D:
            data_temp = np.expand_dims(x.as_array(),axis=0)
            arr_out = Ax.Ax(data_temp, self.tigre_geom, self.tigre_angles, projection_type=self.method['direct'])
            arr_out = np.squeeze(arr_out, axis=1)
        else:
            arr_out = Ax.Ax(x.as_array(), self.tigre_geom, self.tigre_angles, projection_type=self.method['direct'])

        if out is None:
            out = AcquisitionData(arr_out, deep_copy=False, geometry=self._range_geometry.copy(), suppress_warning=True)
            return out
        else:
            out.fill(arr_out)
    def process(self, out=None):

        IM = self.get_input()

        pad = False
        if len(IM.shape) == 2:
            #for 2D cases
            pad = True
            data_temp = np.expand_dims(IM.as_array(), axis=0)
        else:
            data_temp = IM.as_array()

        if out is None:

            sinogram_id, arr_out = astra.create_sino3d_gpu(
                data_temp, self.proj_geom, self.vol_geom)
        else:
            if pad:
                arr_out = np.expand_dims(out.as_array(), axis=0)
            else:
                arr_out = out.as_array()

            sinogram_id = astra.data3d.link('-sino', self.proj_geom, arr_out)
            self.create_backprojection3d_gpu(data_temp, self.proj_geom,
                                             self.vol_geom, False, sinogram_id)

        #clear the memory on GPU
        astra.data3d.delete(sinogram_id)

        if pad is True:
            arr_out = np.squeeze(arr_out, axis=0)

        if out is None:
            out = AcquisitionData(arr_out,
                                  deep_copy=False,
                                  geometry=self.sinogram_geometry.copy(),
                                  suppress_warning=True)
            return out
        else:
            out.fill(arr_out)
    def direct(self, x, out=None):

        data = x.as_array()

        if self.tigre_geom.is2D:
            data_temp = np.expand_dims(data, axis=0)
            arr_out = self.__call_Ax(data_temp)
            arr_out = np.squeeze(arr_out, axis=1)
        else:
            arr_out = self.__call_Ax(data)

        #if single angle projection remove the dimension for CIL
        if arr_out.shape[0] == 1:
            arr_out = np.squeeze(arr_out, axis=0)

        if out is None:
            out = AcquisitionData(arr_out,
                                  deep_copy=False,
                                  geometry=self._range_geometry.copy(),
                                  suppress_warning=True)
            return out
        else:
            out.fill(arr_out)