Table of contents

ImageProcessor

The ImageProcessor class provides API to crop images based on specified regions.

Definition

Assembly: dynamsoft_capture_vision_flutter

class ImageProcessor

Methods

cropImage

Crops the image (as an ImageData object) to the region defined by the rectangle.

Future<ImageData?> cropImage(ImageData image, DSRect rect) async

Remarks

The method returns an ImageData object that represents the newly cropped image. The method returns null if the cropping fails (invalid rectangle, out of bounds, a null ImageData object, etc.).

cropAndDeskewImage

Crops the image (as an ImageData object) to the region defined by the Quadrilateral.

Future<ImageData?> cropAndDeskewImage(ImageData image, Quadrilateral quadrilateral, {
    int dstWidth = 0,
    int dstHeight = 0,
    int padding = 0,
  }) async

Remarks

The quadrilateral input parameter defines the region to extract as four corner points. The method returns an ImageData object that represents the newly cropped image. The method returns null if the cropping fails (invalid Quadrilateral, out of bounds, a null ImageData object, etc.).

adjustBrightness

Adjusts the brightness of the image (as an ImageData object) based on the specified brightness value.

Future<ImageData?> adjustBrightness(ImageData image, int brightness) async

Remarks

The brightness input parameter ranges from -100 to 100. Positive values increase brightness while negative values decrease it. The method returns null if the adjustment fails.

adjustContrast

Adjusts the contrast of the image (as an ImageData object) based on the specified contrast value.

Future<ImageData?> adjustContrast(ImageData image, int contrast) async

Remarks

The contrast input parameter ranges from -100 to 100. Positive values increase brightness while negative values decrease it. The method returns null if the adjustment fails.

filterImage

Applies a filter (represented with EnumFilterType) to the image (as an ImageData object).

Future<ImageData?> filterImage(ImageData image, EnumFilterType type) async

Remarks

The method returns null if the filtering fails.

convertToGray

Converts the image (as an ImageData object) to grayscale using specified channel weights.

Future<ImageData?> convertToGray(ImageData image, {
  double r = 0.3,
  double g = 0.59,
  double b = 0.11,
}) async

Remarks

  • r: Weight of the red channel (default value is 0.3).
  • g: Weight of the green channel (default value is 0.59).
  • b: Weight of the blue channel (default value is 0.11).

The method returns null if the conversion fails.

convertToBinaryGlobal

Converts the image (as an ImageData object) to a binary (black and white) format using global thresholding.

Future<ImageData?> convertToBinaryGlobal(ImageData image, {
  int threshold = -1,
  bool inverse = false,
}) async

Remarks

  • threshold: A value that ranges between 0 and 255. If -1, Otsu’s method is used to determine the optimal threshold.
  • inverse: If true, inverts the binary colours, resulting in a negative filter on the image.

convertToBinaryLocal

Converts the image (as an ImageData object) to a binary (black and white) format using local adaptive thresholding.

Future<ImageData?> convertToBinaryLocal(
  ImageData image, {
  int blockSize = 0,
  int compensation = 0,
  bool inverse = false,
}) async

Remarks

  • blockSize: Size of the local region (must be odd and >= 3).
  • compensation: Value to adjust the threshold (typically 0-10).
  • inverse: If true, inverts the binary colours, resulting in a negative filter on the image.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: