Class Mask

Constructors

  • Construct a new Mask knowing its dimensions.

    Parameters

    • width: number

      Image width.

    • height: number

      Image height.

    • options: MaskOptions = {}

      Image options.

    Returns Mask

Properties

alpha: boolean

Specifying that the mask has no an alpha channel.

bitDepth: BitDepth

The number of bits per value in each channel (always 1).

channels: number

The number of channels in the mask, including the alpha channel (always 1).

colorModel: ImageColorModel

The color model of the mask (always BINARY).

components: number

The number of color channels in the image, excluding the alpha channel (always 1).

height: number

The number of rows of the mask.

maxValue: number

The maximum value that a pixel channel can have.

origin: Point

Origin of the image relative to a the parent image.

size: number

The total number of bits in the mask (width × height).

width: number

The number of columns of the mask.

Methods

  • Fill the mask with a value.

    Parameters

    Returns this

    The mask instance.

  • Get the value of a bit.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    Returns number

    The bit value.

  • Get the value of a bit using index.

    Parameters

    • index: number

      Index of the pixel.

    Returns number

    Value of the bit.

  • Get the vertices of the convex Hull polygon of a mask.

    Returns ConvexHull

    Array of the vertices of the convex Hull in clockwise order.

  • Get the corners of the minimum bounding rectangle of a shape defined in a mask.

    Returns Mbr

    Array of border points.

  • Get the number of pixels that do not have the value 0.

    Returns number

  • Get a pixel of the mask.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    Returns number[]

    The pixel.

  • Get a pixel using its index.

    Parameters

    • index: number

      Index of the pixel.

    Returns number[]

    The pixel.

  • Return the raw mask data.

    Returns { data: Uint8Array; height: number; width: number }

    The raw data.

  • Get the value of a bit. Function exists for compatibility with Image.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    • channel: number

      Index of the channel, must be zero.

    Returns number

    The bit value.

  • Get the value of a bit using index. Function exists for compatibility with Image.

    Parameters

    • index: number

      Index of the pixel.

    • channel: number

      Index of the channel, must be zero.

    Returns number

    Value of the bit.

  • Get the value of a specific bit. Select bit using a point.

    Parameters

    • point: Point

      Coordinates of the desired biz.

    Returns number

    Value of the bit.

  • Set the value of a bit.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    • value: BitValue

      New bit value.

    Returns void

  • Set the value of a bit using index.

    Parameters

    • index: number

      Index of the pixel.

    • value: BitValue

      Value to set.

    Returns void

  • Set a pixel.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    • value: number[]

      The pixel value.

    Returns void

  • Set a pixel using its index.

    Parameters

    • index: number

      Index of the pixel.

    • value: number[]

      New value of the pixel to set.

    Returns void

  • Set the value of a bit. Function exists for compatibility with Image.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    • channel: number

      Index of the channel, must be zero.

    • value: BitValue

      New bit value.

    Returns void

  • Set the value of a bit using index. Function exists for compatibility with Image.

    Parameters

    • index: number

      Index of the pixel.

    • channel: number

      Index of the channel, must be zero.

    • value: BitValue

      Value to set.

    Returns void

  • Set the value of a specific bit. Select bit using a point.

    Parameters

    • point: Point

      Coordinates of the bit.

    • value: BitValue

      Value to set.

    Returns void

  • Set a pixel to a given value if the coordinates are inside the mask.

    Parameters

    • column: number

      Column index.

    • row: number

      Row index.

    • value: number[]

      New color of the pixel to set.

    Returns void

  • Create a mask from an array of points.

    Parameters

    • width: number

      Width of the mask.

    • height: number

      Height of the mask.

    • points: Point[]

      Reference Mask.

    Returns Mask

    New mask.