# Remove Scan Seam

> Removes vertical center seam red lines from scanned book/atlas images and PDFs using OpenCV TELEA inpainting. Use when the user mentions 中缝版, scan seam, red line removal, gutter line, 红线, 扫描修复, or asks to fix scanned map/atlas pages.

- Skill: `lzhzlw/remove-scan-seam` (Agent Skill, multi-file: 7 files)
- Install (CLI): `npx skillmds@latest add lzhzlw/remove-scan-seam`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lzhzlw/remove-scan-seam/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: lzhzlw (https://skillmd.com/u/lzhzlw)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/lzhzlw/remove-scan-seam

---


# Remove Scan Seam Red Line

Remove the vertical red center seam from scanned "中缝版" (gutter edition) images or PDFs.

## Prerequisites

Python 3.10+ with:

```bash
pip install -r scripts/requirements.txt
```

On this machine, Python is typically at:
`%LOCALAPPDATA%\Programs\Python\Python312\python.exe`

## Quick commands

Run from the skill directory or use absolute script path.

**Single image:**

```bash
python scripts/remove_seam.py --image "path/to/scan.jpg"
```

**Folder of images** (skips files already named `*_已修复*`):

```bash
python scripts/remove_seam.py --folder "path/to/folder"
```

**PDF** (renders each page, inpaints, rebuilds PDF):

```bash
python scripts/remove_seam.py --pdf "path/to/scan.pdf"
python scripts/remove_seam.py --pdf "path/to/scan.pdf" --dpi 300
```

**Custom output path:**

```bash
python scripts/remove_seam.py --image input.jpg --output output.jpg
```

## Output naming

| Input | Default output |
|-------|----------------|
| `foo.jpg` | `foo_已修复.jpg` |
| `【中缝版】地图集.pdf` | `地图集_已修复.pdf` |

Original files are never modified.

## Method

1. Detect reddish pixels near horizontal center (`red - max(g,b) > 42`, `r > 145`)
2. Build a narrow vertical mask around the seam
3. OpenCV `INPAINT_TELEA` on a center strip only (not full-image linear interpolation)
4. Feather strip edges back into the original
5. For PDFs: render at 250 DPI (default), process each page, reassemble

## Agent workflow

1. Confirm input path(s) — image, folder, or PDF
2. Verify Python + deps; install if missing
3. Run `scripts/remove_seam.py` with the right flag
4. Report output paths and page/file counts
5. Do **not** use wide linear interpolation — it smears the gutter worse than the red line

## Limitations

- Book gutter misalignment (left/right page offset) cannot be fully corrected by inpainting
- PDF output is rasterized (image-based pages), not vector-preserving
- Higher `--dpi` improves quality but increases time and file size

## Skill location

Personal skill: `~/.cursor/skills/remove-scan-seam/`

