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 maskedColor. 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 pixel set to maskedColor in the output image.

  • maskedColor: Color with which the masked pixels will be replaced.


  • image: Output image.