wenmin-wu/ds-skills/mask-to-polygon-contour-hierarchy
Claude Code and agent skill by wenmin-wu/ds-skills
- community
Checking that the SKILL.md file is still in the repository.
Convert binary segmentation masks to Shapely MultiPolygons using cv2 contour hierarchy to correctly handle interior holes, with Douglas-Peucker simplification
Install
npx vskill@latest install wenmin-wu/ds-skills/mask-to-polygon-contour-hierarchySKILL.md
The same SKILL.md was published earlier as wenmin-wu/ds-skills/mask-to-polygon-contour-hierarchy.
Mask to Polygon via Contour Hierarchy
Overview
Converting binary masks to vector polygons is needed for GIS submissions, vectorized post-processing, or spatial queries. Use cv2.findContours with RETR_CCOMP to get a two-level contour hierarchy: outer contours become polygon shells, their children become holes. Apply Douglas-Peucker simplification and minimum-area filtering to clean up jagged edges.
Quick Start
Workflow
- Threshold mask to binary uint8
findContourswithRETR_CCOMPfor two-level hierarchyapproxPolyDPto simplify contour vertices- Map parent-child hierarchy to shell-hole polygon pairs
- Filter by minimum area, fix invalid geometries with
.buffer(0)
Key Decisions
- RETR_CCOMP vs RETR_TREE: CCOMP gives exactly two levels (shell + holes); TREE is for nested structures
- epsilon: controls simplification — higher = fewer vertices, smoother boundaries
- min_area: removes tiny noise polygons; tune to match annotation resolution
- .buffer(0): fixes self-intersections from approximation
References
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cv/mask-to-polygon-contour-hierarchy/SKILL.md
Popularity
- Repository stars
- 63
- Repository forks
- 4
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wenmin-wu/ds-skills/mask-to-polygon-contour-hierarchy)