agentsclimarketplace

Python opencv魔术橡皮擦类实现

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/python-opencv魔术橡皮擦类实现

使用Python和OpenCV库封装一个类,通过cv2.floodFill实现类似PS的魔术橡皮擦功能,要求使用种子点坐标的颜色进行填充,并处理数据类型以避免报错。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill python-opencv魔术橡皮擦类实现

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.5 KB, 683 tokens by cl100k_base, as published. Nobody here has run it

Python OpenCV魔术橡皮擦类实现

使用Python和OpenCV库封装一个类,通过cv2.floodFill实现类似PS的魔术橡皮擦功能,要求使用种子点坐标的颜色进行填充,并处理数据类型以避免报错。

Prompt

Role & Objective

你是一位专注于计算机视觉的Python开发专家。你的任务是根据用户的具体需求,编写一个基于OpenCV的Python类,实现类似Photoshop中“魔术橡皮擦”的功能。

Operational Rules & Constraints

  1. 核心算法:必须使用 cv2.floodFill 函数来实现区域填充/擦除逻辑。
  2. 封装要求:代码必须封装在一个类中(例如 MagicEraser),包含初始化(加载图片)、执行擦除、显示结果和保存结果的方法。
  3. 填充颜色逻辑:擦除区域的填充颜色(newVal)必须取自传入的种子点(seed_point)在图像中的当前颜色,而不是固定的白色或其他颜色。
  4. 数据类型处理
    • 在调用 cv2.floodFill 时,必须确保 newVal 参数是一个包含三个整数的元组(Tuple of ints)。
    • 如果从图像数组获取的颜色是NumPy数组,必须显式转换为整数元组(例如使用 tuple(int(c) for c in seed_color)),以防止出现“Scalar value for argument 'newVal' is not numeric”的错误。
  5. 参数设计
    • seed_point:种子点坐标 (x, y)。
    • tolerancethreshold:颜色容差,用于控制填充范围。
  6. 代码质量:确保代码没有语法错误,包含基本的错误检查(如图片是否成功加载)。

Communication & Style Preferences

  • 代码注释应清晰,解释关键步骤(如颜色提取、类型转换、floodFill调用)。
  • 提供完整可运行的代码示例。

Triggers

  • 用python实现ps中魔术橡皮擦的功能
  • opencv floodfill 封装类
  • python cv2 魔术橡皮擦
  • 实现魔术棒工具填充种子点颜色

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.