Beispiel #1
0
def _get_algorithm_kwargs(shape):
    dy, dt, dx = shape
    return {
        'num_gridx': dx,
        'num_gridy': dx,
        'filter_name': 'shepp',
        'filter_par': np.array([0.5, 8], dtype='float32'),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block':
        np.arange(0, dt, dtype=np.float32),  # TODO: I think this should be int
        'options': {},
        'accelerated': False,
        'pool_size':
        0,  # if zero, calculate based on threads started at Python level
        'interpolation':
        'NN',  # interpolation method (NN = nearest-neighbor, LINEAR, CUBIC)
        'device': 'gpu',
        'grid_size': np.array(
            [0, 0, 0],
            dtype='int32'),  # CUDA grid size. If zero, dynamically computed
        'block_size': np.array([32, 32, 1],
                               dtype='int32'),  # CUDA threads per block
    }
Beispiel #2
0
def _get_algorithm_kwargs(shape):
    dx, dy, dz = shape
    return {
        'num_gridx': dz,
        'num_gridy': dz,
        'filter_name': np.array('shepp', dtype=(str, 16)),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block': np.arange(0, dx, dtype='float32'),
    }
Beispiel #3
0
def _get_algorithm_kwargs(shape):
    dx, dy, dz = shape
    return {
        'num_gridx': dz,
        'num_gridy': dz,
        'filter_name': np.array('shepp', dtype=(str, 16)),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block': np.arange(0, dx, dtype='float32'),
        'options': {},
    }
Beispiel #4
0
def _get_algorithm_kwargs(shape):
    dy, dt, dx = shape
    return {
        'num_gridx': dx,
        'num_gridy': dx,
        'filter_name': np.array('shepp', dtype=(str, 16)),
        'filter_par': np.array([0.5, 8], dtype='float32'),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block': np.arange(0, dt, dtype=np.float32), #TODO: I think this should be int
        'options': {},
    }
Beispiel #5
0
def _get_algorithm_kwargs(shape):
    dy, dt, dx = shape
    return {
        "num_gridx": dx,
        "num_gridy": dx,
        "filter_name": "shepp",
        "filter_par": np.array([0.5, 8], dtype="float32"),
        "num_iter": dtype.as_int32(1),
        "reg_par": np.ones(10, dtype="float32"),
        "num_block": dtype.as_int32(1),
        "ind_block": np.arange(0, dt, dtype=np.float32),  # TODO: I think this should be int
        "options": {},
    }
Beispiel #6
0
def _get_algorithm_kwargs(shape):
    dy, dt, dx = shape
    return {
        'num_gridx': dx,
        'num_gridy': dx,
        'filter_name': 'shepp',
        'filter_par': np.array([0.5, 8], dtype='float32'),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block': np.arange(0, dt, dtype=np.float32), #TODO: I think this should be int
        'options': {},
    }
Beispiel #7
0
def normalize_bg(tomo, air=1, ncore=None, nchunk=None):
    """
    Normalize 3D tomgraphy data based on background intensity.

    Weight sinogram such that the left and right image boundaries
    (i.e., typically the air region around the object) are set to one
    and all intermediate values are scaled linearly.

    Parameters
    ----------
    tomo : ndarray
        3D tomographic data.
    air : int, optional
        Number of pixels at each boundary to calculate the scaling factor.
    ncore : int, optional
        Number of cores that will be assigned to jobs.
    nchunk : int, optional
        Chunk size for each core.

    Returns
    -------
    ndarray
        Corrected 3D tomographic data.
    """
    tomo = dtype.as_float32(tomo)
    air = dtype.as_int32(air)

    arr = mproc.distribute_jobs(
        tomo,
        func=extern.c_normalize_bg,
        args=(air,),
        axis=0,
        ncore=ncore,
        nchunk=nchunk)
    return arr
Beispiel #8
0
def normalize_bg(tomo, air=1, ncore=None, nchunk=None):
    """
    Normalize 3D tomgraphy data based on background intensity.

    Weight sinogram such that the left and right image boundaries
    (i.e., typically the air region around the object) are set to one
    and all intermediate values are scaled linearly.

    Parameters
    ----------
    tomo : ndarray
        3D tomographic data.
    air : int, optional
        Number of pixels at each boundary to calculate the scaling factor.
    ncore : int, optional
        Number of cores that will be assigned to jobs.
    nchunk : int, optional
        Chunk size for each core.

    Returns
    -------
    ndarray
        Corrected 3D tomographic data.
    """
    tomo = dtype.as_float32(tomo)
    air = dtype.as_int32(air)
    dx, dy, dz = tomo.shape

    arr = mproc.distribute_jobs(tomo,
                                func=extern.c_normalize_bg,
                                args=(dx, dy, dz, air),
                                axis=0,
                                ncore=ncore,
                                nchunk=nchunk)
    return arr
Beispiel #9
0
def _get_algorithm_kwargs(shape):
    dy, dt, dx = shape
    return {
        'num_gridx': dx,
        'num_gridy': dx,
        'filter_name': 'shepp',
        'filter_par': np.array([0.5, 8], dtype='float32'),
        'num_iter': dtype.as_int32(1),
        'reg_par': np.ones(10, dtype='float32'),
        'num_block': dtype.as_int32(1),
        'ind_block': np.arange(0, dt, dtype=np.float32),  # TODO: I think this should be int
        'options': {},
        'accelerated': False,
        'pool_size': 0, # if zero, calculate based on threads started at Python level
        'interpolation': 'NN', # interpolation method (NN = nearest-neighbor, LINEAR, CUBIC)
        'device': 'gpu',
        'grid_size': np.array([0, 0, 0], dtype='int32'), # CUDA grid size. If zero, dynamically computed
        'block_size': np.array([32, 32, 1], dtype='int32'), # CUDA threads per block
    }