Remove Scan Seam Red Line
Remove the vertical red center seam from scanned "中缝版" (gutter edition) images or PDFs.
Prerequisites
Python 3.10+ with:
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:
python scripts/remove_seam.py --image "path/to/scan.jpg"
Folder of images (skips files already named *_已修复*):
python scripts/remove_seam.py --folder "path/to/folder"
PDF (renders each page, inpaints, rebuilds PDF):
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:
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
- Detect reddish pixels near horizontal center (
red - max(g,b) > 42,r > 145) - Build a narrow vertical mask around the seam
- OpenCV
INPAINT_TELEAon a center strip only (not full-image linear interpolation) - Feather strip edges back into the original
- For PDFs: render at 250 DPI (default), process each page, reassemble
Agent workflow
- Confirm input path(s) — image, folder, or PDF
- Verify Python + deps; install if missing
- Run
scripts/remove_seam.pywith the right flag - Report output paths and page/file counts
- 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
--dpiimproves quality but increases time and file size
Skill location
Personal skill: ~/.cursor/skills/remove-scan-seam/