calculate_required_padding#

calculate_required_padding(extent_sz: Union[int, tuple[int, int]], chip_sz: Union[int, tuple[int, int]], stride: Union[int, tuple[int, int]], pad_direction: Literal['start', 'end', 'both'], crop_sz: Optional[int] = None) tuple[int, int][source]#

Calculate min padding to ensure sliding windows cover all pixels.

Parameters:
  • extent_sz (Union[int, tuple[int, int]]) – Extent size as (h, w) tuple.

  • chip_sz (Union[int, tuple[int, int]]) – Chip size as (h, w) tuple.

  • stride (Union[int, tuple[int, int]]) – Stride size as (h_step, w_step) tuple.

  • pad_direction (Literal['start', 'end', 'both']) – One of: ‘start’, ‘end’, ‘both’.

  • crop_sz (Optional[int]) – When cropping out window edges during semantic segmentation prediction, pixels at the edges of the scene can be left with no prediction if there is not enough padding. When crop_sz is specified, the calculated padding takes this into account. Has no effect if zero. Defaults to None.

Returns:

Padding as (h_pad, w_pad) tuple.

Return type:

tuple[int, int]