ImageProcessor
The ImageProcessor
class is a utility class for applying advanced processing on images.
Definition
Module: dynamsoft_utility
class ImageProcessor:
Methods
Method | Description |
---|---|
adjust_brightness |
Adjusts the brightness of the image. |
adjust_contrast |
Adjusts the contrast of the image. |
convert_to_binary_global |
Converts the grayscale image to binary image using a global threshold. |
convert_to_binary_local |
Converts the grayscale image to binary image using local (adaptive) binarization. |
convert_to_gray |
Converts colour image to grayscale. |
crop_image |
Crops an image. |
filter_image |
Applies a specified image filter to an input image and returns the filtered result. |
adjust_brightness
Adjusts the brightness of the image.
def adjust_brightness(self, image_data: ImageData, brightness: int) -> ImageData:
Parameters
image_data
The image data to be processed.
brightness
Brightness adjustment value (positive values increase brightness, negative values decrease brightness). The value range is [-100, 100]
Return value
Returns an ImageData
object representing the processed image.
See Also
adjust_contrast
Adjusts the contrast of the image.
def adjust_contrast(self, image_data: ImageData, contrast: int) -> ImageData:
Parameters
image_data
The image data to be processed.
contrast
Contrast adjustment value (positive values enhance, negative values reduce contrast). The value range is [-100, 100]
Return value
Returns an ImageData
object representing the processed image.
See Also
convert_to_binary_global
Converts the grayscale image to binary image using a global threshold.
def convert_to_binary_global(self, image_data: ImageData, threshold: int = -1, invert: bool = False) -> ImageData:
Parameters
image_data
The image data to be processed.
threshold
Global threshold for binarization(default is -1, automatic calculate the threshold).
invert
If true, invert the binary image (black becomes white and white becomes black).
Return value
Returns an ImageData
object representing the processed image.
See Also
convert_to_binary_local
Converts the grayscale image to binary image using local (adaptive) binarization.
def convert_to_binary_local(self, image_data: ImageData, block_size: int = 0, compensation: int = 0, invert: bool = False) ->ImageData:
Parameters
image_data
The image data to be processed.
block_size
Size of the block for local binarization(default is 0).
compensation
Adjustment value to modify the threshold (default is 0).
invert
If true, invert the binary image (black becomes white and white becomes black).
Return value
Returns an ImageData
object representing the processed image.
See Also
convert_to_gray
Converts colour image to grayscale.
def convert_to_gray(self, image_data: ImageData, r: float = 0.3, g: float = 0.59, b: float = 0.11) -> ImageData:
Parameters
image_data
The image data to be processed.
r
Weight for red channel.
g
Weight for green channel.
b
Weight for blue channel.
Return value
Returns an ImageData
object representing the processed image.
See Also
crop_image
Crops an image.
def crop_image(self, image_data:ImageData, crop_form: Union[Rect,Quadrilateral]) -> Tuple[int, ImageData]:
Parameters
image_data
The image data to be cropped.
crop_form
The cropping form
Return value
Returns an ImageData
object representing the cropped image.
See Also
filter_image
Applies a specified image filter to an input image and returns the filtered result.
def filter_image(self, image_data: ImageData, filter_type: FilterType) -> ImageData:
Parameters
image_data
The image data to be processed.
filter_type
Specifies the type of filter to apply to the input image.
Return value
Returns an ImageData
object representing the processed image.
See Also