示例#1
0
    def test_axis_sym_projection(self):
        tol = 1e-6

        dir_path = os.path.dirname(os.path.realpath(__file__))
        param = axitom.config_from_xtekct(dir_path +
                                          "/example_data/settings.xtekct")
        param.n_voxels_x = 100
        param.n_voxels_y = 100
        param.n_voxels_z = 100
        #
        param.object_size_x = 100.
        param.object_size_y = 100.
        param.object_size_z = 100.

        param.n_pixels_u = 100
        param.n_pixels_v = 100

        param.detector_size_u = param.object_size_x
        param.detector_size_v = param.object_size_y

        param.source_to_detector_dist = 1.0e20
        param.source_to_object_dist = 1.e20

        param.update()

        volume = barrel(100)

        angles = [0.]

        proj = axis_sym_projection(volume, param, angles=angles)

        error = np.abs(np.sum(volume, axis=1) - proj)

        if np.max(error) > tol:
            self.fail()
示例#2
0
    def run_reconstruction_and_compare(self, path_to_projections, correct_body):
        # Set the work path as the filepath to this file
        dir_path = os.path.dirname(os.path.realpath(__file__))

        # Set the same settings as used in the forward projection
        param = axitom.config_from_xtekct(dir_path + "/example_data/settings.xtekct")
        param.n_voxels_x = 500
        param.n_voxels_y = 500
        param.n_voxels_z = 500
        param.n_pixels_u = 500
        param.n_pixels_v = 500
        param.update()

        proj = np.load(dir_path + path_to_projections)
        proj = np.exp(-proj)

        reconstruction = axitom.fdk(proj, param)

        # Note that the reconstruction give the radial slice only
        deviation_field = np.abs(correct_body[:250, 250, :] - reconstruction)

        # Sample some deviation values from the background and the interior
        background_deviation = deviation_field[5:60, 75:-75]
        interior_deviation = deviation_field[90:, 75:-75]

        if np.max(background_deviation) > self.tol:
            self.fail("The background was not reconstructed properly with largest deviation of %f" % np.max(
                background_deviation))

        if np.max(interior_deviation) > self.tol:
            self.fail(
                "The interior was not reconstructed properly with largest deviation of %f" % np.max(interior_deviation))
示例#3
0
文件: recon.py 项目: nik849/ct-tools
 def __init__(self, dataset=None, xtekct=None, debug=None, **kwargs):
     self.debug = debug
     if dataset is not None:
         self.dataset = sorted([
             os.path.join(data, f) for f in os.listdir(data)
             if f.endswith('.tif')
         ])
     else:
         self.dataset = sorted(glob.glob(".tif"))
     if xtekct is not None:
         self.config = axitom.config_from_xtekct(xtekct)
     else:
         self.config = axitom.config_from_xtekct(glob.glob("*.xtekct")[0])
     if self.debug:
         print(self.dataset)
         print(self.config)
示例#4
0
def main():
    config = axitom.config_from_xtekct("./example_data/radiogram.xtekct")
    config.n_voxels_x = 500
    config.n_voxels_y = 500
    config.n_voxels_z = 500
    config.n_pixels_u = 500
    config.n_pixels_v = 500
    config.update()

    radiograms = np.load("proj_barrel.npy")

    radiograms = np.exp(-radiograms)

    tomogram = axitom.fdk(radiograms, config)

    return tomogram
示例#5
0
def main():
    config = axitom.config_from_xtekct(join(path_to_data, "radiogram.xtekct"))
    config.n_voxels_x = 500
    config.n_voxels_y = 500
    config.n_voxels_z = 500
    config.n_pixels_u = 500
    config.n_pixels_v = 500
    config.update()

    radiograms = np.load(join(path_to_data, "proj_barrel.npy"))

    radiograms = np.exp(-radiograms)

    tomogram = axitom.fdk(radiograms, config)

    return tomogram
def reconstruct_tomogram():
    config = axitom.config_from_xtekct("./example_data/radiogram.xtekct")

    radiogram = axitom.read_image(r"./example_data/radiogram.tif", flat_corrected=True)
    # Remove some edges that are in field of view
    radiogram[:250, :] = 0.95
    radiogram[1800:, :] = 0.95

    radiogram = median_filter(radiogram, size=20)

    _, center_offset = axitom.object_center_of_rotation(radiogram, config, background_internsity=0.9)
    config.center_of_rot_y = center_offset
    config.update()

    tomogram = axitom.fdk(radiogram, config)

    return tomogram
示例#7
0
def run_reconstruction():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    config = axitom.config_from_xtekct(dir_path +
                                       "/example_data/settings.xtekct")
    radiogram = axitom.read_image(dir_path + "/example_data/radiogram.tif",
                                  flat_corrected=True)

    # Remove some edges that are in field of view
    radiogram[:250, :] = 0.95
    radiogram[1800:, :] = 0.95

    radiogram = median_filter(radiogram, size=20)

    _, center_offset = axitom.object_center_of_rotation(
        radiogram, config, background_internsity=0.9)
    config.center_of_rot_y = center_offset

    config.update()

    reconstruction = axitom.fdk(radiogram, config)

    return reconstruction