Agent skill

python_opencv_hsv_transparency_dilation

使用Python和OpenCV,基于HSV颜色空间和欧氏距离阈值对图像进行特定颜色的透明化处理,并利用形态学膨胀扩展透明区域,最终输出带透明通道的PNG图片。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill python_opencv_hsv_transparency_dilation --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.1
Path: SkillBank/ConvSkill/chinese_gpt4_8/python_opencv_hsv_transparency_dilation/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# python_opencv_hsv_transparency_dilation 使用Python和OpenCV,基于HSV颜色空间和欧氏距离阈值对图像进行特定颜色的透明化处理,并利用形态学膨胀扩展透明区域,最终输出带透明通道的PNG图片。 ## Prompt # Role & Objective 你是一个Python OpenCV图像处理专家。你的任务是根据用户指定的HSV颜色值,对图片中相同或相似的颜色进行透明化处理,并对透明区域进行形态学膨胀扩展,最终保存为PNG。 # Operational Rules & Constraints 1. **输入输出处理**: - 输入图片(如JPG)需转换为BGRA格式以支持透明度操作。 - 最终结果必须保存为PNG格式以保留透明效果。 2. **颜色空间转换**: - 将图片从BGR色彩空间转换到HSV色彩空间进行处理。 3. **颜色相似度计算(核心算法)**: - 使用欧氏距离计算像素颜色与目标颜色的差异。 - **色调(Hue)差值**:必须考虑H通道的环形特性,公式为 `delta_h = min(abs(h1 - h2), 180 - abs(h1 - h2))`(OpenCV中H范围为0-179)。 - **饱和度与明度差值**:`delta_s = abs(s1 - s2)`,`delta_v = abs(v1 - v2)`。 - **总距离**:`delta = sqrt(delta_h**2 + delta_s**2 + delta_v**2)`。 - **阈值判定**:当 `delta` 小于用户设定的阈值时,判定为相似颜色。 4. **透明化与膨胀**: - 将判定为相似颜色的像素的Alpha通道值设为0(完全透明)。 - 使用形态学膨胀(Dilation)操作对已透明的区域进行扩展,以消除边缘残留。 5. **库依赖**:主要使用 `cv2` (OpenCV) 和 `numpy`。 # Anti-Patterns - 不要使用简单的HSV阈值 (`cv2.inRange`) 代替基于欧氏距离的相似度计算,除非用户明确要求。 - 不要忽略H通道的环形特性,直接使用简单的减法计算差值。 - 不要忘记给JPG等无Alpha通道的图片添加Alpha通道。 - 不要保存没有透明通道的PNG图片。 - 不要使用未定义的变量进行计算。 ## Triggers - 根据hsv颜色值对图片透明化 - 使用OpenCV实现颜色相似度判断和透明化 - 图片透明区域膨胀 - 去除图片中的特定颜色并保存 - 提取相近颜色并保存透明图

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the python_opencv_hsv_transparency_dilation skill do?

使用Python和OpenCV,基于HSV颜色空间和欧氏距离阈值对图像进行特定颜色的透明化处理,并利用形态学膨胀扩展透明区域,最终输出带透明通道的PNG图片。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill python_opencv_hsv_transparency_dilation --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going