plenoptomos package

Subpackages

Submodules

plenoptomos.colors module

Convenience functions for handling multi-channel datasets. They mainly focus on visible light (RGB channels).

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Tue Apr 4 16:01:41 2017

plenoptomos.colors.convert_energy_to_wavelength(energy, unit_energy='eV', unit_lambda='um')[source]
plenoptomos.colors.deal_with_channels(img, mode='grayscale', rgb2gs_mode='luma')[source]
plenoptomos.colors.detect_color(camera, tol=0.01)[source]
plenoptomos.colors.from_rgb_to_grayscale(img, mode='luma')[source]
plenoptomos.colors.get_rgb_wavelengths()[source]
plenoptomos.colors.merge_rgb_images(imgs_r, imgs_g, imgs_b, vmin=0.0, vmax=1.0)[source]
plenoptomos.colors.merge_rgb_lightfields(lf_r, lf_g, lf_b, mode='luma')[source]

plenoptomos.data_format module

This module implements the handling of the .vox data format. It exposes routines that allow to create, calibrate and read vox files.

Convetions: - arrays are understood in the C convention

Rationale behind version 0: - Single light-field per file - Contains all the necessary metadata for interpretation of the light-field - Based on [HDF5](https://www.hdfgroup.org/solutions/hdf5/) and vaguely inspired by [DataExchange](https://github.com/data-exchange/dxchange)

The updated structure can be found at: https://cicwi.github.io/plenoptomos

@author: Nicola Vigano, Charlotte Herzog, Pablo Martinez

Created on Tue Nov 21 23:50:47 2017

plenoptomos.data_format.calibrate_raw_image(vox_file_in, vox_file_out=None, pitch=None, offset=None)[source]

Calibrate the array offsets and lenslet pitch for a .vox light-field file

Parameters
  • vox_file_in – the uncalibrated light-field file path (string)

  • vox_file_out – the calibrated light-field file path (string)

  • pitch – OPTIONAL lenslet pitch, that would otherwise be calibrated (<2x1> list or tuple, default: None)

  • offset – OPTIONAL MLA offset, that would otherwise be calibrated (<2x1> list or tuple, default: None)

plenoptomos.data_format.create_vox_from_dict(data, config, out_file, white=None, dark=None, mask=None)[source]

Creates a .vox light-field file, from a raw detector image and a dictionary containing metadata.

Parameters
  • data – the raw image (numpy.array_like)

  • config – the dictionary containing metadata (numpy.array_like)

  • out_file – the uncalibrated light-field file path (string)

  • white – the flat-field image (numpy.array_like, default: None)

  • dark – the dark-field image (numpy.array_like, default: None)

  • mask – the light-field mask image (numpy.array_like, default: None)

plenoptomos.data_format.create_vox_from_lf(lf: plenoptomos.lightfield.Lightfield, out_file)[source]

Creates a .vox light-field file, from the light-field data class.

Parameters
  • lf – the light-field data class (lightfield.LightField)

  • out_file – the uncalibrated light-field file path (string)

plenoptomos.data_format.create_vox_from_raw(raw_det_file, conf_file, out_file=None, raw_det_white=None, raw_det_dark=None, raw_det_mask=None)[source]

Creates a .vox light-field file, from a raw detector image and metadata.

Parameters
  • raw_det_file – the raw image file path (string)

  • conf_file – the metadata file path (string)

  • out_file – the uncalibrated light-field file path (string)

  • raw_det_white – the flat-field image file path (string, default: None)

  • raw_det_dark – the dark-field image file path (string, default: None)

  • raw_det_mask – the light-field mask image file path (string, default: None)

plenoptomos.data_format.load(vox_file)[source]

Loads a .vox light-field file

Parameters

vox_file – the light-field file path (string)

Returns

the loaded light-field

Return type

light-field.Lightfield

plenoptomos.data_format.raw_to_microimage_exact(data, offsets, pitch)[source]
plenoptomos.data_format.raw_to_microimage_interp(data, offsets, pitch_in, pitch_out, array_size=None)[source]
plenoptomos.data_format.transform_2D_to_4D(data, out_shape_tsvu)[source]

plenoptomos.depth module

This module implements the depth estimation routines, that allow to compute depth-maps from light-fields.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Mar 29 12:34:36 2017

plenoptomos.depth.compute_depth_cues(lf: plenoptomos.lightfield.Lightfield, zs, compute_defocus=True, compute_correspondence=True, compute_xcorrelation=False, beam_geometry='parallel', domain='object', psf=None, up_sampling=1, super_sampling=1, algorithm='bpj', iterations=5, confidence_method='integral', quadratic_refinement=True, window_size=(9, 9), window_shape='gauss', mask=None, plot_filter=False)[source]

Computes depth cues, needed to create a depth map.

These depth cues are created following the procedure from:

M. W. Tao, et al., “Depth from combining defocus and correspondence using light-field cameras,” in Proceedings of the IEEE International Conference on Computer Vision, 2013, pp. 673–680.

Parameters
  • lf (lightfield.Lightfield) – The light-field object

  • zs (numpy.array_like) – Refocusing distances

  • compute_defocus (boolean, optional) – Enable defocus cues, defaults to True

  • compute_correspondence (boolean, optional) – Enable corresponence cues, defaults to True

  • compute_xcorrelation (boolean, optional) – Enable cross-correlation cues, defaults to False

  • beam_geometry (str, optional) – Beam geometry. Options: ‘parallel’ | ‘cone’, defaults to ‘parallel’

  • domain (str, optional) – Refocusing domain. Options: ‘object’ | ‘image’, defaults to ‘object’

  • psf (psf.PSFApply, optional) – Refocusing PSF, defaults to None

  • up_sampling (int, optional) – Integer greater than 1 for up-sampling of the final images, defaults to 1

  • super_sampling (int, optional) – Integer equal or greater than 1, for higer sampling density of the final images, defaults to 1

  • algorithm (str, optional) – Refocusing algorithm to use for the construction of the focal stack, defaults to ‘bpj’

  • iterations (int, optional) – Number of refocusing iterations, defaults to 5

  • confidence_method (str, optional) – Confidence computation method, defaults to ‘integral’, options: ‘integral’ | ‘2nd_peak’

  • quadratic_refinement (boolean, optional) – Use quadratic fit, to refine depth estimation, defaults to True

  • window_size (tuple(int, int), optional) – Filtering window size, defaults to (9, 9)

  • window_shape (str, optional) – Filtering window shape. Options: ‘tri’ | ‘circ’ | ‘gauss’ | ‘rect’, defaults to ‘circ’

  • mask (numpy.array_like, optional) – Light-field data mask, defaults to None

  • plot_filter (boolean, optional) – Plot the used smoothing filter, defaults to False

Raises

ValueError – In case of unknown algorithm or confidence_method

Returns

Depth cues and their confidences.

Return type

dict

plenoptomos.depth.compute_depth_map(depth_cues, iterations=500, lambda_tv=2.0, lambda_d2=0.05, lambda_wl=None, use_defocus=1.0, use_correspondence=1.0, use_xcorrelation=0.0)[source]

Computes a depth map from the given depth cues.

This depth map is based on the procedure from:

M. W. Tao, et al., “Depth from combining defocus and correspondence using light-field cameras,” in Proceedings of the IEEE International Conference on Computer Vision, 2013, pp. 673–680.

Parameters
  • depth_cues (dict) – The depth cues

  • iterations (int, optional) – Number of iterations, defaults to 500

  • lambda_tv (float, optional) – Lambda value of the TV term, defaults to 2.0

  • lambda_d2 (float, optional) – Lambda value of the smoothing term, defaults to 0.05

  • lambda_wl (float, optional) – Lambda value of the wavelet term, defaults to None

  • use_defocus (float, optional) – Weight of defocus cues, defaults to 1.0

  • use_correspondence (float, optional) – Weight of corresponence cues, defaults to 1.0

  • use_xcorrelation (float, optional) – Weight of the cross-correlation cues, defaults to 0.0

Raises

ValueError – In case of requested wavelet regularization but not available

Returns

The depth map

Return type

numpy.array_like

plenoptomos.depth.get_distances(dm, zs)[source]

Convert depth map indices into distances

Parameters
  • dm (numpy.array_like) – the depth map

  • zs (numpy.array_like) – the corresponding distances in the depth map

Returns

the depth-map containing the real distances

Return type

numpy.array_like

plenoptomos.import_lf module

This module contains the import functions for external light-field data formats.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Mon Feb 18 16:08:43 2019

plenoptomos.import_lf.from_flexray(dset_path, crop_fixed_det=True, normalize_flats=False, plot_lf=False, data_type=<class 'numpy.float32'>)[source]

Imports light-fields from FleXray scanner data.

Parameters
  • dset_path (string) – Directory of the sub-aperture images (containing a .ini file)

  • crop_fixed_det (boolean, optional) – Crops the images, in case of fixed detector acquisitions, defaults to True

  • normalize_flats (boolean, optional) – Renormalizes the flats to same total intensity, defaults to False

  • plot_lf (boolean, optional) – Displays the loaded light-field, defaults to False

  • data_type (numpy.dtype, optional) – Datatype of the output light-field data, defaults to np.float32

Returns

The imported light-field datastructure

Return type

lightfield.Lightfield

plenoptomos.import_lf.from_lytro(data_path, fname_json, source='warp', mode='grayscale', rgb2gs_mode='luma', binning=1, data_type=<class 'numpy.float32'>)[source]

Imports either the ESLF or warp image light-fields acquired with Lytro cameras.

Parameters
  • data_path – Either the path of the ESLF file or the directory of the warp images (string)

  • fname_json – Path of the metadata public json file (string)

  • source – Format of the lytro data. Options: {‘warp’}, ‘eslf’ (string)

  • mode – Switch between grayscale and RGB. Options: {‘grayscale’}, ‘rgb’ (string)

  • rgb2gs_mode – RGB -> grayscale conversion method. Options: {‘luma’}, ‘flat’ (string)

  • binning – Binning of the input images, used to reduce their size and resolution (int, default: 1)

  • data_type – Datatype of the output light-field data (np.dtype)

Returns

The imported light-field datastructure

Return type

lightfield.Lightfield

plenoptomos.import_lf.from_stanford_archive(dataset_path, mode='grayscale', rgb2gs_mode='luma', binning=1, data_type=<class 'numpy.float32'>)[source]

Imports light-fields from the Stanford archive.

Parameters
  • dataset_path – Directory of the sub-aperture images (containing a json metadata file) (string)

  • mode – Switch between grayscale and RGB. Options: {‘grayscale’}, ‘rgb’ (string)

  • rgb2gs_mode – RGB -> grayscale conversion method. Options: {‘luma’}, ‘flat’ (string)

  • binning – Binning of the input images, used to reduce their size and resolution (int, default: 1)

  • data_type – Datatype of the output light-field data (np.dtype)

Returns

The imported light-field datastructure

Return type

lightfield.Lightfield

plenoptomos.import_lf.lytro_create_warps(file_path)[source]

Utility function to create warp images using Lytro’s powertools and the corresponding json file

Parameters

file_path – The path to the .lfp file (string)

plenoptomos.import_lf.lytro_read_metadata(fname_json)[source]

Reads the Lytro ILLUM metadata from the json file.

Parameters

fname_json – The path to the .json file (string)

Returns

The camera object

Return type

lightfield.Camera

plenoptomos.import_lf.read_image(img_path, data_type)[source]

plenoptomos.lightfield module

This module implements two important data containers: the data container ‘Lightfield’ and the metadata container ‘Camera’. They are used throughout the entire package for interpreting and performing low level manipulation of the raw light-field data.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Mar 1 16:08:17 2017

class plenoptomos.lightfield.Camera(model='unknown')[source]

Bases: object

Class that holds the metadata needed to interpret light-field data

clone()[source]
crop(crop_size_ts=None, crop_size_vu=None)[source]
get_alphas(alphas, beam_geometry_in='cone', beam_geometry_out='parallel')[source]

Converts the refocusing alphas between beam geometries

Parameters
  • alphas – Sequence of alpha values as numpy array (numpy.array_like)

  • beam_geometry_in – Beam shape of the input alphas. Options: ‘parallel’ | ‘cone’ (string)

  • beam_geometry_out – Beam shape of the output alphas. Options: ‘parallel’ | ‘cone’ (string)

Returns

The converted alphas

Return type

(numpy.array_like)

get_distance_domain(d)[source]
get_f1(z0)[source]
get_filter(alpha, bandwidth=0.04, beam_geometry='parallel', domain='object', oversampling=1)[source]
get_focused_distance()[source]
get_focused_patch_size()[source]
get_grid_points(space='direct', domain='object', oversampling=1)[source]
get_number_of_subaperture_images()[source]
get_raw_detector_size()[source]
get_sampling_renorm_factor(alpha, space='direct', beam_geometry='parallel', domain='object')[source]
get_scales(space='direct', domain='object')[source]
get_sheared_coords(alpha, space='direct', beam_geometry='parallel', domain='object', transformation='shear', oversampling=1)[source]
get_sigmatau_grid_points(space='direct', domain='object')[source]
get_sigmatau_scales(space='direct', domain='object')[source]
get_theo_flatfield_raw(data_type=<class 'numpy.float32'>, over_sampling=5, mode='micro-image')[source]
is_focused()[source]
plot_phase_space_diagram(coordinates='su', show_central_images=None)[source]
print()[source]
regrid(regrid_size, regrid_mode='interleave')[source]
class plenoptomos.lightfield.Lightfield(camera_type: plenoptomos.lightfield.Camera, data=None, flat=None, mask=None, mode='micro-image', dtype=<class 'numpy.float32'>, shifts_vu=(None, None))[source]

Bases: object

Container class for the light-fields

aliases_modes = ('mi', 'sa', 'es', 'et')
available_modes = ('micro-image', 'sub-aperture', 'epipolar_s', 'epipolar_t')
clone()[source]
convention_modes = ('tsvu', 'vuts', 'tuvs', 'vstu')
convention_raw = 'tvsu'
crop(crop_size_ts=None, crop_size_vu=None)[source]

Crop a light-field

Parameters
  • crop_size_ts – Either new size in the (t, s) coordinates or a ROI (<2x1> or <4x1> numpy.array_like)

  • crop_size_vu – Either new size in the (v, u) coordinates or a ROI (<2x1> or <4x1> numpy.array_like)

get_central_subaperture(origin_vu=None)[source]
static get_mode_permutation(old_mode, new_mode)[source]
get_photograph(image='data')[source]

Computes the refocused photograph at z0

Parameters

image – Selects whether we want the detector data, or the flat image (string)

Returns

The refocused photograph at z0

Return type

numpy.array_like

get_raw_detector_picture(image='data')[source]

Returns the detector data, or the flat image in the raw detector format

Parameters

image – Selects whether we want the detector data, or the flat image (string)

Returns

The requested image

Return type

numpy.array_like

get_sub_aperture_image(v, u, image='data')[source]

Returns a chosen sub-aperture image from either detector data, or the flat field

Parameters
  • u – U coordinate of the image (int)

  • v – V coordinate of the image (int)

  • image – Selects whether we want the detector data, or the flat image (string)

Returns

The requested image

Return type

numpy.array_like

get_sub_aperture_images(image='data')[source]

Returns all the sub-aperture images from either detector data, or the flat field

Parameters

image – Selects whether we want the detector data, or the flat image (string)

Returns

The requested image

Return type

numpy.array_like

get_sub_lightfield(center_u=None, center_v=None, sub_aperture_size=5)[source]
get_sub_lightfields(sub_aperture_size=5)[source]
pad(paddings, method='constant', pad_value=(0,))[source]

Pad a light-field

Parameters
  • paddings – Padding to add (<4x1> numpy.array_like)

  • method – Padding method. Possible values: ‘constant’ | ‘edge’ | ‘linear_ramp’ | ‘maximum’ | ‘mean’ | ‘median’ | ‘minimum’ | ‘reflect’ | ‘symmetric’ | ‘wrap’ (string)

regrid(regrid_size, regrid_mode='interleave')[source]
set_mode(new_mode)[source]

Set the required view for the given light-field object.

Parameters

new_mode – One of the following: {‘micro-image’, ‘sub-aperture’, ‘epipolar_s’, ‘epipolar_t’} (string)

set_mode_epipolar_s()[source]

Set the ‘epipolar_s’ mode

set_mode_epipolar_t()[source]

Set the ‘epipolar_t’ mode

set_mode_microimage()[source]

Set the ‘micro-image’ mode

set_mode_subaperture()[source]

Set the ‘sub-aperture’ image mode

set_raw_detector_picture(data_raw, image='data')[source]

Sets the detector data, or the flat image from an image in raw detector format

Parameters
  • data_raw – The new detector image (numpy.array_like)

  • image – Selects whether we want the detector data, or the flat image (string)

plenoptomos.lightfield.cm2inch(x)[source]
plenoptomos.lightfield.get_camera(model_name, down_sampling_st=1, down_sampling_uv=1)[source]

plenoptomos.psf module

This module implements the point spread function (PSF) handling routines.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Tue Oct 10 18:31:14 2017

class plenoptomos.psf.PSF(camera: plenoptomos.lightfield.Camera, coordinates: str, airy_rings: int = 2, wavelength_intensity: float = 1, refocus_distance: Optional[float] = None, up_sampling: int = 1, is_beam_coherent: bool = False, over_sampling: int = 25, wavelength_steps: int = 10, beam_transverse_shape: str = 'circle', data_type: numpy.floating = <class 'numpy.float32'>, plot: bool = False)[source]

Bases: object

Data class that allows to store n-dimensional PSFs, and their accompanying information.

clone()[source]
static compute_defocus_psf(params, norm=2)[source]
static compute_fraunhofer_psf(params, d, z, pixel_size, ls)[source]
static get_unit_length(unit_length)[source]
plot()[source]
class plenoptomos.psf.PSFApply(psf_d=None, params=None, img_size=None, use_otf=True, data_format=None, use_fftconv=True)[source]

Bases: object

Class PSFApply handles all PSF/OTF applications

apply_psf_adjoint(imgs)[source]

Applies the adjoint of the PSF to the given images

Parameters

imgs (numpy.array_like) – The incoming images

Returns

The convolution between the images and the adjoint of the PSF

Return type

numpy.array_like

apply_psf_direct(imgs)[source]

Applies the PSF to the given images

Parameters

imgs (numpy.array_like) – The incoming images

Returns

The convolution between the images and the PSF

Return type

numpy.array_like

deconvolve(imgs, iterations=100, data_term='l2', lambda_wl=None, lambda_tv=None, lower_limit=None, upper_limit=None, verbose=False)[source]

Uses iterative algorithms to deconvolve the PSF from the given images

Parameters
  • imgs (numpy.array_like) – The incoming images

  • iterations (int, optional) – The number of reconstruciton iterations, defaults to 100

  • data_term (str, optional) – Data consistency term used by the wl recosntruction. Options: ‘l2’ | ‘kl’, defaults to ‘l2’

  • lambda_wl (float, optional. If None is passed, the SIRT algorithm will be used instead.) – Weight factor for the wavelet deconvolution, defaults to None

  • lambda_tv (float, optional. If None is passed, the SIRT algorithm will be used instead) – Weight factor for the TV term, defaults to None

  • lower_limit (float, optional) – Lower clipping value, defaults to None

  • upper_limit (float, optional) – Upper clipping value, defaults to None

  • verbose (boolean, optional) – Enable messages, defaults to False

Returns

The deconvolution of the images

Return type

numpy.array_like

print()[source]
set_psf_direct(psf_d, img_size=None)[source]
class plenoptomos.psf.PSFApply2D(psf_d, img_size=None, params=None, use_otf=True, data_format=None, use_fftconv=True)[source]

Bases: plenoptomos.psf.PSFApply

Class PSFApply2D handles all PSF applications and

class plenoptomos.psf.PSFApply4D(psf_d, img_size=None, params=None, use_otf=True, data_format=None, use_fftconv=True)[source]

Bases: plenoptomos.psf.PSFApply

Class PSFApply4D handles all PSF applications and

class plenoptomos.psf.PSFParameters(airy_rings: int = 2, over_sampling: int = 25, is_beam_coherent: bool = False, wavelength_intensity: float = 1, pixels_defocus: float = None, refocus_distance: float = None, guarantee_pixel_multiple: int = 1, beam_transverse_shape: str = 'circle', data_type: numpy.floating = <class 'numpy.float32'>)[source]

Bases: object

airy_rings: int = 2
beam_transverse_shape: str = 'circle'
data_type

alias of numpy.float32

guarantee_pixel_multiple: int = 1
is_beam_coherent: bool = False
over_sampling: int = 25
pixels_defocus: float = None
refocus_distance: float = None
wavelength_intensity: float = 1

plenoptomos.refocus module

This module contains the implementation of the traditional reference refocusing algorithms.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Thu Mar 2 18:48:28 2017

plenoptomos.refocus.compute_refocus_fourier(lf: plenoptomos.lightfield.Lightfield, zs, method: str = 'slice', beam_geometry: str = 'parallel', domain: str = 'object', up_sampling: int = 1, border: int = 4, border_padding: str = 'edge', padding_factor: float = 1.1, oversampling: float = 2)[source]

Perform the refocusing of the input light field image using Fourier slice theorem method.

This method was presented in: [1] R. Ng, “Fourier slice photography,” ACM Trans. Graph., vol. 24, no. 3, p. 735, 2005.

lflightfield.Lightfield

The light-field object.

zsnumpy.array_like

Refocusing distances.

methodstr, optional

Fourier space operation method. Options: ‘slice’ | ‘full’, ‘hyper_cone’. The default is “slice”.

beam_geometrystr, optional

Beam geometry. Possible options: ‘parallel’ | ‘cone’. The default is “parallel”.

domainstr, optional

Refocusing domain. Possible options: ‘object’ | ‘image’. The default is “object”.

up_samplingint, optional

Integer greater than 1 for up-sampling of the final images. The default is 1.

borderint, optional

Number of pixels to extend the border and reduce darkening of edges. The default is 4.

border_paddingstr, optional

Border padding method. The default is “edge”.

padding_factorfloat, optional

Real-space padding factor. The default is 1.1.

oversamplingfloat, optional

Fourier space oversampling factor. The default is 2.

ValueError

In case of wrong domain and beam geometry choices.

imgsnumpy.array_like

Stack of 2D refocused images.

plenoptomos.refocus.compute_refocus_integration(lf: plenoptomos.lightfield.Lightfield, zs, beam_geometry: str = 'parallel', domain: str = 'object', up_sampling: int = 1, border: int = 4, border_padding: str = 'edge', use_multithreading: bool = True)[source]

Perform the refocusing of the input light field image using the integration method.

This method was presented in: [1] R. Ng, et al., “Light Field Photography with a Hand-held Plenoptic Camera,” Stanford Univ. Tech. Rep. CSTR 2005-02, 2005.

lflightfield.Lightfield

The light-field object.

zsnumpy.array_like

Refocusing distances.

beam_geometrystr, optional

Beam geometry. Possible options: ‘parallel’ | ‘cone’. The default is “parallel”.

domainstr, optional

Refocusing domain. Possible options: ‘object’ | ‘image’. The default is “object”.

up_samplingint, optional

Integer greater than 1 for up-sampling of the final images. The default is 1.

borderint, optional

Number of pixels to extend the border and reduce darkening of edges. The default is 4.

border_paddingstr, optional

Border padding method. The default is “edge”.

use_multithreadingbool, optional

Whether to use multi-threading capabilities. The default is True.

ValueError

In case of wrong domain and beam geometry choices.

imgsnumpy.array_like

Stack of 2D refocused images.

plenoptomos.solvers module

This module implements a few different solvers from the tomography reconstruction literature.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Mar 8 11:27:12 2017

class plenoptomos.solvers.BPJ(verbose=False, weight_det=None, dump_file=None, tol=1e-05)[source]

Bases: plenoptomos.solvers.Solver

class plenoptomos.solvers.CP_smooth(verbose=False, weight_det=None, dump_file=None, tol=1e-05, data_term='l2', lambda_d2=0.01, axes=None)[source]

Bases: plenoptomos.solvers.Solver, plenoptomos.solvers.Operations

class plenoptomos.solvers.CP_tv(verbose=False, weight_det=None, dump_file=None, tol=1e-05, data_term='l2', lambda_tv=0.01, axes=None)[source]

Bases: plenoptomos.solvers.Solver, plenoptomos.solvers.Operations

class plenoptomos.solvers.CP_uc(verbose=False, weight_det=None, dump_file=None, tol=1e-05, data_term='l2')[source]

Bases: plenoptomos.solvers.Solver

class plenoptomos.solvers.CP_wl(verbose=False, weight_det=None, dump_file=None, tol=1e-05, data_term='l2', lambda_wl=0.01, axes=None, wl_type='db4', use_decimated=False, decomp_lvl=3)[source]

Bases: plenoptomos.solvers.Solver

initialize_wl_operators()[source]
class plenoptomos.solvers.Operations(axes=None)[source]

Bases: object

divergence(x)[source]
gradient(x)[source]
laplacian(x)[source]
class plenoptomos.solvers.Segment(verbose=False, lambda_tv=0.01, lambda_d2=0.01, axes=None)[source]

Bases: plenoptomos.solvers.Solver, plenoptomos.solvers.Operations

levelset(im, mus, iterations=50, w_norm_p=2, data_term='l1')[source]
simple(vol, rhos)[source]
class plenoptomos.solvers.Sirt(verbose=False, weight_det=None, dump_file=None, tol=1e-05)[source]

Bases: plenoptomos.solvers.Solver

class plenoptomos.solvers.Solver(verbose=False, dump_file=None, tol=1e-05)[source]

Bases: object

initialize_data_operators(A, At)[source]
lower()[source]
mult_matrix(M, x, data_shape=None)[source]

Multiplies a matrix M by and array x.

upper()[source]

plenoptomos.tomo module

This module contains the tomographic refocusing routines.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Mar 8 11:30:00 2017

class plenoptomos.tomo.Projector(camera: plenoptomos.lightfield.Camera, zs, mask=None, vignetting_int=None, beam_geometry='cone', domain='object', psf_d=None, up_sampling=1, super_sampling=1, shifts_vu=(None, None), gpu_index=- 1)[source]

Bases: object

Projector class: it allows to forward-project and back-project light-fields.

This class should not be used directly, but rather through the functions provided in the containing module.

BP(y)[source]

Back-projection function

Parameters

x – Light-field to back-project (numpy.array_like)

Returns

The back-projected volume

Return type

numpy.array_like

FP(x)[source]

Forward-projection function

Parameters

x – The volume to project (numpy.array_like)

Returns

The projected light-field

Return type

numpy.array_like

reset()[source]
plenoptomos.tomo.compute_forwardprojection(camera: plenoptomos.lightfield.Camera, zs, vols, masks, reflective_geom: bool = True, border: int = 5, border_padding: str = 'edge', up_sampling: int = 1, super_sampling: int = 1, beam_geometry: str = 'cone', domain: str = 'object', gpu_index: int = - 1)[source]
plenoptomos.tomo.compute_refocus_backprojection(lf: plenoptomos.lightfield.Lightfield, zs, border: int = 4, border_padding: str = 'edge', up_sampling: int = 1, super_sampling: int = 1, beam_geometry: str = 'cone', domain: str = 'object', gpu_index: int = - 1)[source]

Compute refocusing of the input lightfield image at the input distances by applying the backprojection method.

Parameters
  • lf – The light-field object (lightfield.Lightfield)

  • zs – Refocusing distances (numpy.array_like)

  • up_sampling – Integer greater than 1 for up-sampling of the final images (int, default: 1)

  • super_sampling – Super-sampling of the back-projection operator (it will not increase refocused image size/resolution) (int, default: 1)

  • border – Number of pixels to extend the border and reduce darkening of edges (int, default: 4)

  • border_padding – Border padding method (string, default: ‘edge’)

  • beam_geometry – Beam geometry. Possible options: ‘parallel’ | ‘cone’ (string, default: ‘parallel’)

  • domain – Refocusing domain. Possible options: ‘object’ | ‘image’ (string, default: ‘object’)

Returns

Stack of 2D refocused images.

Return type

numpy.array_like

plenoptomos.tomo.compute_refocus_iterative(lf: plenoptomos.lightfield.Lightfield, zs: Union[float, Sequence, numpy.array], beam_geometry: str = 'cone', domain: str = 'object', zs_independent: bool = True, border: int = 4, border_padding: str = 'edge', algorithm: Union[str, plenoptomos.solvers.Solver] = 'sirt', iterations: int = 10, up_sampling: int = 1, super_sampling: int = 1, psf: Optional[plenoptomos.psf.PSFApply] = None, gpu_index: int = - 1, verbose: bool = False)[source]

Compute refocusing of the input lightfield image at the input distances by applying iterative methods.

lflightfield.Lightfield

The light-field object.

zsany of float, list, tuple, numpy.array_like

Refocusing distances.

beam_geometrystr, optional

Beam geometry. The default is “cone”, out of: ‘parallel’ | ‘cone’.

domainstr, optional

Refocusing domain. The default is “object”, out of: ‘object’ | ‘image’.

zs_independentbool, optional

Whether the refocusing should be independent for each distance. The default is True.

borderint, optional

Number of pixels to extend the border and reduce darkening of edges. The default is 4.

border_paddingstr, optional

Border padding method. The default is “edge”.

algorithmstr or solvers.Solver, optional

The algorithm to use. The default is “sirt”.

iterationsint, optional

Number of iterations (for iterative algorithms). The default is 10.

up_samplingint, optional

Integer greater than 1 for up-sampling of the final images. The default is 1.

super_samplingint, optional

Finer sampling of the projection (does not alter the final image size). The default is 1.

psfOptional[psf.PSFApply], optional

Detector PSF. The default is None.

gpu_indexint, optional

It allows to pin a specific GPU. The default is -1.

verbosebool, optional

Whether to have verbose output from algorithms. The default is False.

ValueError

DESCRIPTION.

numpy.array_like

Stack of 2D refocused images.

plenoptomos.tomo.compute_refocus_iterative_multiple(*args, **kwds)[source]

Compute refocusing of the input lightfield image jointly at the input distances by applying iterative methods.

For the parameters description refer to the function compute_refocus_iterative().

plenoptomos.utils_io module

Convenience functions for handling IO with hdf5 files of frequently used data structures.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Mar 1 16:09:53 2017

plenoptomos.utils_io.load_field_fromh5(filename, dset, verbose=False)[source]
plenoptomos.utils_io.load_lightfield(filename)[source]
plenoptomos.utils_io.save_field_toh5(filename, dset_name, data, verbose=False, append=False, compression_lvl=7, to_uint8=False)[source]
plenoptomos.utils_io.save_lightfield(filename, lf: plenoptomos.lightfield.Lightfield)[source]
plenoptomos.utils_io.save_refocused_image(img2d, filename, ind=None)[source]
plenoptomos.utils_io.save_refocused_stack(refocus_stack, filename, verbose=False, zs=None)[source]

plenoptomos.utils_plot module

Simple visualization tools for refocused stacks.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Fri Dec 8 15:24:12 2017

class plenoptomos.utils_plot.RefocusVisualizer(data, pos_val=None, ref_img=None, transpose_axes=None, share_axes=False, clims=None, do_clear=True, cmap=<matplotlib.colors.ListedColormap object>, colorbar=True)[source]

Bases: object

Simple visualization tool for refocusing stacks.

show(*args, **kwords)[source]
class plenoptomos.utils_plot.Scroller(f, ax, data, pos_val=None, title=None, do_clear=True, clims=None, cmap=<matplotlib.colors.ListedColormap object>, colorbar=True)[source]

Bases: object

Class to be used in conjunction with RefocusVisualizer.

update()[source]

Updates the axes, to show the new requested image.

plenoptomos.utils_proc module

This module implements utility functions for image processing.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Created on Wed Sep 18 17:00:50 2019

plenoptomos.utils_proc.apply_bandpass_filter(img, filt_fft)[source]

Applies a 2D band pass filter to an image or collection of images.

Parameters
  • img (numpy.array_like) – Image to be filtered

  • filt_fft (numpy.array_like) – 2D filter in Fourier domain

Returns

The filtered image

Return type

numpy.array_like

plenoptomos.utils_proc.get_bandpass_filter(img_shape, cutoff_pix, trans_pix)[source]

Computes a band pass filter with the erf.

Parameters
  • img_shape (tuple) – Shape of the image

  • cutoff_pix (tuple(int, int)) – Position of the cutoffs in k-vector, in the fft domain

  • trans_pix (tuple(int, int)) – Size of the cutoffs transition in k-vector, in the fft domain

Returns

The computes filter

Return type

numpy.array_like

plenoptomos.utils_proc.get_highpass_filter(img_shape, cutoff_pix, trans_pix)[source]

Computes a high pass filter with the erf.

Parameters
  • img_shape (tuple) – Shape of the image

  • cutoff_pix (int or tuple of ints) – Position of the cutoff in k-vector, in the fft domain

  • trans_pix (int) – Size of the cutoff transition in k-vector, in the fft domain

Returns

The computes filter

Return type

numpy.array_like

plenoptomos.utils_proc.get_lowpass_filter(img_shape, cutoff_pix, trans_pix)[source]

Computes a low pass filter with the erfc.

Parameters
  • img_shape (tuple) – Shape of the image

  • cutoff_pix (int or tuple of ints) – Position of the cutoff in k-vector, in the fft domain

  • trans_pix (int) – Size of the cutoff transition in k-vector, in the fft domain

Returns

The computes filter

Return type

numpy.array_like

plenoptomos.utils_proc.get_smoothing_filter(window_size=(9, 9), window_shape='gauss', plot_filter=False)[source]

Computes and returns a smoothing filter.

Parameters
  • window_size (tuple(int, int), optional) – Filter window size, defaults to (9, 9)

  • window_shape (str, optional. Options: {'gauss'} | 'tri' | 'circ' | 'rect'.) – Filter type, defaults to ‘gauss’

  • plot_filter (boolean, optional) – Whether to plot the filter or not, defaults to False

Raises

ValueError – In case of wrong filter name

Returns

The filter

Return type

numpy.array_like

plenoptomos.utils_proc.remove_background(data, blur_size, blur_func='circ', axes=(0, 1), do_reverse=False, non_negative=False)[source]

Removes the background.

Parameters
  • data (numpy.array_like) – Input data.

  • blur_size (tuple(int, int)) – Size of the blur filter

  • blur_func (str, optional. Options are the ones of get_smoothing_filter) – Smoothing blur type, defaults to ‘circ’

  • axes (tuple, optional) – Axes where to remove the background, defaults to (0, 1)

  • do_reverse (boolean, optional) – Computes the opposite of the input data (minus), defaults to False

  • non_negative (boolean, optional) – Truncates the values below zero, defaults to False

Returns

Background removed data

Return type

numpy.array_like

Module contents

Top-level package for plenoptomos.

Created on Thu Mar 2 17:44:15 2017