apply_mask

hybrid_learning.datasets.data_visualization.apply_mask(img, mask, color='green', alpha=0.8)[source]

Apply monochrome (possibly non-binary) mask to image of same size with alpha value. The positive parts of the mask are colored in color and added to the image.

Parameters
  • img (Image) – image

  • mask (Image) – mask (mode 'L' or '1')

  • color (str) – color to use for masked regions as argument to Image.new()

  • alpha (float) –

    alpha value in [0,1] to darken mask:

    0

    black,

    <1

    darken,

    1

    original

Returns

RGB PIL.Image.Image with mask applied

Return type

Image