> For the complete documentation index, see [llms.txt](https://developer.topazlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.topazlabs.com/image-models/removal-and-cleanup.md).

# Removal & Cleanup

Remove dust, scratches, objects, and backgrounds from images while preserving natural structure.

### Models

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Dust &#x26; Scratch 2</strong></td><td>Automatically removes dust, specks, and scratches from scans and prints.</td><td><a href="https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2FoZTDAWOnOuDlznw3tjZa%2FDust__Scratch_2_(Ex_1)_slider.jpg?alt=media&#x26;token=c2694b86-aef6-4e31-807f-9e7d87de9524">https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2FoZTDAWOnOuDlznw3tjZa%2FDust__Scratch_2_(Ex_1)_slider.jpg?alt=media&#x26;token=c2694b86-aef6-4e31-807f-9e7d87de9524</a></td><td><a href="https://developer.topazlabs.com/image-models/removal-and-cleanup/dust-and-scratch-2.md">Dust &amp; Scratch 2</a></td></tr><tr><td><strong>Image Object Matting</strong></td><td>Cuts out a specific object using a bounding box.</td><td><a href="https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2Fq8jRhySNhAjTLS3ZDbv0%2FObject_Matting_slider.jpg?alt=media&#x26;token=eb72f51c-5ec7-400d-a5fb-2a459d0b7282">https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2Fq8jRhySNhAjTLS3ZDbv0%2FObject_Matting_slider.jpg?alt=media&#x26;token=eb72f51c-5ec7-400d-a5fb-2a459d0b7282</a></td><td><a href="https://developer.topazlabs.com/image-models/removal-and-cleanup/image-object-matting.md">Image Object Matting</a></td></tr><tr><td><strong>Background Removal</strong></td><td>Removes the background and returns the subject on transparency.</td><td><a href="https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2FidVFBFBVdpN8KLCRmRRQ%2FBG_Remover_Cow_slider.jpg?alt=media&#x26;token=ca59327b-767c-4462-842d-e128c839ba93">https://4007072434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJkSwaYgAsTQke14gpXAF%2Fuploads%2FidVFBFBVdpN8KLCRmRRQ%2FBG_Remover_Cow_slider.jpg?alt=media&#x26;token=ca59327b-767c-4462-842d-e128c839ba93</a></td><td><a href="https://developer.topazlabs.com/image-models/removal-and-cleanup/background-removal.md">Background Removal</a></td></tr></tbody></table>

{% hint style="warning" %}
Dust & Scratch 1 is deprecated and will be retired no sooner than December 9, 2026. Dust & Scratch 2 replaces it. See [Model Deprecations](https://developer.topazlabs.com/resources/model-deprecations.md) for replacements and migration steps.
{% endhint %}

### Best Use Cases

* **Dust & Scratch 2.** Restore scanned prints, negatives, and slides by removing dust, specks, scratches, and surface damage.
* **Image Object Matting.** Cut out one specific object in a busy scene by drawing a box around it.
* **Background Removal.** Isolate the main subject for product listings, portraits, and design assets with clean, detailed edges.

### Endpoints

| Endpoint                                               | Models                                                     |
| ------------------------------------------------------ | ---------------------------------------------------------- |
| `https://api.topazlabs.com/image/v1/restore-gen/async` | Dust & Scratch 2                                           |
| `https://api.topazlabs.com/image/v1/matting/async`     | Image Object Matting, Background Removal (PNG output only) |

Requests are `multipart/form-data`. Pass the image as the `image` field (or reference a previous upload with `source_id` or `source_url`), set `model` to the value shown on the model's page, and add any model settings as extra form fields. The response returns a `process_id` and `eta`; poll `GET /status/{process_id}` and download the result from `GET /download/{process_id}`.

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "https://api.topazlabs.com/image/v1/matting/async" \
  -H "X-API-Key: $TOPAZ_API_KEY" \
  -F "image=@product.jpg" \
  -F "model=RemoveBG" \
  -F "output_type=rgba" \
  -F "output_format=png"  # default is jpeg
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import fs from 'fs';
import FormData from 'form-data';

const form = new FormData();
form.append("image", fs.createReadStream("product.jpg"));
form.append("model", "RemoveBG");
form.append("output_type", "rgba");

const response = await fetch("https://api.topazlabs.com/image/v1/matting/async", {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.TOPAZ_API_KEY,
    ...form.getHeaders(),
  },
  body: form,
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status} ${await response.text()}`);
}

console.log(await response.json());
```

{% endtab %}

{% tab title="Python" %}

```python
import os
import requests

with open("product.jpg", "rb") as image:
    response = requests.post(
        "https://api.topazlabs.com/image/v1/matting/async",
        headers={"X-API-Key": os.environ["TOPAZ_API_KEY"]},
        files={"image": image},
        data={
            "model": "RemoveBG",
            "output_type": "rgba",
        },
    )

response.raise_for_status()
print(response.json())
```

{% endtab %}
{% endtabs %}

### Parameters

Request parameters (`image`, `source_id`, `source_url`, `model`, `output_format`, `webhook_url`) are the same for every image endpoint and are listed on the Request Parameters page. Model settings are listed on each model's page.

### Limitations

These models accept up to 256 MP input and output and don't change resolution. Image Object Matting and Background Removal always return PNG. For a full restoration, run Dust & Scratch 2 first, then an upscaling model such as Wonder 3.5.

### Helpful Resources

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-play">:play:</i></td><td><h4>Image Quickstart</h4></td><td>Quickly get started with our Image API.</td><td></td></tr><tr><td><i class="fa-file-brackets-curly">:file-brackets-curly:</i></td><td><h4>API Reference</h4></td><td>View our API reference to view the entire schema.</td><td><a href="https://playground.topazlabs.com/">https://playground.topazlabs.com/</a></td></tr><tr><td><i class="fa-square-root-variable">:square-root-variable:</i></td><td><h4>Model Pricing</h4></td><td>Learn how we price our models.</td><td></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.topazlabs.com/image-models/removal-and-cleanup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
