scico.examples¶
Utility functions used by example scripts.
Functions
|
Construct a 3D phantom with random radii and centers. |
|
Construct a circular phantom with given radii and intensities. |
|
Compute a 2D map of the distance from a center pixel. |
|
Construct a disc dictionary and sparse coefficient maps. |
|
Construct a volume phantom. |
|
Downsample a 3D array. |
|
Get deconvolution problem data from EPFL Biomedical Imaging Group. |
|
Construct a multivariate Gaussian distribution function. |
|
Download example data from EPFL Biomedical Imaging Group. |
|
Download data from UC Berkeley Waller Lab diffusercam project. |
|
Distance between phase angles. |
|
Convert an RGB image (or images) to grayscale. |
|
Return image with salt & pepper noise imposed on it. |
|
Make an image with tiled slices from an input volume. |
|
Get example data from UC Berkeley Waller Lab diffusercam project. |
|
Read a 3D volume from a set of files in the specified directory. |
- scico.examples.volume_read(path, ext='tif')[source]¶
Read a 3D volume from a set of files in the specified directory.
All files with extension ext (i.e. matching glob *.ext) in directory path are assumed to be image files and are read. The filenames are assumed to be such that their alphanumeric ordering corresponds to their order as volume slices.
- scico.examples.get_epfl_deconv_data(channel, path, verbose=False)[source]¶
Download example data from EPFL Biomedical Imaging Group.
Download deconvolution problem data from EPFL Biomedical Imaging Group. The downloaded data is converted to .npz format for convenient access via
numpy.load
. The converted data is saved in a file epfl_big_deconv_<channel>.npz in the directory specified by path.
- scico.examples.epfl_deconv_data(channel, verbose=False, cache_path=None)[source]¶
Get deconvolution problem data from EPFL Biomedical Imaging Group.
If the data has previously been downloaded, it will be retrieved from a local cache.
- Parameters:
- Return type:
- Returns:
tuple –
A tuple (y, psf) containing:
y : (np.ndarray): Blurred channel data.
psf : (np.ndarray): Channel psf.
- scico.examples.get_ucb_diffusercam_data(path, verbose=False)[source]¶
Download data from UC Berkeley Waller Lab diffusercam project.
Download deconvolution problem data from UC Berkeley Waller Lab diffusercam project. The downloaded data is converted to .npz format for convenient access via
numpy.load
. The converted data is saved in a file ucb_diffcam_data.npz.npz in the directory specified by path.
- scico.examples.ucb_diffusercam_data(verbose=False, cache_path=None)[source]¶
Get example data from UC Berkeley Waller Lab diffusercam project.
If the data has previously been downloaded, it will be retrieved from a local cache.
- Parameters:
- Return type:
- Returns:
tuple –
A tuple (y, psf) containing:
y : (np.ndarray): Measured image
psf : (np.ndarray): Stack of psfs.
- scico.examples.downsample_volume(vol, rate)[source]¶
Downsample a 3D array.
Downsample a 3D array. If the volume dimensions can be divided by rate, this is achieved via averaging distinct rate x rate x rate block in vol. Otherwise it is achieved via a call to
scipy.ndimage.zoom
.
- scico.examples.tile_volume_slices(x, sep_width=10)[source]¶
Make an image with tiled slices from an input volume.
Make an image with tiled xy, xz, and yz slices from an input volume.
- scico.examples.create_cone(img_shape, center=None)[source]¶
Compute a 2D map of the distance from a center pixel.
- scico.examples.gaussian(shape, sigma=None)[source]¶
Construct a multivariate Gaussian distribution function.
Construct a zero-mean multivariate Gaussian distribution function
\[f(\mb{x}) = (2 \pi)^{-N/2} \, \det(\Sigma)^{-1/2} \, \exp \left( -\frac{\mb{x}^T \, \Sigma^{-1} \, \mb{x}}{2} \right) \;,\]where \(\Sigma\) is the covariance matrix of the distribution.
- scico.examples.create_circular_phantom(img_shape, radius_list, val_list, center=None)[source]¶
Construct a circular phantom with given radii and intensities.
- Parameters:
img_shape (
Tuple
[int
,...
]) – Shape of the phantom to be created.radius_list (
list
) – List of radii of the rings in the phantom.val_list (
list
) – List of intensity values of the rings in the phantom.center (
Optional
[list
]) – Tuple of center pixel coordinates. IfNone
, this is set to the center of the image.
- Return type:
- Returns:
The computed circular phantom.
- scico.examples.create_3d_foam_phantom(im_shape, N_sphere, r_mean=0.1, r_std=0.001, pad=0.01, is_random=False)[source]¶
Construct a 3D phantom with random radii and centers.
- Parameters:
N_sphere (
int
) – Number of spheres added.r_mean (
float
) – Mean radius of sphere (normalized to 1 along each axis). Default 0.1.r_std (
float
) – Standard deviation of radius of sphere (normalized to 1 along each axis). Default 0.001.pad (
float
) – Padding length (normalized to 1 along each axis). Default 0.01.is_random (
bool
) – Flag used to control randomness of phantom generation. IfFalse
, random seed is set to 1 in order to make the process deterministic. DefaultFalse
.
- Return type:
- Returns:
3D phantom of shape im_shape.
- scico.examples.create_conv_sparse_phantom(Nx, Nnz)[source]¶
Construct a disc dictionary and sparse coefficient maps.
Construct a disc dictionary and a corresponding set of sparse coefficient maps for testing convolutional sparse coding algorithms.
- scico.examples.spnoise(img, nfrac, nmin=0.0, nmax=1.0)[source]¶
Return image with salt & pepper noise imposed on it.