Scratch Removal (IP Command)

From Grooper Wiki

This article is about the current version of Grooper.

Note that some content may still need to be updated.

2025 2.80

Scratch Removal is an IP Command detects and removes or repairs scratches from film-based images.

The Scratch Removal IP Command in Grooper is a specialized image processing tool designed to automatically detect and remove scratches from scanned images of film-based media, such as microfilm, microfiche, aperture cards, and 35mm slides. Scratches on these media appear as bright, distracting lines or streaks that can obscure content and reduce image quality.

What is Scratch Removal?

Scratch Removal is an IP Command that analyzes an image to identify and suppress scratches—typically high-intensity white lines caused by physical damage to film. The command generates a dropout mask to target these regions and applies a configurable dropout method to remove or diminish the scratches, while preserving the rest of the image content.

This process is essential for improving the clarity of film scans, making them more suitable for downstream tasks such as OCR, data extraction, or archival.

The original scanned image. The dropout mask of all the scratches detected. The final, cleaned up, output.  

When and why to use Scratch Removal

Use the Scratch Removal command when working with images from film-based sources that show visible scratches or streaks. These artifacts can:

  • Obscure important content
  • Interfere with OCR and data extraction
  • Reduce the overall quality and readability of the image

By removing scratches, you can enhance image quality, improve recognition accuracy, and reduce the need for manual cleanup.

How Scratch Removal works

The Scratch Removal command follows these general steps:

  1. The input image is converted to grayscale (if necessary) for analysis.
  2. A threshold is automatically determined based on the image histogram and the "Sensitivity" property, identifying high-intensity pixels likely to be scratches.
  3. A raw mask is generated, highlighting all pixels above the threshold.
  4. The mask is refined by filtering out regions that do not meet the "Maximum Thickness" and "Minimum Weight" criteria, ensuring only true scratches are targeted.
  5. The final mask is applied to the image using the selected dropout method, removing or suppressing the scratches.

This approach ensures that only genuine scratches are removed, while important image content is preserved.

Configuration and usage

Scratch Removal is typically used as part of an IP Profile, which is a sequence of image processing steps. Each step is represented by an IP Step, which specifies an IP Command to execute—such as Scratch Removal.

To use Scratch Removal:

  1. Add an IP Step to your IP Profile and set its "Command" property to Scratch Removal.
  2. Configure the following key properties to tune the detection and removal process:
    • "Sensitivity": Controls how aggressively scratches are detected. Higher values detect more scratches; lower values are more conservative.
    • "Maximum Thickness": Sets the upper limit on the width of features considered scratches. Decrease to exclude wide features; increase to allow thicker scratches.
    • "Minimum Weight": Specifies the minimum pixel count (area) for a region to be considered a scratch. Increase to ignore small marks; decrease to detect very fine scratches.
  3. Configure "Dropout Method" settings as needed.
    • There are two Dropout Methods to choose from:
      • Fill (Default) - Replaces scratches with a solid color.
        • By default, the Fill Color is set to "none". When set to "none" Grooper will detect a color from the image's background and use that.
      • Inpaint - Digitally restores masked regions by estimating and filling in missing or damaged areas using advanced algorithms. Because scratches will often overlap text, this method is often preferred. It will help preserve text better than the Fill method.
    • (Optional) The "Mask Dilation Factor" will dilate or erode the dropout mask applied to the image. Expanding this value may help ensure no stray artifacts remain, but setting it too high may remove nearby text content. Always start with "0" and go from there.
  4. (Best practice) Test the IP Step and IP Profile to ensure proper function. Review diagnostics, such as the "Scratch Mask" and logs.
  5. Run the IP Profile on your images and review the results.

Example scenarios

  • Microfilm and microfiche with fine scratches: The command detects and removes thin, bright lines without affecting the underlying content.
  • Aperture card scans: Scratches and streaks are suppressed, improving the clarity of engineering drawings or text.

Diagnostics and tuning

When run in diagnostic mode, Scratch Removal generates output images and logs to help you tune the command:

  • Scratch Mask: Shows the detected scratch regions as a mask, allowing you to verify detection accuracy.
  • Threshold Log: Reports the automatically detected threshold and histogram analysis.
  • Log Messages: Details the steps taken and parameters used during processing.

Use these diagnostics to fine-tune detection parameters and ensure that only scratches are being removed.

Supported pixel formats

Scratch Removal supports the following pixel formats:

  • Pixel8bppGrayscale
  • Pixel24bppBgr

Images are automatically converted to grayscale for processing if needed.

Best practices

  • Start with moderate "Sensitivity" and "Maximum Thickness" settings to avoid removing non-scratch features.
  • Use the diagnostic outputs to verify that only scratches are being targeted.
  • Adjust parameters incrementally and re-test to achieve optimal results.
  • Always review processed images to ensure important content is preserved.

Integration in IP Profiles

Scratch Removal can be combined with other IP Commands in an IP Profile to create a complete image processing workflow. Each command is applied in sequence, with the output of one command serving as the input to the next.

Summary

The Scratch Removal IP Command is a robust solution for cleaning up film-based images in Grooper. By accurately detecting and removing scratches, it ensures your images are clear, readable, and ready for further processing.