Mask image🔗

Applies a binary mask to the input image. A pixel is copied from the input image to the output image if the corresponding pixel in the mask image is non-zero. Otherwise the pixel in the output image is set to zero. The logic can be inverted with the invert flag.


  • image: Input image.

  • mask: Binary mask. Must be the same size as the input or an empty image. If the mask is empty, the input image will be passed as such.

  • invert: Logic inversion flag. If the value is true, a non-zero pixel in the mask means a zero pixel in the output image.


  • image: Output image.