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

# AddReplaceBlackPixelsRegion Method of the ImageModification Object

This method adds a new "replace black pixels" region to the internal array of "replace black pixels" regions of the [ImageModification](/fine-reader/engine/api-reference/image-related-objects/imagemodification) object. To remove all the "replace black pixels" regions previously added call the [IImageModification::ClearReplaceBlackPixelsRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearreplaceblackpixelsregions-method) method. If the modification must be applied to a single [color](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#color) (or [gray](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#gray)) plane of the image, coordinates of the region should be specified on this color (gray) plane. If the modification must be applied to the whole [ImageModification](/fine-reader/engine/api-reference/image-related-objects/imagemodification) object, the coordinates should be specified on the deskewed [black-and-white](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#black-and-white) image plane.

## Syntax

### C++

```cpp theme={null}
HRESULT AddReplaceBlackPixelsRegion(
  IRegion* Region,
  int      Color,
  int      StrokesExpansion
);
```

### C\#

```csharp theme={null}
void AddReplaceBlackPixelsRegion(
  IRegion Region,
  int    Color,
  int    StrokesExpansion
);
```

### Visual Basic .NET

```vb theme={null}
Sub AddReplaceBlackPixelsRegion( _
  Region As IRegion, _
  Color As Integer, _
  [StrokesExpansion As Integer = 0] _
)
```

## Parameters

Region

\[in] This parameter of the [Region](/fine-reader/engine/api-reference/supplementary-objects-and-methods/region) type specifies the "replace black pixels" region to be added.

Color

\[in] This variable specifies the color with which the black pixels are replaced. The value of this parameter can be -1, which means that the color is transparent.

<Note>
  The int value is calculated from the RGB triplet using the formula: ( red value ) + (256 x green value ) + (65536 x blue value ), where red value is the first triplet component, green value is the second triplet component, blue value is the third triplet component. For example, the int value of the color white equals 16777215.
</Note>

StrokesExpansion

\[in] This variable specifies the expansion (in pixels) of white areas on the black-and-white image plane before replacing. This parameter must be non-negative.

## Return values

This method has no specific return values. It returns the [standard return values of ABBYY FineReader Engine functions](/fine-reader/engine/api-reference/return-codes).

## Remarks

Black pixels on the image inside the "replace black pixels" regions will be replaced with the pixels of the specified color when [IImageDocument::Modify](/fine-reader/engine/api-reference/image-related-objects/imagedocument/modify-method) method is applied. This operation is performed on the [black-and-white](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#black-and-white) image plane but results will be applied to the [gray](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#gray) and [color](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#color) image planes too.

## See also

[ImageModification](/fine-reader/engine/api-reference/image-related-objects/imagemodification)

[ClearReplaceBlackPixelsRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearreplaceblackpixelsregions-method)
