pandora.matching_cost.sad_ssd
This module contains functions associated to SAD and SSD methods used in the cost volume measure step.
Module Contents
Classes
SadSsd class allows to compute the cost volume |
- class pandora.matching_cost.sad_ssd.SadSsd(**cfg: str | int)[source]
Bases:
pandora.matching_cost.matching_cost.AbstractMatchingCost
SadSsd 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
- allocate_numpy_cost_volume(img_left: xarray.Dataset, disparity_range: numpy.ndarray | List, offset_row_col: int = 0) numpy.ndarray [source]
Allocate the numpy cost volume cv = (disp, col, row), for efficient memory management
- 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
disparity_range (np.ndarray) – disparity range
offset_row_col (int) – offset in row and col
- Returns:
the cost volume dataset , with the data variables:
cost_volume 3D xarray.DataArray (row, col, disp)
- Return type:
xarray.Dataset
- ad_cost(point_p: Tuple[int, int], point_q: Tuple[int, int], img_left: xarray.Dataset, img_right: xarray.Dataset) numpy.ndarray [source]
Computes the absolute difference
- 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 – left Dataset image
img_right – right Dataset image
- Returns:
the absolute difference pixel-wise between elements in the interval
- Return type:
numpy array
- sd_cost(point_p: Tuple, point_q: Tuple, img_left: xarray.Dataset, img_right: xarray.Dataset) numpy.ndarray [source]
Computes the square difference
- 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 – left Dataset image
img_right – right Dataset image
- Returns:
the squared difference pixel-wise between elements in the interval
- Return type:
numpy array