百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

magicwand

> 编程语言
开源

Python+OpenCV 实现类似 Adobe Photoshop 的魔杖选择工具。

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Python+OpenCV 实现类似 Adobe Photoshop 的魔杖选择工具。

magicwand

Flood filling masking tool.

Displays an image with a tolerance trackbar. A user can click anywhere on the image to seed a selection, where the range of allowable deviation from a color is given by the trackbar value. The mean and standard deviation of the selected region is displayed in the window's status bar.

Getting Started

Install into a Python virtual environment, as you would any other Python project.

bash
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install git+https://github.com/alkasm/magicwand

Run the module as a script on any image you want:

bash
(venv) $ python3 -m magicwand path/to/image.png

Usage

As a script, just run the module directly as above. You can always check the --help flag when running the module as a script for more info:

bash
(venv) $ python3 -m magicwand --help
usage: magic wand selector [-h] image

positional arguments:
  image       path to image

optional arguments:
  -h, --help  show this help message and exit

Use inside your own Python projects:

python
>>> from magicwand import SelectionWindow
>>> import cv2 as cv
>>> 
>>> img = cv.imread("lane.jpg")
>>> window = SelectionWindow(img)
>>> window.show()
>>> 
>>> print(f"Selection mean: {window.mean[:, 0]}.")
Selection mean: [106.76420172  93.78792503  89.71121334].

The window object has a few properties you might be interested in after successfully filtering your image:

python
>>> window.mean     # average value for each channel - from cv.meanStdDev(img, mask)
>>> window.stddev   # standard deviation for each channel - from cv.meanStdDev(img, mask)
>>> window.mask     # mask from cv.floodFill()
>>> window.img      # image input into the window
>>> window.seed     # most recent seed point for cv.floodFill()

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言