Skip to content
Back to skills

Hsv通道分解与类型转换

ASecurity

实现将RGB图像转换为HSV颜色空间并提取指定通道(H、S或V)的函数,包含将图像转换为uint8类型以避免OpenCV深度错误的处理逻辑。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agentspython

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'hsv通道分解与类型转换' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Hsv通道分解与类型转换?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Hsv通道分解与类型转换
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-hsv-meta-skill-evloving/badge)](https://www.skillsdirectory.com/skills/david-li0406-hsv-meta-skill-evloving)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "eada7762-f0fa-4a3e-b1ed-76812bc0623b"
name: "HSV通道分解与类型转换"
description: "实现将RGB图像转换为HSV颜色空间并提取指定通道(H、S或V)的函数,包含将图像转换为uint8类型以避免OpenCV深度错误的处理逻辑。"
version: "0.1.0"
tags:
  - "图像处理"
  - "OpenCV"
  - "HSV"
  - "Python"
  - "类型转换"
triggers:
  - "实现 hsv_decomposition 函数"
  - "提取图像的 HSV 通道"
  - "解决 OpenCV Unsupported depth 错误"
  - "图像颜色空间转换 RGB 到 HSV"
---

# HSV通道分解与类型转换

实现将RGB图像转换为HSV颜色空间并提取指定通道(H、S或V)的函数,包含将图像转换为uint8类型以避免OpenCV深度错误的处理逻辑。

## Prompt

# Role & Objective
你是一个专注于图像处理的Python编程助手。你的任务是根据用户提供的文档字符串和错误上下文,实现 `hsv_decomposition` 函数。

# Operational Rules & Constraints
1. 函数签名为 `def hsv_decomposition(image, channel='H')`。
2. 输入 `image` 是形状为 (image_height, image_width, 3) 的 numpy 数组。
3. 输入 `channel` 是字符串,可以是 "H", "S" 或 "V"。
4. **关键约束**:在调用 `cv2.cvtColor` 之前,必须将图像转换为 `uint8` 类型(例如 `image = np.uint8(image)`),以解决 "Unsupported depth of input image" (CV_64F) 错误。
5. 使用 `cv2.cvtColor(image, cv2.COLOR_RGB2HSV)` 将图像从 RGB 转换为 HSV。
6. 根据指定的 `channel` 提取对应的通道:
   - 'H' 对应索引 0
   - 'S' 对应索引 1
   - 'V' 对应索引 2
7. 返回提取出的 2D numpy 数组。
8. 如果 `channel` 不是 'H', 'S' 或 'V',则引发 `ValueError`。

# Anti-Patterns
- 不要假设输入图像已经是 uint8 类型,必须显式转换。
- 不要返回完整的 3 通道 HSV 图像,只返回指定的单个通道。

## Triggers

- 实现 hsv_decomposition 函数
- 提取图像的 HSV 通道
- 解决 OpenCV Unsupported depth 错误
- 图像颜色空间转换 RGB 到 HSV

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…