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

# RemoveGarbage Method of the ImageDocument Object

This method removes garbage (excess dots that are smaller than a certain size) from the image. The image can be color as well as black-and-white. In case of a color image the garbage will be detected on the black-and-white image plane and afterwards removed from all planes.

## Syntax

### C++

```cpp theme={null}
HRESULT RemoveGarbage(
  IRegion* Region,
  int      GarbageSize
);
```

### C\#

```csharp theme={null}
void RemoveGarbage(
  IRegion Region,
  int    GarbageSize
);
```

### Visual Basic .NET

```vb theme={null}
Sub RemoveGarbage( _
  Region As IRegion, _
  GarbageSize As Integer _
)
```

## Parameters

**Region**

\[in] This parameter of the [Region](/fine-reader/engine/api-reference/supplementary-objects-and-methods/region) type specifies the set of rectangles to remove garbage from. The coordinates of rectangles are related to the deskewed image. This parameter may be 0. In this case, the garbage is removed from the whole image.

**GarbageSize**

\[in] This variable specifies the maximum area of black dots that are to be considered garbage (in pixels). The value of -1 for this input parameter tells ABBYY FineReader Engine to automatically calculate the size of garbage.

<Warning>
  You cannot call this method with both parameters set to default. If you would like to remove garbage from the whole image, you need to set garbage size; if you would like garbage size to be calculated automatically, you need to specify a region on the image.
</Warning>

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

## See also

[ImageDocument](/fine-reader/engine/api-reference/image-related-objects/imagedocument)
