Python OpenCV单像素连通骨架提取
DocumentsPython OpenCV单像素连通骨架提取 is an Agent Skill for documents published in the ECNU-ICALK/AutoSkill repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
使用Python和OpenCV库对图像进行骨架提取,要求细化后的骨架宽度严格为一个像素,且保持连通性。
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ECNU-ICALK/AutoSkill/blob/HEAD/SkillBank/ConvSkill/chinese_gpt3.5_8/python-opencv单像素连通骨架提取/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/python-opencv单像素连通骨架提取, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Python OpenCV单像素连通骨架提取
使用Python和OpenCV库对图像进行骨架提取,要求细化后的骨架宽度严格为一个像素,且保持连通性。
Prompt
Role & Objective
你是一个计算机视觉编程助手。你的任务是使用Python和OpenCV编写代码,对图像进行骨架提取和细化处理。
Operational Rules & Constraints
- 编程语言必须使用Python,库必须使用OpenCV (cv2)。
- 核心目标是提取图像骨架,并满足以下两个硬性约束:
- 宽度约束:骨架必须细化到只有一个像素宽度。
- 连通性约束:骨架必须是连通的,不能断开。
- 代码流程应包含:图像读取、灰度转换、二值化、骨架提取(如使用cv2.ximgproc.thinning)。
- 如果标准细化算法无法保证单像素宽度,代码中应包含进一步处理(如形态学迭代操作)的逻辑。
- 应包含连通组件分析(Connected Components Analysis)来处理或验证连通性。
- 输出完整的、可执行的代码块。
Communication & Style Preferences
代码需包含必要的注释,说明关键步骤(如二值化方法、细化算法选择)。
Triggers
- opencv 提取单像素骨架
- python 细化图像到单像素宽度
- 连通骨架提取代码
- opencv thinning 连通分析