24kchengYe

Seal Extractor — AI skill for Claude Code

AI community

Extract red seals (公章/印章) from scanned documents — OpenCV color filtering + AI gap repair.

How to install Seal Extractor

This entry records only its repository, not the path inside it, so there is no exact command to give. Open 24kchengYe/seal-extractor and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Seal Extractor does

Extract red seals (公章/印章) from scanned documents — OpenCV color filtering + AI gap repair. Claude Code skill.

Alternatives in AI

README

Seal Extractor

**Extract red seals (公章/印章) from scanned documents with pixel-perfect fidelity.**

A Claude Code skill that removes black table lines, handwritten text, and annotations from scanned seals — preserving the original red ink pixels exactly as they are, with optional AI-powered gap repair.

The Problem

When you scan a document with a red official seal (公章), the seal overlaps with:

  • Black table grid lines
  • Handwritten annotations (dates, "盖章", signatures)
  • Other printed text

You need the clean seal isolated — for archiving, reprinting, or digital use — but manual Photoshop work is tedious, and AI image generators change the font style.

The Solution

A two-step pipeline that combines the best of both worlds:

Step 1: OpenCV Color Filtering (local, fast, deterministic)

  • HSV + Lab color space analysis detects red pixels with high precision
  • Black/gray elements (lines, text) are detected and removed
  • Morphological operations clean noise and fill small internal gaps
  • Result: original seal pixels preserved exactly — zero AI hallucination

Step 2: AI Gap Repair (optional, via OpenRouter)

  • Where black lines crossed over the red seal, small white gaps remain after Step 1
  • Calls Gemini image models to naturally inpaint these gaps
  • Preserves original font style and proportions
  • Models tried in order: Gemini 3 Pro → 3.1 Flash → 2.5 Flash

Installation

claude skill install 24kchengYe/seal-extractor

Or clone manually:

cd ~/.claude/skills/
git clone https://github.com/24kchengYe/seal-extractor.git

Dependencies

pip install opencv-python numpy

Usage

In Claude Code

Just tell Claude what you need:

提取这个公章
extract the seal from this image
把公章抠出来,去掉黑线

Claude will automatically use this skill.

Command Line

**Basic extraction (transparent background):**

python scripts/extract_seal.py input.png -o seal_clean.png

**White background:**

python scripts/extr