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

  • Perform an AND operation on two masks.

    Parameters

    Returns Mask

    AND of the two masks.

  • Remove elements connected to the borders of an image.

    Parameters

    Returns Mask

    The processed image.

  • Copy the mask to another one by specifying the location in the target mask.

    Parameters

    Returns Mask

    The target with the source copied to it.

  • Draw a line defined by two points onto a mask.

    Parameters

    Returns Mask

    The mask with the line drawing.

  • Draw a set of points on a mask.

    Parameters

    Returns Mask

    New mask.

  • Draw a polygon defined by an array of points onto an mask.

    Parameters

    Returns Mask

    The mask with the polygon drawing.

  • Draw a polyline defined by an array of points on a mask.

    Parameters

    Returns Mask

    The mask with the polyline drawing.

  • Draw a rectangle defined by position of the top-left corner, width and height.

    Parameters

    Returns Mask

    The image with the rectangle drawing.

  • Fill the mask with a value.

    Parameters

    Returns Mask

    The mask instance.

  • Apply flood fill algorithm from a given starting point.

    Parameters

    Returns Mask

    The filled mask.

  • 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 coordinates of the points on the border of a shape defined in a mask.

    Parameters

    Returns Point[]

    Array of border points.

  • 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.

    • data: Uint8Array
    • height: number
    • width: number
  • 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.

  • Invert the colors of the mask.

    Parameters

    Returns Mask

    The inverted mask.

  • Perform an OR operation on two masks.

    Parameters

    Returns Mask

    OR of the two masks.

  • Paint a mask onto another mask and the given position and with the given value.

    Parameters

    Returns Mask

    The painted mask.

  • 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

  • Fill holes in regions of interest.

    Parameters

    Returns Mask

    The filled mask.

  • 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.