com.aspose.ocr

Class PreprocessingFilter



  • public class PreprocessingFilter
    extends Object
    Base class for image processing commands.
    Author:
    Aspose
    • Constructor Detail

      • PreprocessingFilter

        public PreprocessingFilter()
    • Method Detail

      • 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:
        BinarizeFilter object.
      • Resize

        public static PreprocessingFilter Resize(int width,
                                                 int height,
                                                 InterpolationFilterType type)
        Rescale image - upscale or downscale image resolution.
        Parameters:
        width - The new width of the image.
        height - The new height of the image.
        type - InterpolationFilterType @see InterpolationFilterType
        Returns:
        ResizeFilter object.
      • Resize

        public static PreprocessingFilter Resize(int width,
                                                 int height)
        Rescale image - Upscale or downscale image resolution. InterpolationFilterType = bilinear or nearest neighbor @see InterpolationFilterType
        Parameters:
        width - The new width of the image.
        height - The new height of the image.
        Returns:
        ResizeFilter object.
      • BinarizeAndDilate

        public static PreprocessingFilter BinarizeAndDilate()
        Dilation adds pixels to the boundaries of objects in an image.
        Returns:
        DilateFilter object.
      • Invert

        public static PreprocessingFilter Invert()
        Automatically inverts colors in a document image.
        Returns:
        InvertFilter object.
      • Rotate

        public static PreprocessingFilter Rotate(float angle)
        Rotate original image.
        Parameters:
        angle - Angle of rotation. Value from -360 to 360.
        Returns:
        RotateFilter object.
      • Scale

        public static PreprocessingFilter Scale(float ratio)
        Rescale image - Upscale or downscale image resolution. InterpolationFilterType default bilinear or nearest neighbor @see InterpolationFilterType
        Parameters:
        ratio - The scaling factor. Recommended value from 0.1 to 1 to shrink. From 1 to 10 to enlarge.
        Returns:
        ScaleFilter object.
      • Scale

        public static PreprocessingFilter Scale(float ratio,
                                                InterpolationFilterType type)
        Rescale image - Upscale or downscale image resolution.
        Parameters:
        ratio - The scaling factor. Recommended value from 0.1 to 1 to shrink. From 1 to 10 to enlarge.
        type - InterpolationFilterType @see InterpolationFilterType
        Returns:
        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:
        GrayscaleFilter object.
      • Threshold

        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:
        value - The max value.
        Returns:
        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:
        MedianFilter object.
      • ContrastCorrection

        public static PreprocessingFilter ContrastCorrection()
        Contrast correction filter.
        Returns:
        ContrastCorrectionFilter object.
      • add

        public void add(PreprocessingFilter filter)
        Add the new filter to the collection to further run all operations. Consistency in the collection matters.
        Parameters:
        filter - New operation to add to filter list.