ImageJS
    Preparing search index...

    Class Image

    Index

    Constructors

    • Construct a new Image knowing its dimensions.

      Parameters

      • width: number

        Image width.

      • height: number

        Image height.

      • options: ImageOptions = {}

        Image options.

      Returns Image

    Properties

    alpha: boolean

    Whether the image has an alpha channel or not.

    bitDepth: BitDepth

    The number of bits per value in each channel.

    channels: number

    The total number of channels in the image, including the alpha channel.

    colorModel: ImageColorModel

    The color model of the image.

    components: number

    The number of color channels in the image, excluding the alpha channel. A GREY image has 1 component. An RGB image has 3 components.

    height: number

    The number of rows of the image.

    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 pixels in the image (width × height).

    width: number

    The number of columns of the image.

    Methods

    • Modify all the values of the image using the given callback.

      Parameters

      • cb: (value: number) => number

        Callback that modifies a given value.

      Returns void

    • Correct the colors in an image using the reference colors.

      Parameters

      • measuredColors: RgbColor[]

        Colors from the image, which will be compared to the reference.

      • referenceColors: RgbColor[]

        Reference colors.

      Returns Image

      Image with the colors corrected.

    • Crops the image based on the alpha channel This removes lines and columns where the alpha channel is lower than a threshold value.

      Parameters

      Returns Image

      The cropped image.

    • Crop an oriented rectangle from the image. If the rectangle's length or width are not an integers, its dimension is expanded in both directions such as the length and width are integers.

      Parameters

      Returns Image

      The cropped image. The orientation of the image is the one closest to the rectangle passed as input.

    • Divide image pixels by a constant.

      Parameters

      • value: number

        Value which pixels will be divided to.

      • options: DivideOptions = {}

        Divide options.

      Returns Image

      Divided image.

    • Fill the image with a value or a color.

      Parameters

      • value: number | number[]

        Value or color.

      Returns this

      The image instance.

    • Fill the alpha channel with the specified value.

      Parameters

      • value: number

        New channel value.

      Returns this

      The image instance.

    • Fill one channel with a value.

      Parameters

      • channel: number

        The channel to fill.

      • value: number

        The new value.

      Returns this

      The image instance.

    • Get one channel of the image as an array.

      Parameters

      • channel: number

        The channel to fill.

      Returns number[]

      Array with the channel values.

    • Parameters

      • column: number

      Returns number[][]

    • Get the coordinates of a point in the image. The reference is the top-left corner.

      Parameters

      • coordinates: ImageCoordinates

        The point for which you want the coordinates.

      • round: boolean = false

        Whether the coordinates should be rounded. This is useful when you want the center of the image.

      Returns Point

      Coordinates of the point in the format [column, row].

    • Get all the channels of a pixel.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      Returns number[]

      Channels of the pixel.

    • Get all the channels of a pixel using its index.

      Parameters

      • index: number

        Index of the pixel.

      Returns number[]

      Channels of the pixel.

    • Return the raw image data.

      Returns {
          bitDepth: BitDepth;
          channels: number;
          data: ImageDataArray;
          height: number;
          width: number;
      }

      The raw data.

    • Parameters

      • row: number

      Returns number[][]

    • Get the value of a specific pixel channel. Select pixel using coordinates.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      • channel: number

        Channel index.

      Returns number

      Value of the specified channel of one pixel.

    • Get the value of a specific pixel channel. Select pixel using index.

      Parameters

      • index: number

        Index of the pixel.

      • channel: number

        Channel index.

      Returns number

      Value of the channel of the pixel.

    • Get the value of a specific pixel channel. Select pixel using a point.

      Parameters

      • point: Point

        Coordinates of the desired pixel.

      • channel: number

        Channel index.

      Returns number

      Value of the channel of the pixel.

    • Level the image using the optional input and output value. This function allows you to enhance the image's contrast.

      Parameters

      Returns Image

      The levelled image.

    • Compute the mean pixel of an image.

      Parameters

      Returns number[]

      The mean pixel.

    • Compute the median pixel of an image.

      Parameters

      Returns number[]

      The median pixel.

    • Find the min and max values of each channel of the image.

      Returns { max: number[]; min: number[] }

      An object with arrays of the min and max values.

    • Multiply image pixels by a constant.

      Parameters

      • value: number

        Value which pixels will be multiplied to.

      • options: MultiplyOptions = {}

        Multiply options.

      Returns Image

      Multiplied image.

    • Compute direct convolution of an image and return an array with the raw values.

      Parameters

      • kernel: number[][]

        Kernel used for the convolution.

      • Optionaloptions: ConvolutionOptions

        Convolution options.

      Returns Float64Array

      Array with the raw convoluted values.

    • Set the value of a specific pixel channel. Select pixel using coordinates. If the value is out of range it is set to the closest extremety.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      • channel: number

        Channel index.

      • value: number

        Value to set.

      Returns void

    • Set the value of a specific pixel channel. Select pixel using index. If the value is out of range it is set to the closest extremety.

      Parameters

      • index: number

        Index of the pixel.

      • channel: number

        Channel index.

      • value: number

        Value to set.

      Returns void

    • Set all the channels of a pixel.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      • value: number[]

        New color of the pixel to set.

      Returns void

    • Set all the channels of a pixel using its index.

      Parameters

      • index: number

        Index of the pixel.

      • value: number[]

        New channel values of the pixel to set.

      Returns void

    • Set the value of a specific pixel channel. Select pixel using coordinates.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      • channel: number

        Channel index.

      • value: number

        Value to set.

      Returns void

    • Set the value of a specific pixel channel. Select pixel using index.

      Parameters

      • index: number

        Index of the pixel.

      • channel: number

        Channel index.

      • value: number

        Value to set.

      Returns void

    • Set the value of a specific pixel channel. Select pixel using a point.

      Parameters

      • point: Point

        Coordinates of the pixel.

      • channel: number

        Channel index.

      • value: number

        Value to set.

      Returns void

    • Set all the channels of a pixel if the coordinates are inside the image.

      Parameters

      • column: number

        Column index.

      • row: number

        Row index.

      • value: number[]

        New color of the pixel to set.

      Returns void

    • Compute the variance of each channel of an image.

      Parameters

      Returns number[]

      The variance of the channels of the image.