> ## 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.

# IEditablePictureObject

> IEditablePictureObject in ABBYY FlexiCapture scripts: edit page images with crop, deskew, despeckle, binarize, contrast filter, and stamp removal methods.

## What it does

Represents a picture that can be edited in ABBYY FlexiCapture. The object is an extension of the [IPictureObject](/flexi-capture/appendix/scripts/ipictureobject) interface.

<Note>
  This object is not available on the Web Verification Station for checking rules locally.
</Note>

## Methods

| Method                                                                                         | Description                                                                                                                                                                                                                                                   | Allowable image color           |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
| `ApplyContourSmoother( params: IContourSmootherParams )`                                       | Applies the contour smoother to an image.                                                                                                                                                                                                                     | For gray and color images       |
| `ApplyLocalContrastFilter( params: ILocalContrastParams )`                                     | Applies the non-adaptive contrast filter to an image.                                                                                                                                                                                                         | For gray and color images       |
| `ApplyMultiscaleLocalContrastFilter()`                                                         | Applies the adaptive contrast filter to an image. Use this method to transform an image into a scan.                                                                                                                                                          | For gray and color images       |
| `ApplyShadowsHighlightsFilter( params: IShadowsHighlightsParams )`                             | Applies shadow highlighting to an image.                                                                                                                                                                                                                      | For gray and color images       |
| `ApplySigmaFilter()`                                                                           | Removes digital noise from an image.                                                                                                                                                                                                                          | For all images                  |
| `AutoCrop( [optional] type: string )`                                                          | Automatically crops an image. Possible values of the `type` parameter are `Photo`, `Scan`, and `Generic`. The default is `Generic`.                                                                                                                           | For all images                  |
| `Binarize( params: IBinarizationParams )`                                                      | Converts colors on an image to black-and-white. Has a different set of properties than the `ConvertToBW` method.                                                                                                                                              | For gray and color images       |
| `ConvertToBW( [optional] threshold: int )`                                                     | Converts an image to black-and-white. You can specify a brightness threshold value. Values higher than the threshold are considered white, and values lower than the threshold are considered black. Brightness threshold values can range from `0` to `255`. | For all images                  |
| `CreateBinarizationParams(): IBinarizationParams`                                              | Creates an object with parameters for the `Binarize` method.                                                                                                                                                                                                  | For all images                  |
| `CreateContourSmootherParams(): IContourSmootherParams`                                        | Creates an object with parameters for the contour smoother.                                                                                                                                                                                                   | For all images                  |
| `CreateLocalContrastFilterParams(): ILocalContrastParams`                                      | Creates an object with parameters for the contrasting action. Parameters inside the filter are set to default.                                                                                                                                                | For all images                  |
| `CreateShadowsHighlightsFilterParams(): IShadowsHighlightsParams`                              | Creates an object with parameters for the action of changing a shadow light effect.                                                                                                                                                                           | For all images                  |
| `Crop( rect: string )`                                                                         | Crops the image outside the specified rectangle.                                                                                                                                                                                                              | For all images                  |
| `CutOut( rect: string ): IEditablePictureObject`                                               | Cuts a specified rectangle from the image and returns this rectangle.                                                                                                                                                                                         | For all images                  |
| `Deskew( [optional] byLines: bool, [optional] byBlackSquares: bool, [optional] byText: bool )` | Deskews the image. Image skew can be corrected based on straight lines, black squares, or text. By default, the `byText` parameter is set to `true`.                                                                                                          | For all images                  |
| `Despeckle( [optional] garbageSize: int )`                                                     | Removes noise from black-and-white images. Speckles up to the specified size are removed. If the `garbageSize` parameter is not specified, the size is detected automatically.                                                                                | Only for black-and-white images |
| `Erase( rectangle: string, [optional] red: int, [optional] green: int, [optional] blue: int )` | Erases an area on the image. You can specify the color to erase the area with. By default, the black color is used.                                                                                                                                           | For all images                  |
| `FlipHorizontal()`                                                                             | Flips the image horizontally.                                                                                                                                                                                                                                 | For all images                  |
| `FlipVertical()`                                                                               | Flips the image vertically.                                                                                                                                                                                                                                   | For all images                  |
| `FreeScale( newWidth: int, newHeight: int, newResolution: int )`                               | Resizes the page according to the new values.                                                                                                                                                                                                                 | For all images                  |
| `Invert( [optional] rectString: string )`                                                      | Inverts the image. You can specify a string with coordinates of the rectangle to invert.                                                                                                                                                                      | For all images                  |
| `NewRectsArray(): IRects`                                                                      | Creates a new collection of rectangles. Returns an [IRects](/flexi-capture/appendix/scripts/irects) object.                                                                                                                                                   | Only for color images           |
| `RemoveMotionBlur()`                                                                           | Removes blurring caused by document, camera, or scanner movement during scanning.                                                                                                                                                                             | For all images                  |
| `RemoveStamps( color: TColorToFilter, rects: IRects )`                                         | Deletes color stamps and other marks of a specified color from an image. For more information, see [Remove color stamps from an image](#remove-color-stamps-from-an-image).                                                                                   | Only for color images           |
| `RemoveStampsExt( colorsToFilter: string )`                                                    | Deletes color stamps and other marks from an image using an improved algorithm that removes more colors. This is the recommended method. For more information, see [Remove additional stamp colors](#remove-additional-stamp-colors).                         | Only for color images           |
| `Rotate( angle: int )`                                                                         | Rotates the image clockwise to the given angle.                                                                                                                                                                                                               | For all images                  |
| `Scale( ratio: int )`                                                                          | Stretches or compresses the image relative to the base size of 100%. The method applies to image pixel size only. Image physical size remains unchanged.                                                                                                      | For all images                  |

<Note>
  The `rect` parameter passed to the `CutOut` and `Crop` methods is a string in the form `"[left, top, right, bottom]"`. To get this string, call the `ToString` method of any [IRect](/flexi-capture/appendix/scripts/irect) object, or use the `Rect` method of [IFlexiCaptureTools](/flexi-capture/appendix/scripts/iexportimagetools) (`FCTools`).
</Note>

## Remove color stamps from an image

The `RemoveStamps` method deletes color stamps and other marks of a specified color from an image. This method works only for color images.

| Parameter | Type                                               | Description                                       |
| --------- | -------------------------------------------------- | ------------------------------------------------- |
| `color`   | [TColorToFilter](/flexi-capture/t-color-to-filter) | The color of stamps to remove.                    |
| `rects`   | [IRects](/flexi-capture/appendix/scripts/irects)   | The rectangle collection of the stamps to remove. |

The following sample script for an [On User Command](/flexi-capture/appendix/scripts-shell/user-command) event removes red stamps from all pages. The entire page area is searched for stamps.

```csharp theme={null}
MainWindow.TaskWindow.OpenDocument( MainWindow.TaskWindow.EditorWindow.Document );
foreach (IPage page in MainWindow.TaskWindow.EditorWindow.Document.Pages)
{
    if (page.Picture.IsColor)
    {
        IEditablePictureObject editablePicture = page.Picture.CreateEditableCopy();
        IRects rects = editablePicture.NewRectsArray();
        rects.AddRect(0, 0, editablePicture.Width - 1, editablePicture.Height - 1); // all page
        editablePicture.RemoveStamps(TColorToFilter.CTF_Red, rects);
        page.ReplaceImage(editablePicture);
    }
}
```

## Remove additional stamp colors

The `RemoveStampsExt` method deletes color stamps and other marks of a specified color from an image. It is similar to `RemoveStamps`, but it uses an improved algorithm that removes more colors. This is the recommended method for removing stamps.

The `colorsToFilter` parameter (`string`) sets the color of stamps to remove:

* Accepts the following string values: `Red`, `Green`, `Blue`, `Yellow`, `Orange`, `LightBlue`, and `Purple` (not case-sensitive).
* You can specify multiple values separated by commas, for example `"Red, Green"`.
* You can specify an empty string (`""`) to let the program select the appropriate stamp color automatically. The program deletes any stamps it detects on an image that have one of the allowed color values.

The following sample script for an [On User Command](/flexi-capture/appendix/scripts-shell/user-command) event removes red and green stamps from all pages:

```csharp theme={null}
foreach (IPage page in Document.Pages)
{
    if (page.Picture.IsColor)
    {
        IPictureObject picture = page.Picture;
        IEditablePictureObject editablePicture = picture.CreateEditableCopy();
        editablePicture.RemoveStampsExt("Red, Green");
        page.ReplaceImage(editablePicture);
    }
}
```

## Custom processing stage examples

These scripts show how to use `IEditablePictureObject` methods in custom processing stages.

### Apply a local contrast filter

This script creates an object with parameters for the local contrast filter, sets the parameters manually, and applies the filter to an image.

```csharp theme={null}
foreach( IPage page in Document.Pages )
{
    IPictureObject picture = page.Picture;
    IEditablePictureObject editablePicture = picture.CreateEditableCopy();
    // Creating an object with parameters (parameters are set by default)
    ILocalContrastParams localContrastParams = editablePicture.CreateLocalContrastFilterParams();
    // Setting parameters whose values will be changed afterwards
    localContrastParams.Radius = 7;
    localContrastParams.NoiseLevel = 200;
    // Applying a filter to the image
    editablePicture.ApplyLocalContrastFilter( localContrastParams );
    // Replacing an image of a page with the modified one
    page.ReplaceImage( editablePicture );
}
```

### Binarize an image with custom parameters

This script creates an object with parameters for the `Binarize` method and converts the image to black-and-white with the set parameters.

```csharp theme={null}
foreach ( IPage page in Document.Pages )
{
    IPictureObject picture = page.Picture;
    IEditablePictureObject editablePicture = picture.CreateEditableCopy();
    // Creating an object with parameters (parameters are set by default)
    IBinarizationParams binarizationParams =  editablePicture.CreateBinarizationParams();
    // Setting the true or false parameter
    binarizationParams.SmoothTexture = false;
    editablePicture.Binarize( binarizationParams );
    page.ReplaceImage( editablePicture );
}
```

### Enhance selected pages from the Verification Station

This script increases contrast, removes digital noise, applies automatic cropping, and removes blurring on the selected pages. A Verification Station operator runs the script.

```csharp theme={null}
foreach( IPageItem pageItem in MainWindow.Selection.PageItems) {
    pageItem.TaskWindow.CloseEditorWindow();
    pageItem.TaskWindow.OpenDocument(  pageItem.DocumentItem.Document );
    IPage page = pageItem.Page;
    IEditablePictureObject editablePicture = page.Picture.CreateEditableCopy();
    // Applies the image transformations
    editablePicture.AutoCrop();
    editablePicture.ApplySigmaFilter();
    editablePicture.ApplyMultiscaleLocalContrastFilter();
    editablePicture.RemoveMotionBlur();
    // Replaces the original document image with the edited image
    page.ReplaceImage( editablePicture );
    pageItem.TaskWindow.CloseDocument(  pageItem.DocumentItem.Document );
}
```
