pandora.filter.bilateral

This module contains functions associated to the bilateral filter used to filter the disparity map.

Module Contents

Classes

BilateralFilter

BilateralFilter class allows to perform the filtering step

class pandora.filter.bilateral.BilateralFilter(cfg: Dict, image_shape: Tuple[int, int], step: int = 1)[source]

Bases: pandora.filter.filter.AbstractFilter

BilateralFilter class allows to perform the filtering step

property margins[source]
_SIGMA_COLOR = 2.0[source]
_SIGMA_SPACE = 6.0[source]
check_conf(cfg: Dict) Dict[str, str | float][source]

Add default values to the dictionary if there are missing elements and check if the dictionary is correct

Parameters:

cfg (dict) – filter configuration

Return cfg:

filter configuration updated

Return type:

dict

desc()[source]

Describes the filtering method

filter_disparity(disp: xarray.Dataset, img_left: xarray.Dataset = None, img_right: xarray.Dataset = None, cv: xarray.Dataset = None) None[source]

Apply bilateral filter. Filter size is computed from sigmaSpace

Parameters:
  • disp (xarray.Dataset) –

    the disparity map dataset with the variables :

    • disparity_map 2D xarray.DataArray (row, col)

    • confidence_measure 3D xarray.DataArray (row, col, indicator)

    • validity_mask 2D xarray.DataArray (row, col)

  • img_left (xarray.Dataset) – left Dataset image

  • img_right (xarray.Dataset) – right Dataset image

  • cv (xarray.Dataset) – cost volume dataset

Returns:

None

filter_bilateral(data: numpy.ndarray, sigma_space: float, sigma_color: float) numpy.ndarray[source]

Apply bilateral filter on valid pixels (pixels that are not nan). Invalid pixels are not filtered. If a valid pixel contains an invalid pixel in its filter, the invalid pixel is ignored for the calculation of the median.

Parameters:
  • data (2D np.array (row, col)) – input data to be filtered

  • sigma_space (float) – spatial sigma value

  • sigma_color (float) – color sigma value

Returns:

The gaussian spatial kernel

Return type:

2D np.array(row, col)

Returns:

The filtered array

Return type:

2D np.array(row, col)

gauss_spatial_kernel(kernel_size: int, sigma: float) numpy.ndarray[source]

Compute gaussian spatial kernel

Parameters:
  • kernel_size (float) – Kernel size

  • sigma (float) – sigma value

Returns:

The gaussian spatial kernel

Return type:

2D np.array(row, col)

static normalized_gaussian(array: numpy.ndarray, sigma: float) numpy.ndarray[source]

Apply normalized gaussian to the input array :param array: input array :type array: 2D np.array :param sigma: sigma :type sigma: float :return: The filtered array :rtype: 2D np.array

bilateral_kernel(windows: numpy.ndarray, gauss_spatial_kernel: numpy.ndarray, sigma_color: float, offset: int) numpy.ndarray[source]

Bilateral filtering on each window.

Parameters:
  • windows (4D np.array (stepsize, stepsize, windowsize, windowsize)) – batch of windows to be filtered

  • gauss_spatial_kernel (2D np.array (row, col)) – gaussian spatial kernel

  • sigma_color (float) – color sigma value

  • offset (int) – distance to window’s center

Returns:

The filtered pixels

Return type:

2D np.array(stepsize, stepsize)