conv2d_valid#

rlemasklib.RLEMask.conv2d_valid(kernel, stride=(1, 1), threshold=0.5)[source]#

Perform a 2D convolution with the given weighted kernel and threshold the result.

This function does not perform any padding and only returns the “valid” part of the convolution, similar to “valid” padding mode in deep learning frameworks as opposed to “same” or “full” padding.

Parameters:
  • kernel (ndarray) – the convolution kernel as a 2D numpy array

  • stride (Sequence[int]) – the stride of the convolution as two integers

  • threshold (float) – the result is set to 1 if the convolution result is greater than this value

Returns:

A new RLEMask object representing the convolved and thresholded mask.

Return type:

RLEMask