Table of contents

ImageProcessor

The ImageProcessor class provides APIs for processing images.

Name Description
cropImage() Crops an image using a rectangle.
cropAndDeskewImage() Crops and deskew an image using a quadrilateral.
adjustBrightness() Adjusts the brightness of the image.
adjustContrast() Adjusts the contrast of the image.
filterImage() Applies a specified image filter to an input image.
convertToGray() Converts a colour image to grayscale.
convertToBinaryGlobal() Converts a grayscale image to a binary image using a global threshold.
convertToBinaryLocal() Converts a grayscale image to a binary image using local (adaptive) binarization.

cropImage

Crops an image using a rectangle.

cropImage(image: Blob, roi: DSRect): Promise<DSImageData>;

Parameters

image: The image to be saved, of type Blob.

roi: The rectangle to be cropped.

Return Value

A promise that resolves with the cropped image data.

cropAndDeskewImage

Crops and deskews an image using a quadrilateral.

cropAndDeskewImage:(image: Blob, roi:Core.Quadrilateral) => Promise<Core.DSImageData>;

Parameters

image: The image to be saved, of type Blob.

roi: The quadrilateral defining the region of interest to be cropped and deskewed.

Return Value

A promise that resolves with the cropped and deskewed image data.

adjustBrightness

Adjusts the brightness of the image.

adjustBrightness(image: Blob, brightness: number): Promise<DSImageData>;

Parameters

image: The image to be adjusted.

brightness: Brightness adjustment value (range: [-100, 100]).

Return Value

A promise that resolves with the adjusted image data.

adjustContrast

Adjusts the contrast of the image.

adjustContrast(image: Blob, contrast: number): Promise<DSImageData>;

Parameters

image: The image to be adjusted.

contrast: Contrast adjustment value (range: [-100, 100]).

Return Value

A promise that resolves with the adjusted image data.

filterImage

Applies a specified image filter to an input image.

filterImage(image: Blob, filterType: EnumFilterType): Promise<DSImageData>;

Parameters

image: The image to be filtered.

filterType: The type of filter to apply.

Return Value

A promise that resolves with the filtered image data.

convertToGray

Converts a colour image to grayscale.

convertToGray(image: Blob, R?: number, G?: number, B?: number): Promise<DSImageData>;

Parameters

image: The image to be converted.

R: [R=0.3] - Weight for the red channel.

G: [G=0.59] - Weight for the green channel.

B: [B=0.11] - Weight for the blue channel.

Return Value

A promise that resolves with the grayscale image data.

convertToBinaryGlobal

Converts a grayscale image to a binary image using a global threshold.

convertToBinaryGlobal(image: Blob, threshold?: number, invert?: boolean): Promise<DSImageData>;

Parameters

image: The grayscale image.

threshold: [threshold=-1] Global threshold for binarization (-1 for automatic calculation).

invert: [invert=false] Whether to invert the binary image.

Return Value

A promise that resolves with the binary image data.

convertToBinaryLocal

Converts a grayscale image to a binary image using local (adaptive) binarization.

convertToBinaryLocal(image: Blob, blockSize?: number, compensation?: number, invert?: boolean): Promise<DSImageData>;

Parameters

image: The grayscale image.

blockSize: [blockSize=0] Size of the block for local binarization.

compensation: [compensation=0] Adjustment value to modify the threshold.

invert: [invert=false] Whether to invert the binary image.

Return Value

A promise that resolves with the binary image data.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: