Пример #1
0
def c_project(obj, center, tomo, theta):
    if len(obj.shape) == 2:
        # no y-axis (only one slice)
        oy = 1
        ox, oz = obj.shape
    else:
        oy, ox, oz = obj.shape

    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.project.restype = dtype.as_c_void_p()
    LIB_TOMOPY.project(
        dtype.as_c_float_p(obj),
        dtype.as_c_int(oy),
        dtype.as_c_int(ox),
        dtype.as_c_int(oz),
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta))
Пример #2
0
def c_project2(objx, objy, center, tomo, theta):
    # TODO: we should fix this elsewhere...
    # TOMO object must be contiguous for c function to work

    contiguous_tomo = np.require(tomo, requirements="AC")
    if len(objx.shape) == 2:
        # no y-axis (only one slice)
        oy = 1
        ox, oz = objx.shape
    else:
        oy, ox, oz = objx.shape

    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.project2.restype = dtype.as_c_void_p()
    LIB_TOMOPY.project2(
        dtype.as_c_float_p(objx),
        dtype.as_c_float_p(objy),
        dtype.as_c_int(oy),
        dtype.as_c_int(ox),
        dtype.as_c_int(oz),
        dtype.as_c_float_p(contiguous_tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta))
    tomo[:] = contiguous_tomo[:]
Пример #3
0
def c_sirt(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    use_accel = 1 if kwargs['accelerated'] else 0

    LIB_TOMOPY.sirt.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.sirt(
            dtype.as_c_float_p(tomo),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta),
            dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']),
            dtype.as_c_int(use_accel),
            dtype.as_c_int(kwargs['pool_size']),
            dtype.as_c_char_p(kwargs['interpolation']),
            dtype.as_c_char_p(kwargs['device']),
            dtype.as_c_int_p(kwargs['grid_size']),
            dtype.as_c_int_p(kwargs['block_size']))
Пример #4
0
def c_vector2(tomo1, tomo2, center1, center2, recon1, recon2, recon3, theta1, theta2, axis1, axis2, **kwargs):
    if len(tomo1.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo1.shape
    else:
        dy, dt, dx = tomo1.shape

    LIB_TOMOPY.vector2.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.vector2(
            dtype.as_c_float_p(tomo1),
            dtype.as_c_float_p(tomo2),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center1),
            dtype.as_c_float_p(center2),
            dtype.as_c_float_p(theta1),
            dtype.as_c_float_p(theta2),
            dtype.as_c_float_p(recon1),
            dtype.as_c_float_p(recon2),
            dtype.as_c_float_p(recon3),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']),
            dtype.as_c_int(axis1),
            dtype.as_c_int(axis2))
Пример #5
0
def c_sample(mode, arr, dx, dy, dz, level, axis, out):
    LIB_TOMOPY.sample.restype = dtype.as_c_void_p()
    LIB_TOMOPY.sample(
        dtype.as_c_int(mode),
        dtype.as_c_float_p(arr),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_int(level),
        dtype.as_c_int(axis),
        dtype.as_c_float_p(out))
    return out
Пример #6
0
def c_gridrec(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.gridrec.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.gridrec(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                              dtype.as_c_int(dt), dtype.as_c_int(dx),
                              dtype.as_c_float_p(center),
                              dtype.as_c_float_p(theta),
                              dtype.as_c_float_p(recon),
                              dtype.as_c_int(kwargs['num_gridx']),
                              dtype.as_c_int(kwargs['num_gridy']),
                              dtype.as_c_char_p(kwargs['filter_name']),
                              dtype.as_c_float_p(kwargs['filter_par']))
Пример #7
0
def c_pml_hybrid(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.pml_hybrid.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.pml_hybrid(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                                 dtype.as_c_int(dt), dtype.as_c_int(dx),
                                 dtype.as_c_float_p(center),
                                 dtype.as_c_float_p(theta),
                                 dtype.as_c_float_p(recon),
                                 dtype.as_c_int(kwargs['num_gridx']),
                                 dtype.as_c_int(kwargs['num_gridy']),
                                 dtype.as_c_int(kwargs['num_iter']),
                                 dtype.as_c_float_p(kwargs['reg_par']))
Пример #8
0
def c_vector(tomo, center, recon1, recon2, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.vector.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.vector(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                             dtype.as_c_int(dt), dtype.as_c_int(dx),
                             dtype.as_c_float_p(center),
                             dtype.as_c_float_p(theta),
                             dtype.as_c_float_p(recon1),
                             dtype.as_c_float_p(recon2),
                             dtype.as_c_int(kwargs['num_gridx']),
                             dtype.as_c_int(kwargs['num_gridy']),
                             dtype.as_c_int(kwargs['num_iter']))
Пример #9
0
def c_project(ox, oy, oz, theta, center, dx, dy, dz, istart, iend):
    obj = mproc.SHARED_OBJ
    tomo = mproc.SHARED_ARRAY

    LIB_TOMOPY.project.restype = dtype.as_c_void_p()
    LIB_TOMOPY.project(
        dtype.as_c_float_p(obj),
        dtype.as_c_int(ox),
        dtype.as_c_int(oy),
        dtype.as_c_int(oz),
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
Пример #10
0
def c_pml_hybrid(args):
    data=args[0]
    recon=args[6]
    # Call C function.
    c_float_p = ctypes.POINTER(ctypes.c_float)
    librecon_phi.pml_hybrid.restype = ctypes.POINTER(ctypes.c_void_p)
    librecon_phi.pml_hybrid(data.ctypes.data_as(c_float_p),
        dtype.as_c_int(args[1]),  # dx
        dtype.as_c_int(args[2]),  # dy
        dtype.as_c_int(args[3]),  # dz
        dtype.as_c_float_p(args[4]),  # center
        dtype.as_c_float_p(args[5]),  # theta
        recon.ctypes.data_as(c_float_p),
        dtype.as_c_int(args[7]['num_gridx']),
        dtype.as_c_int(args[7]['num_gridy']),
        dtype.as_c_int(args[7]['num_iter']),
        dtype.as_c_float_p(args[7]['reg_par']))
    return recon
Пример #11
0
def c_sirt(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.sirt.restype = dtype.as_c_void_p()
    LIB_TOMOPY.sirt(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]['num_gridx']),
        dtype.as_c_int(args[5]['num_gridy']),
        dtype.as_c_int(args[5]['num_iter']),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]))  # iend
Пример #12
0
def c_pml_hybrid(args):
    data=args[0]
    recon=args[6]
    # Call C function.
    c_float_p = ctypes.POINTER(ctypes.c_float)
    librecon_phi.pml_hybrid.restype = ctypes.POINTER(ctypes.c_void_p)
    librecon_phi.pml_hybrid(data.ctypes.data_as(c_float_p),
        dtype.as_c_int(args[1]),  # dx
        dtype.as_c_int(args[2]),  # dy
        dtype.as_c_int(args[3]),  # dz
        dtype.as_c_float_p(args[4]),  # center
        dtype.as_c_float_p(args[5]),  # theta
        recon.ctypes.data_as(c_float_p),
        dtype.as_c_int(args[7]['num_gridx']),
        dtype.as_c_int(args[7]['num_gridy']),
        dtype.as_c_int(args[7]['num_iter']),
        dtype.as_c_float_p(args[7]['reg_par']))
    return recon
Пример #13
0
def c_bart(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.bart.restype = dtype.as_c_void_p()
    return (LIB_TOMOPY.bart, dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
            dtype.as_c_int(dt), dtype.as_c_int(dx), dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta), dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']),
            dtype.as_c_int(kwargs['num_block']),
            dtype.as_c_float_p(kwargs['ind_block'])
            )  #TODO: I think this should be int_p
Пример #14
0
def c_sirt(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.sirt.restype = dtype.as_c_void_p()
    LIB_TOMOPY.sirt(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]['num_gridx']),
        dtype.as_c_int(args[5]['num_gridy']),
        dtype.as_c_int(args[5]['num_iter']),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]))  # iend
Пример #15
0
def c_project(ox, oy, oz, theta, center, dx, dy, dz, istart, iend):
    obj = mproc.SHARED_OBJ
    tomo = mproc.SHARED_ARRAY

    LIB_TOMOPY.project.restype = dtype.as_c_void_p()
    LIB_TOMOPY.project(
        dtype.as_c_float_p(obj),
        dtype.as_c_int(ox),
        dtype.as_c_int(oy),
        dtype.as_c_int(oz),
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
Пример #16
0
def c_mlem(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.mlem.restype = dtype.as_c_void_p()
    LIB_TOMOPY.mlem(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]["num_gridx"]),
        dtype.as_c_int(args[5]["num_gridy"]),
        dtype.as_c_int(args[5]["num_iter"]),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]),
    )  # iend
Пример #17
0
def c_osem(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY_RECON.osem.restype = dtype.as_c_void_p()
    return LIB_TOMOPY_RECON.osem(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                                 dtype.as_c_int(dt), dtype.as_c_int(dx),
                                 dtype.as_c_float_p(center),
                                 dtype.as_c_float_p(theta),
                                 dtype.as_c_float_p(recon),
                                 dtype.as_c_int(kwargs['num_gridx']),
                                 dtype.as_c_int(kwargs['num_gridy']),
                                 dtype.as_c_int(kwargs['num_iter']),
                                 dtype.as_c_int(kwargs['num_block']),
                                 dtype.as_c_int_p(kwargs['ind_block']))
Пример #18
0
def c_normalize_bg(tomo, air):
    dt, dy, dx = tomo.shape

    LIB_TOMOPY.normalize_bg.restype = dtype.as_c_void_p()
    LIB_TOMOPY.normalize_bg(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dt),
        dtype.as_c_int(dy),
        dtype.as_c_int(dx),
        dtype.as_c_int(air))
Пример #19
0
def c_gridrec(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.gridrec.restype = dtype.as_c_void_p()
    LIB_TOMOPY.gridrec(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]["num_gridx"]),
        dtype.as_c_int(args[5]["num_gridy"]),
        dtype.as_c_char_p(args[5]["filter_name"]),
        dtype.as_c_float_p(args[5]["filter_par"]),  # filter_par
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]),
    )  # iend
Пример #20
0
def c_art(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.art.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.art(
            dtype.as_c_float_p(tomo),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta),
            dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']))
Пример #21
0
def c_remove_stripe_sf(dx, dy, dz, size, istart, iend):
    tomo = mproc.SHARED_ARRAY

    LIB_TOMOPY.remove_stripe_sf.restype = dtype.as_c_void_p()
    LIB_TOMOPY.remove_stripe_sf(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_int(size),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
Пример #22
0
def c_normalize_bg(dx, dy, dz, air, istart, iend):
    tomo = mproc.SHARED_ARRAY

    LIB_TOMOPY.normalize_bg.restype = dtype.as_c_void_p()
    LIB_TOMOPY.normalize_bg(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_int(air),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
Пример #23
0
def c_fbp(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.fbp.restype = dtype.as_c_void_p()
    LIB_TOMOPY.fbp(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_float_p(recon),
        dtype.as_c_int(kwargs['num_gridx']),
        dtype.as_c_int(kwargs['num_gridy']),
        dtype.as_c_char_p(kwargs['filter_name']),
        dtype.as_c_float_p(kwargs['filter_par'])) # filter_par
Пример #24
0
def c_project(obj, center, tomo, theta):
    if len(obj.shape) == 2:
        # no y-axis (only one slice)
        oy = 1
        ox, oz = obj.shape
    else:
        oy, ox, oz = obj.shape

    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.project.restype = dtype.as_c_void_p()
    LIB_TOMOPY.project(dtype.as_c_float_p(obj), dtype.as_c_int(oy),
                       dtype.as_c_int(ox), dtype.as_c_int(oz),
                       dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                       dtype.as_c_int(dt), dtype.as_c_int(dx),
                       dtype.as_c_float_p(center), dtype.as_c_float_p(theta))
Пример #25
0
def c_normalize_bg(dx, dy, dz, air, istart, iend):
    tomo = mproc.SHARED_ARRAY

    LIB_TOMOPY.normalize_bg.restype = dtype.as_c_void_p()
    LIB_TOMOPY.normalize_bg(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_int(air),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
Пример #26
0
def c_project3(objx, objy, objz, center, tomo, theta, axis):
    # TODO: we should fix this elsewhere...
    # TOMO object must be contiguous for c function to work

    contiguous_tomo = np.require(tomo, requirements="AC")
    if len(objx.shape) == 2:
        # no y-axis (only one slice)
        oy = 1
        ox, oz = objx.shape
    else:
        oy, ox, oz = objx.shape

    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY_RECON.project3.restype = dtype.as_c_void_p()
    LIB_TOMOPY_RECON.project3(
        dtype.as_c_float_p(objx),
        dtype.as_c_float_p(objy),
        dtype.as_c_float_p(objz),
        dtype.as_c_int(oy),
        dtype.as_c_int(ox),
        dtype.as_c_int(oz),
        dtype.as_c_float_p(contiguous_tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_int(axis))
    tomo[:] = contiguous_tomo[:]
Пример #27
0
def c_osem(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.osem.restype = dtype.as_c_void_p()
    LIB_TOMOPY.osem(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_float_p(recon),
        dtype.as_c_int(kwargs['num_gridx']),
        dtype.as_c_int(kwargs['num_gridy']),
        dtype.as_c_int(kwargs['num_iter']),
        dtype.as_c_int(kwargs['num_block']),
        dtype.as_c_float_p(kwargs['ind_block'])) #TODO: should be int?
Пример #28
0
def c_remove_stripe_sf(tomo, size):
    # TODO: we should fix this elsewhere...
    # TOMO object must be contiguous for c function to work
    contiguous_tomo = np.require(tomo, requirements="AC")
    dx, dy, dz = tomo.shape
    istart = 0
    iend = dy

    LIB_TOMOPY.remove_stripe_sf.restype = dtype.as_c_void_p()
    LIB_TOMOPY.remove_stripe_sf(dtype.as_c_float_p(contiguous_tomo),
                                dtype.as_c_int(dx), dtype.as_c_int(dy),
                                dtype.as_c_int(dz), dtype.as_c_int(size),
                                dtype.as_c_int(istart), dtype.as_c_int(iend))
    tomo[:] = contiguous_tomo[:]
Пример #29
0
def c_remove_ring(*args):
    data = mproc.SHARED_ARRAY

    LIB_TOMOPY.remove_ring.restype = dtype.as_c_void_p()
    LIB_TOMOPY.remove_ring(
        dtype.as_c_float_p(data),
        dtype.as_c_float(args[0]),  # center_x
        dtype.as_c_float(args[1]),  # center_y
        dtype.as_c_int(args[2]),  # dx
        dtype.as_c_int(args[3]),  # dy
        dtype.as_c_int(args[4]),  # dz
        dtype.as_c_float(args[5]),  # thresh_max
        dtype.as_c_float(args[6]),  # thresh_min
        dtype.as_c_float(args[7]),  # thresh
        dtype.as_c_int(args[8]),  # theta_min
        dtype.as_c_int(args[9]),  # rwidth
        dtype.as_c_int(args[10]),  # istart
        dtype.as_c_int(args[11]))  # iend
Пример #30
0
def c_remove_ring(rec, *args):
    istart = 0
    iend = rec.shape[0]
    LIB_TOMOPY.remove_ring.restype = dtype.as_c_void_p()
    LIB_TOMOPY.remove_ring(
        dtype.as_c_float_p(rec),
        dtype.as_c_float(args[0]),  # center_x
        dtype.as_c_float(args[1]),  # center_y
        dtype.as_c_int(args[2]),  # dx
        dtype.as_c_int(args[3]),  # dy
        dtype.as_c_int(args[4]),  # dz
        dtype.as_c_float(args[5]),  # thresh_max
        dtype.as_c_float(args[6]),  # thresh_min
        dtype.as_c_float(args[7]),  # thresh
        dtype.as_c_int(args[8]),  # theta_min
        dtype.as_c_int(args[9]),  # rwidth
        dtype.as_c_int(istart),  # istart
        dtype.as_c_int(iend))  # iend
Пример #31
0
def c_remove_ring(rec, *args):
    istart = 0
    iend = rec.shape[0]
    LIB_TOMOPY.remove_ring.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.remove_ring(
            dtype.as_c_float_p(rec),
            dtype.as_c_float(args[0]),  # center_x
            dtype.as_c_float(args[1]),  # center_y
            dtype.as_c_int(args[2]),  # dx
            dtype.as_c_int(args[3]),  # dy
            dtype.as_c_int(args[4]),  # dz
            dtype.as_c_float(args[5]),  # thresh_max
            dtype.as_c_float(args[6]),  # thresh_min
            dtype.as_c_float(args[7]),  # thresh
            dtype.as_c_int(args[8]),  # theta_min
            dtype.as_c_int(args[9]),  # rwidth
            dtype.as_c_int(istart),  # istart
            dtype.as_c_int(iend))  # iend
Пример #32
0
def c_remove_stripe_sf(tomo, size):
    # TODO: we should fix this elsewhere...
    # TOMO object must be contiguous for c function to work
    contiguous_tomo = np.require(tomo, requirements="AC")
    dx, dy, dz = tomo.shape
    istart = 0
    iend = dy

    LIB_TOMOPY.remove_stripe_sf.restype = dtype.as_c_void_p()
    LIB_TOMOPY.remove_stripe_sf(
        dtype.as_c_float_p(contiguous_tomo),
        dtype.as_c_int(dx),
        dtype.as_c_int(dy),
        dtype.as_c_int(dz),
        dtype.as_c_int(size),
        dtype.as_c_int(istart),
        dtype.as_c_int(iend))
    tomo[:] = contiguous_tomo[:]
Пример #33
0
def c_vector2(tomo1, tomo2, center1, center2, recon1, recon2, recon3, theta1,
              theta2, axis1, axis2, **kwargs):
    if len(tomo1.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo1.shape
    else:
        dy, dt, dx = tomo1.shape

    LIB_TOMOPY.vector2.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.vector2(dtype.as_c_float_p(tomo1),
                              dtype.as_c_float_p(tomo2), dtype.as_c_int(dy),
                              dtype.as_c_int(dt), dtype.as_c_int(dx),
                              dtype.as_c_float_p(center1),
                              dtype.as_c_float_p(center2),
                              dtype.as_c_float_p(theta1),
                              dtype.as_c_float_p(theta2),
                              dtype.as_c_float_p(recon1),
                              dtype.as_c_float_p(recon2),
                              dtype.as_c_float_p(recon3),
                              dtype.as_c_int(kwargs['num_gridx']),
                              dtype.as_c_int(kwargs['num_gridy']),
                              dtype.as_c_int(kwargs['num_iter']),
                              dtype.as_c_int(axis1), dtype.as_c_int(axis2))
Пример #34
0
def c_sirt(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    use_accel = 1 if kwargs['accelerated'] else 0

    if use_accel:
        return LIB_TOMOPY_ACCEL.cxx_sirt(
            dtype.as_c_float_p(tomo),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta),
            dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']),
            dtype.as_c_int(kwargs['pool_size']),
            dtype.as_c_char_p(kwargs['interpolation']),
            dtype.as_c_char_p(kwargs['device']),
            dtype.as_c_int_p(kwargs['grid_size']),
            dtype.as_c_int_p(kwargs['block_size']))
    else:
        LIB_TOMOPY_RECON.sirt.restype = dtype.as_c_void_p()
        return LIB_TOMOPY_RECON.sirt(
            dtype.as_c_float_p(tomo),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta),
            dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']))
Пример #35
0
def c_ospml_quad(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY.ospml_quad.restype = dtype.as_c_void_p()
    LIB_TOMOPY.ospml_quad(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                          dtype.as_c_int(dt), dtype.as_c_int(dx),
                          dtype.as_c_float_p(center),
                          dtype.as_c_float_p(theta), dtype.as_c_float_p(recon),
                          dtype.as_c_int(kwargs['num_gridx']),
                          dtype.as_c_int(kwargs['num_gridy']),
                          dtype.as_c_int(kwargs['num_iter']),
                          dtype.as_c_float_p(kwargs['reg_par']),
                          dtype.as_c_int(kwargs['num_block']),
                          dtype.as_c_float_p(
                              kwargs['ind_block']))  #TODO: should be int?
Пример #36
0
def c_ospml_quad(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.ospml_quad.restype = dtype.as_c_void_p()
    LIB_TOMOPY.ospml_quad(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]['num_gridx']),
        dtype.as_c_int(args[5]['num_gridy']),
        dtype.as_c_int(args[5]['num_iter']),
        dtype.as_c_float_p(args[5]['reg_par']),
        dtype.as_c_int(args[5]['num_block']),
        dtype.as_c_float_p(args[5]['ind_block']),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]))  # iend
Пример #37
0
def c_ospml_quad(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.ospml_quad.restype = dtype.as_c_void_p()
    LIB_TOMOPY.ospml_quad(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]['num_gridx']),
        dtype.as_c_int(args[5]['num_gridy']),
        dtype.as_c_int(args[5]['num_iter']),
        dtype.as_c_float_p(args[5]['reg_par']),
        dtype.as_c_int(args[5]['num_block']),
        dtype.as_c_float_p(args[5]['ind_block']),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]))  # iend
Пример #38
0
def c_ospml_hybrid(*args):
    tomo = mproc.SHARED_TOMO
    recon = mproc.SHARED_ARRAY

    LIB_TOMOPY.ospml_hybrid.restype = dtype.as_c_void_p()
    LIB_TOMOPY.ospml_hybrid(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(args[0]),  # dx
        dtype.as_c_int(args[1]),  # dy
        dtype.as_c_int(args[2]),  # dz
        dtype.as_c_float_p(args[3]),  # center
        dtype.as_c_float_p(args[4]),  # theta
        dtype.as_c_float_p(recon),
        dtype.as_c_int(args[5]["num_gridx"]),
        dtype.as_c_int(args[5]["num_gridy"]),
        dtype.as_c_int(args[5]["num_iter"]),
        dtype.as_c_float_p(args[5]["reg_par"]),
        dtype.as_c_int(args[5]["num_block"]),
        dtype.as_c_float_p(args[5]["ind_block"]),
        dtype.as_c_int(args[6]),  # istart
        dtype.as_c_int(args[7]),
    )  # iend