DisneyDisp package

DisneyDisp.disparity

author:Manuel Tuschen
date:20.06.2016
license:GPL3
class DisneyDisp.disparity.Disney(lightfield, lf_group, output_dir, working_dir='work_tmp/', n_cpus=-1, r_start=None, s_hat=None, DEBUG=False)

Bases: object

The class collecting all functionality and input parameters needed for the disparity calculation.

calculateDisp(min_disp, max_disp, stepsize, Ce_t, Cd_t, S_t, NOISEFREE=False)

The main method to calculate the disparity estimates.

Parameters:
  • min_disp (float) – The minimal disparity to sample for.
  • max_disp (float) – The maximal disparity to sample for.
  • stepsize (float) – The stepsize used during the sampling procedure.
  • Ce_t (float) – The threshold for the edge confidence.
  • Cd_t (float:) – The threshold for the disparity confidence.
  • S_t (float) – The similarity threshold e.g. for the bilateral median filter.
  • NOISEFREE (bool, optional) – True means not to iteratively smooth the mean radiance. This should only be enabled for noisy data.
calculateMap()

Calculate the final disparity map for each s-dimension and save output into a hdf5 file container. In DEBUG mode lot’s of furhter plot’s are generated.

generate_s_hat_order()

Generate a list with each entry being the next s-entry to work with.

Returns:
  • list
  • A ordered list with the s-dimensions to go through.
getCd(res, v=None, s=None, u=None)

Get the required required disparity confidence data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u]

getCe(res, v=None, s=None, u=None)

Get the required required edge confidence data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u]

getDBs(res, v=None, s=None, u=None)

Get the required required disparity bound data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u]

getDisp(res, v=None, s=None, u=None, level=None)

Get the required required disparity data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • level (int, optional) – Determine which disparity data to get in DEBUG mode. 0) after refinement, 1) raw data, 2) after bilateral median, 3) after confidence selection
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u, (level)]

getEpi(res, v=None, s=None, u=None)

Get the required epi data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u]

getScore(res, v=None, s=None, u=None, level=None)

Get the required required score data.

Parameters:
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • level (int, optional) – Determine which score data to get in DEBUG mode. 0) S_max, 1) S_mean, 2) S_argmax,
Returns:

The sub(data) requested.

Return type:

numpy.array [v,s,u, (level)]

initialize()

Load data from files or initialize if not available.

saveCd(data, res, v=None, s=None, u=None, threshold=None)

Save the selected disparity confidence data.

Parameters:
  • data (numpy.array) – The data to save.
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • threshold (float, optional) – Confidence threshold for binary mask.
saveCe(data, res, v=None, s=None, u=None, threshold=None)

Save the selected edge confidence data.

Parameters:
  • data (numpy.array) – The data to save.
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • threshold (float, optional) – Confidence threshold for binary mask.
saveDBs(data, res, v=None, s=None, u=None)

Save the selected disparity bound data.

Parameters:
  • data (numpy.array) – The data to save.
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
saveDisp(data, res, v=None, s=None, u=None, level=None)

Save the selected disparity data.

Parameters:
  • data (numpy.array) – The data to save.
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • level (int, optional) – Determine which disparity data to get in DEBUG mode. 0) after refinement, 1) raw data, 2) after bilateral median, 3) after confidence selection.
saveScore(data, res, v=None, s=None, u=None, level=0)

Save the selected score data.

Parameters:
  • data (numpy.array) – The data to save.
  • res (tuple) – The current v- and u-dimension.
  • v (int, optional) – The only v-dimension to return.
  • s (int, optional) – The only s-dimension to return.
  • u (int, optional) – The only u-dimension to return.
  • level (int, optional) – Determine which disparity data to get in DEBUG mode. 0) S_max, 1) S_mean, 2) S_argmax,

DisneyDisp.imgs2lf

author:Manuel Tuschen
date:20.06.2016
license:GPL3
DisneyDisp.imgs2lf.imgs2lf(input_dir, output_file, output_dataset='lightfield', img_extension='.png', dtype=<class 'numpy.uint8'>, RGB=True)

Convert several images to a lightfield.

Parameters:
  • input_dir (string) – The directory where the ligthfield images are located.
  • output_file (string) – The filename (including the directory), of the output file.
  • output_dataset (string, optional) – The new container name of the hdf5 file.
  • img_extension (string, optional) – The file extension of the images to look for.
  • dtype (numpy.dtype, optional) – The new data type for the downscaled lightfield. Must be either np.float64, np.uint8 or np.uint16.
  • RGB (bool, optional) – If True, the output lightfield will be converted to RGB (default). Otherwise gray type images are stored.

DisneyDisp.lf2epi

author:Manuel Tuschen
date:20.06.2016
license:GPL3
DisneyDisp.lf2epi.calculate_resolutions(r0_v, r0_u, red_fac=2, min_res=11)

Create a list of downsampled resolutions (v,u) by reducing the initial resolution by a constant factor for each dimension up to a minimal resolution.

Parameters:
  • r0_v (uint16) – The initial resolution in v-dimension.
  • r0_u (uint16) – The initial resolution in u-dimension.
  • red_fac (uint , optional) – The reduction factor used for down sampling. Default is to halve the resolution each time.
  • min_res (uint16.) – The minimal resolution to sample to. The program will stop when either u or v reach min_res.
Returns:

Each entry is a tuple (u,v) of resolutions.

Return type:

array_like

DisneyDisp.lf2epi.create_epis(lf_in, epi_out, hdf5_group_in, hdf5_group_out='epis', dtype=<class 'numpy.float64'>, RGB=True)

Create epis for all resolutions given by the input lightfield.

Parameters:
  • lf_in (string) – The input hdf5 filename (including the directory) of the lightfield.
  • epi_out (string) – The output hdf5 filename (including the directory) of the lightfield in all resolutions.
  • hdf5_group_in (string) – The container name inside the hdf5 file for the lightfield. The same name will be used for the new file.
  • hdf5_group_out (string, optional) – The container name inside the hdf5 file for the epis.
  • dtype (numpy.dtype, optional) – The new data type for the epis. Must be either np.float64, np.uint8 or np.uint16.
  • RGB (bool, optional) – If True, the output epis will be converted to RGB (default). Otherwise gray type images are stored.
DisneyDisp.lf2epi.downsample_lightfield(lf_in, lf_out, hdf5_group, r_all)

Reduces the dimension of the input lightfield to the values given. Results are stored in a new hdf5 file.

Parameters:
  • lf_in (string) – The input hdf5 filename (including the directory) of the lightfield.
  • lf_out (string) – The output hdf5 filename (including the directory) of the lightfield in all resolutions.
  • hdf5_group (string) – The container name inside the hdf5 file for the lightfield. The same name will be used for the new file.
  • r_all (array_like) – All resolutions to create. Each entry is a tuple (u,v) of resolutions.

DisneyDisp.clif2lf

author:Manuel Tuschen
date:20.06.2016
license:GPL3
DisneyDisp.clif2lf.clif2lf(clif_file, lf_file, clif_group, lf_group='lightfiled')

Convert a standard .clif file to an .hdf5 lightfield file.

Parameters:
  • clif_file (string) – The .clif filename including the directory.
  • lf_file (string) – The filename (including the directory) of the output .hdf5 lightfield.
  • clif_group (string) – The container name inside the .clif file.
  • lf_group (string, optional) – The container name inside the .hdf5 file for the lightfield.

DisneyDisp.dmap2hdf5

author:Manuel Tuschen
date:20.06.2016
license:GPL3
DisneyDisp.dmap2hdf5.dmap2hdf5(input_dir, output_file, output_dataset='disparities')

Convert results from .dmap files into .hdf5 file.

Parameters:
  • input_dir (string) – The directory where the .dmap files are located.
  • output_file (string) – The filename (including the directory), of the output file.
  • output_dataset (string, optional) – The new container name of the hdf5 file.