
## PreprocessingFilter class

**Module:** `models`

**Inherits:** `BaseJavaClass`


Base class for image processing commands.


## Constructors

| Name | Description |
| --- | --- |
| [__init__](#constructor) |  |

## Methods

| Name | Return Type | Static | Description |
| --- | --- | --- | --- |
| [add](#add) |  | No | Add filter to collection for further preprocessing. |
| [auto_denoising](#auto_denoising) |  | Yes | 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. |
| [auto_dewarping](#auto_dewarping) |  | Yes | Automatically corrects geometric distortions in the image. Extremely resource intensive! |
| [auto_skew](#auto_skew) |  | Yes | Enables the automatic image skew correction. |
| [binarize](#binarize) |  | Yes | 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. |
| [binarize_and_dilate](#binarize_and_dilate) |  | Yes | Dilation adds pixels to the boundaries of objects in an image. |
| [contrast_correction](#contrast_correction) |  | Yes | Contrast correction filter. |
| [getJavaClass](#getjavaclass) |  | No |  |
| [invert](#invert) |  | Yes | Automatically inverts colors in a document image. |
| [median](#median) |  | Yes | The median filter run through each element of the image and replace each pixel with the median of its neighboring pixels. |
| [resize](#resize) |  | Yes | Rescale image - upscale or downscale image resolution. |
| [rotate](#rotate) |  | Yes | Rotate original image. |
| [scale](#scale) |  | Yes | Rescale image - Upscale or downscale image resolution. InterpolationFilterType bilinear or nearest neighbor. |
| [threshold](#threshold) |  | Yes | Create a binary image based on setting a threshold value on the pixel intensity of the original image. |
| [to_grayscale](#to_grayscale) |  | Yes | Converts an image to grayscale image. Grayscale image have 256 level of light in image (0 to 255). |

## Fields

| Name | Value | Description |
| --- | --- | --- |
| [JAVA_CLASS_NAME](#java_class_name) | `"com.aspose.ocr.PreprocessingFilter"` |  |

### PreprocessingFilter Constructor {#constructor}

```python
__init__(self)
```

### PreprocessingFilter.add {#add}

```python
add(self, filter)
```

Add filter to collection for further preprocessing.

| Parameter | Type | Description |
| --- | --- | --- |
| `filter` | `` | PreprocessingFilter object. |

### PreprocessingFilter.auto_denoising (static) {#auto_denoising}

```python
auto_denoising()
```

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.

### PreprocessingFilter.auto_dewarping (static) {#auto_dewarping}

```python
auto_dewarping()
```

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

### PreprocessingFilter.auto_skew (static) {#auto_skew}

```python
auto_skew()
```

Enables the automatic image skew correction.

### PreprocessingFilter.binarize (static) {#binarize}

```python
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.

### PreprocessingFilter.binarize_and_dilate (static) {#binarize_and_dilate}

```python
binarize_and_dilate()
```

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

### PreprocessingFilter.contrast_correction (static) {#contrast_correction}

```python
contrast_correction()
```

Contrast correction filter.

### PreprocessingFilter.getJavaClass {#getjavaclass}

```python
getJavaClass(self)
```

### PreprocessingFilter.invert (static) {#invert}

```python
invert()
```

Automatically inverts colors in a document image.

### PreprocessingFilter.median (static) {#median}

```python
median()
```

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

### PreprocessingFilter.resize (static) {#resize}

```python
resize(int width, int height)
```

Rescale image - upscale or downscale image resolution.

| Parameter | Type | Description |
| --- | --- | --- |
| `width` | `int` | The new width of the image. |
| `height` | `int` | The new height of the image. |

### PreprocessingFilter.rotate (static) {#rotate}

```python
rotate(float angle)
```

Rotate original image.

| Parameter | Type | Description |
| --- | --- | --- |
| `angle` | `float` | Angle of rotation. Value from -360 to 360. |

### PreprocessingFilter.scale (static) {#scale}

```python
scale(float ratio)
```

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

| Parameter | Type | Description |
| --- | --- | --- |
| `ratio` | `float` | The scaling factor. Recommended value from 0.1 to 1 to shrink. From 1 to 10 to enlarge. |

### PreprocessingFilter.threshold (static) {#threshold}

```python
threshold(int value)
```

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

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `int` | The max value. |

### PreprocessingFilter.to_grayscale (static) {#to_grayscale}

```python
to_grayscale()
```

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

### PreprocessingFilter.JAVA_CLASS_NAME {#java_class_name}

**Type:** `str`

**Value:** `"com.aspose.ocr.PreprocessingFilter"`

