Beispiel #1
0
def project2(
        objx, objy, theta, center=None, emission=True, pad=True,
        sinogram_order=False, ncore=None, nchunk=None):
    """
    Project x-rays through a given 3D object.

    Parameters
    ----------
    objx, objy : ndarray
        (x, y) components of vector of a voxelized 3D object.
    theta : array
        Projection angles in radian.
    center: array, optional
        Location of rotation axis.
    emission : bool, optional
        Determines whether output data is emission or transmission type.
    pad : bool, optional
        Determines if the projection image width will be padded or not. If True,
        then the diagonal length of the object cross-section will be used for the
        output size of the projection image width.
    sinogram_order: bool, optional
        Determines whether output data is a stack of sinograms (True, y-axis first axis)
        or a stack of radiographs (False, theta first axis).
    ncore : int, optional
        Number of cores that will be assigned to jobs.
    nchunk : int, optional
        Chunk size for each core.

    Returns
    -------
    ndarray
        3D tomographic data.
    """
    objx = dtype.as_float32(objx)
    objy = dtype.as_float32(objy)
    theta = dtype.as_float32(theta)

    # Estimate data dimensions.
    oy, ox, oz = objx.shape
    dt = theta.size
    dy = oy
    if pad is True:
        dx = _round_to_even(np.sqrt(ox * ox + oz * oz) + 2)
    elif pad is False:
        dx = ox
    shape = dy, dt, dx
    tomo = dtype.empty_shared_array(shape)
    tomo[:] = 0.0
    center = get_center(shape, center)

    extern.c_project2(objx, objy, center, tomo, theta)

    # NOTE: returns sinogram order with emmission=True
    if not emission:
        # convert data to be transmission type
        np.exp(-tomo, tomo)
    if not sinogram_order:
        # rotate to radiograph order
        tomo = np.swapaxes(tomo, 0, 1)  # doesn't copy data
        # copy data to sharedmem
        tomo = dtype.as_sharedmem(tomo, copy=True)

    return tomo
Beispiel #2
0
def project2(objx,
             objy,
             theta,
             center=None,
             emission=True,
             pad=True,
             sinogram_order=False,
             axis=0,
             ncore=None,
             nchunk=None):
    """
    Project x-rays through a given 3D object.

    Parameters
    ----------
    objx : ndarray
        (x, y) components of vector of a voxelized 3D object.
    theta : array
        Projection angles in radian.
    center: array, optional
        Location of rotation axis.
    emission : bool, optional
        Determines whether output data is emission or transmission type.
    pad : bool, optional
        Determines if the projection image width will be padded or not. If True,
        then the diagonal length of the object cross-section will be used for the
        output size of the projection image width.
    sinogram_order: bool, optional
        Determines whether output data is a stack of sinograms (True, y-axis first axis)
        or a stack of radiographs (False, theta first axis).
    ncore : int, optional
        Number of cores that will be assigned to jobs.
    nchunk : int, optional
        Chunk size for each core.

    Returns
    -------
    ndarray
        3D tomographic data.
    """
    objx = dtype.as_float32(objx)
    objy = dtype.as_float32(objy)
    theta = dtype.as_float32(theta)

    # Estimate data dimensions.
    oy, ox, oz = objx.shape
    dt = theta.size
    dy = oy
    if pad is True:
        dx = _round_to_even(np.sqrt(ox * ox + oz * oz) + 2)
    elif pad is False:
        dx = ox
    shape = dy, dt, dx
    tomo = dtype.empty_shared_array(shape)
    tomo[:] = 0.0
    center = get_center(shape, center)

    extern.c_project2(objx, objy, center, tomo, theta)

    # NOTE: returns sinogram order with emmission=True
    if not emission:
        # convert data to be transmission type
        np.exp(-tomo, tomo)
    if not sinogram_order:
        # rotate to radiograph order
        tomo = np.swapaxes(tomo, 0, 1)  # doesn't copy data
        # copy data to sharedmem
        tomo = dtype.as_sharedmem(tomo, copy=True)

    return tomo