Spaces:
Sleeping
Color Removal Tool (color_rm)
This document provides an overview of the Color Removal Tool, explaining its functionality, interface, and workflow.
Overview
The Color Removal Tool is a feature designed to process images by selectively removing colors. The core idea is to keep specific colors in an image while removing all others. This is particularly useful for cleaning up scanned documents, highlighting specific content, or creating stylized images.
The tool operates on the principle of "colors to keep". You select the colors you want to preserve, and the tool removes everything else.
Workflow
The process of using the Color Removal Tool is as follows:
Upload: You start by uploading a PDF or a set of images. If a PDF is uploaded, it is automatically split into individual pages, which are treated as images.
Interface: You are then taken to the color removal interface. Here, you can navigate through the pages of your document one by one.
Color Selection:
- From Image: Click directly on the image to select a color you want to keep. The selected color will appear as a swatch in the "Selected Colors" list.
- Manual Picker: Use the color picker to choose a color manually and add it to the list.
Adjust Settings:
- Match Strictness: This slider controls how closely a color in the image must match a selected color to be kept. A stricter setting means only very similar colors will be kept. A looser setting will keep a wider range of shades.
- Background Fill: You can choose what the removed parts of the image are filled with: black, white, or transparent.
- Region Selection: You can choose to apply the color removal effect only to a specific rectangular region of the image.
Preview: Click the "Preview" button to see the result of your selections and settings applied to the current image.
Save & Continue:
- Save: Saves the processed image for the current page and automatically moves to the next page.
- Apply to All Pages: This will process all pages in the session using the current settings (colors, strictness, etc.). This is a batch operation and may take some time.
Generate PDF: Once you have processed the desired pages, you can generate a PDF of the results. You can choose to include all pages or a specific range of pages.
Processing Logic
The color matching is not based on simple RGB values. Instead, it uses the CIELAB color space. This color space is designed to approximate human vision, so the "distance" between two colors in this space is more perceptually uniform.
When you select a color, the tool calculates its LAB value. Then, for each pixel in the image, it calculates the difference (Delta E) between the pixel's color and the selected colors. If the difference is below the "Match Strictness" threshold for any of the selected colors, the pixel is kept. Otherwise, it is removed.
Keyboard Shortcuts
The following keyboard shortcuts are available in the color removal interface for faster workflow:
ArrowRight: Go to the next page.ArrowLeft: Go to the previous page.Enter: Save the current page and go to the next one.porP: Toggle the preview.rorR: Reset the current image to its original state (a confirmation will be asked).DeleteorBackspace: Remove the last selected color.
Note: Shortcuts are disabled when you are typing in an input field (e.g., the page number input).