Table of contents

ImageProcessor

The class ImageProcessor is a utility class for managing the image data. It provides functionality for saving images to files and reading images from files.

Definition

Assembly: DynamsoftCaptureVisionBundle.xcframework

  • Objective-C
  • Swift
  1. @interface DSImageProcessor : NSObject
    
  2. class ImageProcessor : NSObject
    

Methods

Method Description
cropImage(imageData,rect) Crops an image based on the provided rectangle or quadrilateral.
cropAndDeskewImage(imageData,quad,dstWidth,dstHeight,padding) Crops and deskew an image based on the provided quadrilateral and additional information.
cropAndDeskewImage(imageData,quad) Crops and deskew an image based on the provided quadrilateral.
adjust(imageData,brightness) Adjusts the brightness of an image.
adjust(imageData,contrast) Adjusts the contrast of an image.
filterImage Applies a filter to an image.
convertToGray(imageData) Converts an image to grayscale.
convertToGray(imageData,rgb) Converts an image to grayscale.
convertToBinaryGlobal(imageData) Converts an image to binary using a global threshold.
convertToBinaryGlobal(imageData,threshold,invert) Converts an image to binary using a global threshold.
convertToBinaryLocal(imageData) Converts an image to binary using a local threshold.
convertToBinaryLocal(imageData,blockSize,compensation,invert) Converts an image to binary using a local threshold.

cropImage(imageData,rect,error)

Crops an image based on the provided rectangle.

  • Objective-C
  • Swift
  1. - (nullable DSImageData *)cropImage:(DSImageData *)imageData
                               rect:(DSRect *)rect
                              error:(NSError * _Nullable * _Nullable)error;
    
  2. func cropImage(imageData: ImageData, rect: Rect, error: UnsafeMutablePointer<NSError?>?) -> ImageData
    

Parameters

imageData: The ImageData to modify.

rect: The Rect to crop the image.

error: An NSError pointer. If an error occurs, it will represent the error information.

Return Value

The cropped ImageData.

cropAndDeskewImage(imageData,quad,dstWidth,dstHeight,padding)

Crops and deskews an image based on the provided quadrilateral and additional information.

  • Objective-C
  • Swift
  1. - (nullable ImageData*)cropAndDeskewImage:(DSImageData*)imageData
                                     quad:(DSQuadrilateral*)quad
                                 dstWidth:(NSInteger)dstWidth
                                dstHeight:(NSInteger)dstHeight
                                  padding:(NSInteger)padding
                                    error:(NSError * _Nullable * _Nullable)error;
    
  2. func cropAndDeskewImage(imageData: ImageData, quad: Quadrilateral, dstWidth: Int, dstHeight: Int, padding: Int) throws -> ImageData
    

Parameters

imageData: The ImageData to modify.

quad: The Quadrilateral to crop the image.

dstWidth: The width of the destination image.

dstHeight: The height of the destination image.

padding: The padding value.

error: An NSError pointer. If an error occurs, it will represent the error information.

cropAndDeskewImage(imageData,quad)

Crops and deskews an image based on the provided quadrilateral. The arguments dstWidth, dstHeight, and padding are set to 0.

  • Objective-C
  • Swift
  1. - (nullable ImageData*)cropAndDeskewImage:(DSImageData*)imageData
                                     quad:(DSQuadrilateral*)quad;
                                    error:(NSError * _Nullable * _Nullable)error
    
  2. func cropAndDeskewImage(imageData: ImageData, quad: Quadrilateral) throws -> ImageData
    

Parameters

imageData: The ImageData to modify.

quad: The Quadrilateral to crop the image.

error: An NSError pointer. If an error occurs, it will represent the error information.

adjust(imageData,brightness)

Adjusts the brightness of an image.

  • Objective-C
  • Swift
  1. - (DSImageData *)adjust:(DSImageData *)imageData
             brightness:(NSInteger)brightness;
    
  2. func adjust(imageData: ImageData, brightness: Int) -> ImageData
    

Parameters

imageData: The ImageData to modify.

brightness: The amount to adjust the brightness by.

Return Value

The modified ImageData.

adjust(imageData,contrast)

Adjusts the contrast of an image.

  • Objective-C
  • Swift
  1. - (DSImageData *)adjust:(DSImageData *)imageData
               contrast:(NSInteger)contrast;
    
  2. func adjust(imageData: ImageData, contrast: Int) -> ImageData
    

Parameters

imageData: The ImageData to modify.

contrast: The amount to adjust the contrast by.

Return Value

The modified ImageData.

filterImage

Applies a filter to an image.

  • Objective-C
  • Swift
  1. - (DSImageData *)filterImage:(DSImageData *)imageData
                  filterType:(DSFilterType)filterType;
    
  2. func filterImage(imageData: ImageData, filterType: FilterType) -> ImageData
    

Parameters

imageData: The ImageData to modify.

filterType: The type of filter to apply.

Return Value

The modified ImageData.

convertToGray(imageData)

Converts an image to grayscale.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToGray:(DSImageData *)imageData;
    
  2. func convertToGray(imageData: ImageData) -> ImageData
    

Parameters

imageData: The ImageData to modify.

Return Value

The converted grayscale ImageData.

convertToGray(imageData,r,g,b)

Converts an image to grayscale.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToGray:(DSImageData *)imageData
                             r:(CGFloat)r
                             g:(CGFloat)g
                             b:(CGFloat)b;
    
  2. func convertToGray(imageData: ImageData, r: Float, g: Float, b: Float) -> ImageData
    

Parameters

imageData: The ImageData to modify.

r: The weight for the red channel.

g: The weight for the green channel.

b: The weight for the blue channel.

Return Value

The converted grayscale ImageData.

convertToBinaryGlobal(imageData)

Converts an image to binary using a global threshold.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToBinaryGlobal:(DSImageData *)imageData;
    
  2. func convertToBinaryGlobal(imageData: ImageData) -> ImageData
    

Parameters

imageData: The ImageData to modify.

Return Value

The converted binary ImageData.

convertToBinaryGlobal(imageData,threshold,invert)

Converts an image to binary using a global threshold.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToBinaryGlobal:(DSImageData *)imageData
                             threshold:(NSInteger)threshold
                                invert:(BOOL)invert;
    
  2. func convertToBinaryGlobal(imageData: ImageData, threshold: Int, invert: Bool) -> ImageData
    

Parameters

imageData: The ImageData to modify.

threshold: The threshold value.

invert: Whether to invert the binary image.

Return Value

The converted binary ImageData.

convertToBinaryLocal(imageData)

Converts an image to binary using a local threshold.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToBinaryLocal:(DSImageData *)imageData;
    
  2. func convertToBinaryLocal(imageData: ImageData) -> ImageData
    

Parameters

imageData: The ImageData to modify.

Return Value

The converted binary ImageData.

convertToBinaryLocal(imageData,blockSize,compensation,invert)

Converts an image to binary using a local threshold.

  • Objective-C
  • Swift
  1. - (DSImageData *)convertToBinaryLocal:(DSImageData *)imageData
                            blockSize:(NSInteger)blockSize
                         compensation:(NSInteger)compensation
                               invert:(BOOL)invert;
    
  2. func convertToBinaryLocal(imageData: ImageData, blockSize: Int, compensation: Int, invert: Bool) -> ImageData
    

Parameters

imageData: The ImageData to modify.

blockSize: The block size for local thresholding.

compensation: The compensation value for local thresholding.

invert: Whether to invert the binary image.

Return Value

The converted binary ImageData.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: