> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ImageProcessingTools Object (IImageProcessingTools Interface)

This object allows you to preprocess images before recognition.

The standard procedure, which uses this object, is as follows:

1. Open an image file using either the **OpenImageFile** or **OpenImageFileFromStream** method. These methods return an opened file as the [**ImageFile**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagefile.md) object.
2. Open a page of the image file using the [**OpenImagePage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagefile-openimagepage.md) of the **ImageFile** object. This method provides access to an image page as the [**Image**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md) object.
3. Preprocess the image page using one of the available methods or implement your own preprocessing algorithm. With the available methods you can do the following operations:
   * remove noise from color photos (**RemoveNoise**, **CreateDenoiseFilterParamsByImage** methods)
   * remove motion blur from photos, equalize their brightness (**RemoveMotionBlur**, **EqualizeBrightness** methods)
   * remove geometrical distortions from an image or stretch it (**CorrectImageGeometry**, **StretchTrapezoidToRectangle**, **StretchImage** methods)
   * suppress color objects in official documents (**SuppressColorObjects** method)
   * remove garbage (excess dots that are smaller than a certain size) from an image (**RemoveGarbage** method)
   * smooth image (**SmoothImageBySquareAverage**, **SmoothImageByGaussianKernel** methods)
   * smooth texture (**SmoothTexture** method)
   * detect orientation of the text on an image and rotate an image either by a predefined angle, or by any custom angle (**DetectOrientationByText**, **RotateImageByRotationType**, **RotateImage** methods)
   * mirror or invert an image (**MirrorImage**, **InvertRegion** methods)
   * crop an image (**CropImage** method)
   * fill with color a region on an image (**FillRegionWithColor** method)
   * convert image to gray or black and white (**ConvertToGray**, **Binarize** methods)
   * convert an internal image plane to a bitmap and vice versa (**ImageToBitmap** and **BitmapToImage** methods)

## Methods

| **Name** | **Description** |
| - | - |
| [**Binarize**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-binarize.md) | Converts an image to black and white. |
| [**BitmapToImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-bitmaptoimage.md) | Converts the specified bitmap to the [**Image**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md) object. |
| [**CalcSuitableForOcr**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-calcsuitableforocr.md) | Shows how suitable is an image for OCR. Possible values are from 0.0 to 1.0. |
| [**ConvertToGray**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-converttogray.md) | Converts an image to gray. |
| [**CorrectImageGeometry**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-correctimagegeometry.md) | Corrects image geometry: perspective distortions, curved text lines. |
| [**CreateDenoiseFilterParamsByImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-createdenoisefilterparamsbyimage.md) | Measures ISO noise on the image and creates the [**DenoiseFilterParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/denoisefilterparams.md) object based on the measurement. |
| [**CropImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-cropimage.md) | Crops an image. |
| [**DetectEmpty**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-detectempty.md) | Detects if the image is empty. |
| [**DetectOrientationByText**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-detectorientationbytext.md) | Detects orientation of an image by text lines. |
| [**DetectRequiredRotation**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-detectrequiredrotation.md) | Detects the rotation that should be applied to the image to return it to the normal (upright) orientation. |
| [**EqualizeBrightness**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-equalizebrightness.md) | Equalizes brightness of an image. |
| [**FillRegionWithColor**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-fillregionwithcolor.md) | Fills the specified region with color. |
| [**FilterColor**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-filtercolor.md) | Removes specified color objects from the entire image or its parts. |
| [**ImageToBitmap**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-imagetobitmap.md) | Converts the [**Image**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md) object to a bitmap. |
| [**InvertRegion**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-invertregion.md) | Inverts either the specified region on an image or the entire image. |
| [**IsSuitableForOcr**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-issuitableforocr.md) | Checks if an image is suitable for OCR. |
| [**MirrorImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-mirrorimage.md) | Mirrors an image either vertically or horizontally. |
| [**OpenImageFile**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-openimagefile.md) | Opens an image file. |
| [**OpenImageFileFromStream**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-openimagefilefromstream.md) | Reads an image file from the specified stream. |
| [**PreprocessCameraImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-preprocesscameraimage.md) | Preprocesses a photo using predefined settings specially designed for different types of photos. |
| [**RemoveGarbage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-removegarbage.md) | Removes isolated clusters of pixels of the specified size which are considered garbage. |
| [**RemoveMotionBlur**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-removemotionblur.md) | Removes motion blur from an image. |
| [**RemoveNoise**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-removenoise.md) | Removes ISO noise from color photos. |
| [**RotateImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-rotateimage.md) | Rotates an image by the specified angle. |
| [**RotateImageByRotationType**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-rotateimagebyrotationtype.md) | Rotates an image by a predefined angle (90 degrees clockwise, 90 degrees counterclockwise, upside down). |
| [**SmoothImageByGaussianKernel**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-smoothimagebygaussiankernel.md) | Smoothes an image by Gaussian kernel. |
| [**SmoothImageBySquareAverage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-smoothimagebysquareaverage.md) | Smoothes the image by averaging over the square neighborhood. |
| [**SmoothTexture**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-smoothtexture.md) | Smoothes texture of an image by a nonlinear filter, preserving sharp edges. |
| [**StretchImage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-stretchimage.md) | Stretches or shrinks the image to the specified size. |
| [**StretchTrapezoidToRectangle**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-stretchtrapezoidtorectangle.md) | Transforms an image so that the specified trapezoid becomes a rectangle. Can be used to manually correct slight perspective distortion. |
| [**SuppressColorObjects**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imageprocessingtools-suppresscolorobjects.md) | Suppresses objects with the specified color in official documents. |

## Output parameter

This object is the output parameter of the [**CreateImageProcessingTools**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine-createxxx.md) method of the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object.

## Samples

> [accordion] C# code
>
> ```csharp theme={null}
> // Sample implementation of a custom image source
> class CustomPreprocessingImageSource : IImageSource
> {
>  public CustomPreprocessingImageSource( IEngine engine )
>  {
>   fileNames = new Queue();
>   imageTools = engine.CreateImageProcessingTools();
>  }
>  ...
>  // Implementation of the IImageSource::GetNextImage, which uses the ImageProcessingTools object
>  public IImage GetNextImage()
>  {
>   while( true ) {
>    if( imageFile == null ) {
>     if( fileNames.Count > 0 ) {
>      imageFile = imageTools.OpenImageFile( (string)fileNames.Dequeue() );
>      nextPageIndex = 0;
>     } else {
>      return null;
>     }
>    }
>    assert( imageFile != null );
>    if( nextPageIndex < imageFile.PagesCount ) {
>     IImage nextPage = imageFile.OpenImagePage( nextPageIndex++ );
>     // Here you can apply any preprocessing that is necessary
>     // ...
>     return nextPage;
>    } else {
>     imageFile = null;
>     continue;
>    }
>   }
>  }
>  IImageProcessingTools imageTools;
>  Queue fileNames;
>  IImageFile imageFile;
>  int nextPageIndex;
> };
> ```
