PreprocessingFilter

Inheritance: java.lang.Object

public class PreprocessingFilter

Base class for image processing commands.

Constructors

ConstructorDescription
PreprocessingFilter()

Fields

FieldDescription
Empty

Methods

MethodDescription
Binarize()Converts an image to black-and-white image.
Binarize(Rectangle area)Converts a part of the image to black-and-white image.
Resize(int width, int height, InterpolationFilterType type)Rescale image - upscale or downscale image resolution.
Resize(int width, int height)Rescale image - Upscale or downscale image resolution.
BinarizeAndDilate()Dilation adds pixels to the boundaries of objects in an image.
BinarizeAndDilate(Rectangle area)Dilation adds pixels to the boundaries of objects in a part of the image.
Invert()Automatically inverts colors in a document image.
Invert(Rectangle area)Automatically inverts colors in a part of the image.
Rotate(float angle)Rotate original image.
Rotate(float angle, Rectangle area)Rotate the part of the image.
Scale(float ratio)Rescale image - Upscale or downscale image resolution.
Scale(float ratio, InterpolationFilterType type)Rescale image - Upscale or downscale image resolution.
ToGrayscale()Converts an image to grayscale image.
Threshold(int value)Create a binary image based on setting a threshold value on the pixel intensity of the original image.
Threshold(int value, Rectangle area)Create a binary image part based on setting a threshold value on the pixel intensity of the original image part.
Median()The median filter run through each element of the image and replace each pixel with the median of its neighboring pixels.
Median(Rectangle area)The median filter run through each element of the part of the image and replace each pixel with the median of its neighboring pixels.
AutoDenoising()Enables the use of an additional neural network to improve the image - reduce noise.
AutoDewarping()Automatically corrects geometric distortions in the image.
AutoDenoising(Rectangle area)Enables the use of an additional neural network to improve the part of the image - reduce noise.
AutoSkew()Enables the automatic image skew correction.
AutoSkew(Rectangle area)Enables the automatic image part skew correction.
ContrastCorrection()Contrast correction filter.
ContrastCorrection(Rectangle area)Contrast correction filter for the part of the image.
add(PreprocessingFilter filter)Add the new filter to the collection to further run all operations.

PreprocessingFilter()

public PreprocessingFilter()

Empty

public static final PreprocessingFilter Empty

Binarize()

public static PreprocessingFilter Binarize()

Converts an image to black-and-white image. Binary images are images whose pixels have only two possible intensity values. They are normally displayed as black and white. Numerically, the two values are often 0 for black, and 255 for white. Binary images are produced by auto thresholding an image.

Returns: PreprocessingFilter - BinarizeFilter object.

Binarize(Rectangle area)

public static PreprocessingFilter Binarize(Rectangle area)

Converts a part of the image to black-and-white image. Binary images are images whose pixels have only two possible intensity values. They are normally displayed as black and white. Numerically, the two values are often 0 for black, and 255 for white. Binary images are produced by auto thresholding an image.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - BinarizeFilter object.

Resize(int width, int height, InterpolationFilterType type)

public static PreprocessingFilter Resize(int width, int height, InterpolationFilterType type)

Rescale image - upscale or downscale image resolution.

Parameters:

ParameterTypeDescription
widthintThe new width of the image.
heightintThe new height of the image.
typeInterpolationFilterTypeInterpolationFilterType @see InterpolationFilterType

Returns: PreprocessingFilter - ResizeFilter object.

Resize(int width, int height)

public static PreprocessingFilter Resize(int width, int height)

Rescale image - Upscale or downscale image resolution. InterpolationFilterType = bilinear or nearest neighbor @see InterpolationFilterType

Parameters:

ParameterTypeDescription
widthintThe new width of the image.
heightintThe new height of the image.

Returns: PreprocessingFilter - ResizeFilter object.

BinarizeAndDilate()

public static PreprocessingFilter BinarizeAndDilate()

Dilation adds pixels to the boundaries of objects in an image.

Returns: PreprocessingFilter - DilateFilter object.

BinarizeAndDilate(Rectangle area)

public static PreprocessingFilter BinarizeAndDilate(Rectangle area)

Dilation adds pixels to the boundaries of objects in a part of the image.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - DilateFilter object.

Invert()

public static PreprocessingFilter Invert()

Automatically inverts colors in a document image.

Returns: PreprocessingFilter - InvertFilter object.

Invert(Rectangle area)

public static PreprocessingFilter Invert(Rectangle area)

Automatically inverts colors in a part of the image.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - InvertFilter object.

Rotate(float angle)

public static PreprocessingFilter Rotate(float angle)

Rotate original image.

Parameters:

ParameterTypeDescription
anglefloatAngle of rotation. Value from -360 to 360.

Returns: PreprocessingFilter - RotateFilter object.

Rotate(float angle, Rectangle area)

public static PreprocessingFilter Rotate(float angle, Rectangle area)

Rotate the part of the image.

Parameters:

ParameterTypeDescription
anglefloatAngle of rotation. Value from -360 to 360.
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - RotateFilter object.

Scale(float ratio)

public static PreprocessingFilter Scale(float ratio)

Rescale image - Upscale or downscale image resolution. InterpolationFilterType default bilinear or nearest neighbor @see InterpolationFilterType

Parameters:

ParameterTypeDescription
ratiofloatThe scaling factor. Recommended value from 0.1 to 1 to shrink. From 1 to 10 to enlarge.

Returns: PreprocessingFilter - ScaleFilter object.

Scale(float ratio, InterpolationFilterType type)

public static PreprocessingFilter Scale(float ratio, InterpolationFilterType type)

Rescale image - Upscale or downscale image resolution.

Parameters:

ParameterTypeDescription
ratiofloatThe scaling factor. Recommended value from 0.1 to 1 to shrink. From 1 to 10 to enlarge.
typeInterpolationFilterTypeInterpolationFilterType @see InterpolationFilterType

Returns: PreprocessingFilter - ScaleFilter object.

ToGrayscale()

public static PreprocessingFilter ToGrayscale()

Converts an image to grayscale image. Grayscale image have 256 level of light in image (0 to 255).

Returns: PreprocessingFilter - GrayscaleFilter object.

Threshold(int value)

public static PreprocessingFilter Threshold(int value)

Create a binary image based on setting a threshold value on the pixel intensity of the original image.

Parameters:

ParameterTypeDescription
valueintThe max value.

Returns: PreprocessingFilter - BinarizeFilter object.

Threshold(int value, Rectangle area)

public static PreprocessingFilter Threshold(int value, Rectangle area)

Create a binary image part based on setting a threshold value on the pixel intensity of the original image part.

Parameters:

ParameterTypeDescription
valueintThe max value.
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - BinarizeFilter object.

Median()

public static PreprocessingFilter Median()

The median filter run through each element of the image and replace each pixel with the median of its neighboring pixels.

Returns: PreprocessingFilter - MedianFilter object.

Median(Rectangle area)

public static PreprocessingFilter Median(Rectangle area)

The median filter run through each element of the part of the image and replace each pixel with the median of its neighboring pixels.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - MedianFilter object.

AutoDenoising()

public static PreprocessingFilter AutoDenoising()

Enables the use of an additional neural network to improve the image - reduce noise. Useful for images with scan artifacts, distortion, spots, flares, gradients, foreign elements.

Returns: PreprocessingFilter - AutoDenoisingFilter object.

AutoDewarping()

public static PreprocessingFilter AutoDewarping()

Automatically corrects geometric distortions in the image. Extremely resource intensive!

Returns: PreprocessingFilter - AutoDewarpingFilter object.

AutoDenoising(Rectangle area)

public static PreprocessingFilter AutoDenoising(Rectangle area)

Enables the use of an additional neural network to improve the part of the image - reduce noise. Useful for images with scan artifacts, distortion, spots, flares, gradients, foreign elements.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - AutoDenoisingFilter object.

AutoSkew()

public static PreprocessingFilter AutoSkew()

Enables the automatic image skew correction.

Returns: PreprocessingFilter - AutoSkewFilter object.

AutoSkew(Rectangle area)

public static PreprocessingFilter AutoSkew(Rectangle area)

Enables the automatic image part skew correction.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - AutoSkewFilter object.

ContrastCorrection()

public static PreprocessingFilter ContrastCorrection()

Contrast correction filter.

Returns: PreprocessingFilter - ContrastCorrectionFilter object.

ContrastCorrection(Rectangle area)

public static PreprocessingFilter ContrastCorrection(Rectangle area)

Contrast correction filter for the part of the image.

Parameters:

ParameterTypeDescription
areajava.awt.RectangleRectangle to preprocess.

Returns: PreprocessingFilter - ContrastCorrectionFilter object.

add(PreprocessingFilter filter)

public void add(PreprocessingFilter filter)

Add the new filter to the collection to further run all operations. Consistency in the collection matters.

Parameters:

ParameterTypeDescription
filterPreprocessingFilterNew operation to add to filter list.