pandora.matching_cost.sad_ssd ============================= .. py:module:: pandora.matching_cost.sad_ssd .. autoapi-nested-parse:: This module contains functions associated to SAD and SSD methods used in the cost volume measure step. Classes ------- .. autoapisummary:: pandora.matching_cost.sad_ssd.SadSsd Module Contents --------------- .. py:class:: SadSsd(**cfg: Union[str, int]) Bases: :py:obj:`pandora.matching_cost.matching_cost.AbstractMatchingCost` SadSsd class allows to compute the cost volume .. py:attribute:: _pixel_wise_methods .. py:method:: check_conf(**cfg: Dict[str, Union[str, int]]) -> Dict[str, Union[str, int]] Add default values to the dictionary if there are missing elements and check if the dictionary is correct :param cfg: matching cost configuration :type cfg: dict :return cfg: matching cost configuration updated :rtype: dict .. py:method:: compute_cost_volume(img_left: xarray.Dataset, img_right: xarray.Dataset, cost_volume: xarray.Dataset) -> xarray.Dataset Computes the cost volume for a pair of images :param img_left: 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 :type img_left: xarray.Dataset :param img_right: 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 :type img_right: xarray.Dataset :param cost_volume: an empty cost volume :type cost_volume: xr.Dataset :return: the cost volume dataset , with the data variables: - cost_volume 3D xarray.DataArray (row, col, disp) :rtype: xarray.Dataset .. py:method:: allocate_numpy_cost_volume(img_left: xarray.Dataset, disparity_range: Union[numpy.ndarray, List], offset_row_col: int = 0) -> numpy.ndarray Allocate the numpy cost volume cv = (disp, col, row), for efficient memory management :param img_left: 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 :type img_left: xarray.Dataset :param disparity_range: disparity range :type disparity_range: np.ndarray :param offset_row_col: offset in row and col :type offset_row_col: int :return: the cost volume dataset , with the data variables: - cost_volume 3D xarray.DataArray (row, col, disp) :rtype: xarray.Dataset .. py:method:: ad_cost(point_p: Tuple[int, int], point_q: Tuple[int, int], img_left: xarray.Dataset, img_right: xarray.Dataset) -> numpy.ndarray Computes the absolute difference :param point_p: Point interval, in the left image, over which the squared difference will be applied :type point_p: tuple :param point_q: Point interval, in the right image, over which the squared difference will be applied :type point_q: tuple :param img_left: left Dataset image :type img_left: xarray.Dataset 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 :param img_right: right Dataset image :type img_right: xarray.Dataset 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 :return: the absolute difference pixel-wise between elements in the interval :rtype: numpy array .. py:method:: sd_cost(point_p: Tuple, point_q: Tuple, img_left: xarray.Dataset, img_right: xarray.Dataset) -> numpy.ndarray Computes the square difference :param point_p: Point interval, in the left image, over which the squared difference will be applied :type point_p: tuple :param point_q: Point interval, in the right image, over which the squared difference will be applied :type point_q: tuple :param img_left: left Dataset image :type img_left: xarray.Dataset 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 :param img_right: right Dataset image :type img_right: xarray.Dataset 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 :return: the squared difference pixel-wise between elements in the interval :rtype: numpy array .. py:method:: pixel_wise_aggregation(cost_volume: numpy.ndarray) -> numpy.ndarray Summing pixel wise matching cost over square windows :param cost_volume: the cost volume :type cost_volume: numpy array 3D (disp, col, row) :return: the cost volume aggregated :rtype: numpy array 3D ( disp, col, row)