pandora.matching_cost.census

This module contains functions associated to census method used in the cost volume measure step.

Module Contents

Classes

Census

Census class allows to compute the cost volume

class pandora.matching_cost.census.Census(**cfg: Dict[str, str | int])[source]

Bases: pandora.matching_cost.matching_cost.AbstractMatchingCost

Census class allows to compute the cost volume

check_conf(**cfg: Dict[str, str | int]) Dict[str, str | int][source]

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

Parameters:

cfg (dict) – matching cost configuration

Return cfg:

matching cost configuration updated

Return type:

dict

compute_cost_volume(img_left: xarray.Dataset, img_right: xarray.Dataset, cost_volume: xarray.Dataset) xarray.Dataset[source]

Computes the cost volume for a pair of images

Parameters:
  • img_left (xarray.Dataset) –

    left Dataset image containing :

    • im: 2D (row, col) or 3D (band_im, row, col) xarray.DataArray float32

    • disparity (optional): 3D (disp, row, col) xarray.DataArray float32

    • msk (optional): 2D (row, col) xarray.DataArray int16

    • classif (optional): 3D (band_classif, row, col) xarray.DataArray int16

    • segm (optional): 2D (row, col) xarray.DataArray int16

  • img_right (xarray.Dataset) –

    right Dataset image containing :

    • im: 2D (row, col) or 3D (band_im, row, col) xarray.DataArray float32

    • disparity (optional): 3D (disp, row, col) xarray.DataArray float32

    • msk (optional): 2D (row, col) xarray.DataArray int16

    • classif (optional): 3D (band_classif, row, col) xarray.DataArray int16

    • segm (optional): 2D (row, col) xarray.DataArray int16

  • cost_volume (xr.Dataset) – an empty cost volume

Returns:

the cost volume dataset , with the data variables:

  • cost_volume 3D xarray.DataArray (row, col, disp)

Return type:

xarray.Dataset

census_cost(point_p: Tuple[int, int], point_q: Tuple[int, int], img_left: xarray.Dataset, img_right: xarray.Dataset) List[int][source]

Computes xor pixel-wise between pre-processed images by census transform

Parameters:
  • point_p (tuple) – Point interval, in the left image, over which the squared difference will be applied

  • point_q (tuple) – Point interval, in the right image, over which the squared difference will be applied

  • img_left (xarray.Dataset) –

    left Dataset image containing :

    • im: 2D (row, col) or 3D (band_im, row, col) xarray.DataArray float32

    • disparity (optional): 3D (disp, row, col) xarray.DataArray float32

    • msk (optional): 2D (row, col) xarray.DataArray int16

    • classif (optional): 3D (band_classif, row, col) xarray.DataArray int16

    • segm (optional): 2D (row, col) xarray.DataArray int16

  • img_right (xarray.Dataset) –

    right Dataset image containing :

    • im: 2D (row, col) or 3D (band_im, row, col) xarray.DataArray float32

    • disparity (optional): 3D (disp, row, col) xarray.DataArray float32

    • msk (optional): 2D (row, col) xarray.DataArray int16

    • classif (optional): 3D (band_classif, row, col) xarray.DataArray int16

    • segm (optional): 2D (row, col) xarray.DataArray int16

Returns:

the xor pixel-wise between elements in the interval

Return type:

numpy array

static popcount32b(row: int) int[source]

Computes the Hamming weight for the input row, Hamming weight is the number of symbols that are different from the zero

Parameters:

row (int) – 32-bit integer

Returns:

the number of symbols that are different from the zero

Return type:

int