Giter Club home page Giter Club logo

magicwand's Introduction

magicwand

A Python+OpenCV implementation similar to Adobe Photoshop's magic wand selection tool.

Displays an image with a tolerance trackbar. A user can click anywhere on the image to select a region with similar colors, where the range of allowable deviation from a color is given by the trackbar value.

usage

import cv2
from magicwand import SelectionWindow
image = cv2.imread('lane.jpg', 0)
window = SelectionWindow('Selection Window', image)
window.show()

files

example.py     An example script showing usage of the module magicwand.py
lane.jpg       An example image for the example script
LICENSE.txt    MIT license
magicwand.py   Main module containing the SelectionWindow class

methods

There are some internal ("private") methods to run the selection task and modify the displayed image, and there are some public methods implemented in magicwand.py which can help get some information about the accepted selection:

   min, max = getMinMax() returns the min and max color inside the selection mean, stddev = getMeanStdDev() returns the mean and standard deviation of color inside the selection

Both functions return two 3-vector numpy arrays if the image is 3-channel, otherwise they return two single values.

future

In the future, support will be added to add to the current selection, and maybe subtract as well. Allowing the change of colorspaces may be helpful, but will only make sense if each channel will have their own sliders; having a range of hue values the the same range of saturation values doesn't really make sense otherwise. I may build out the SelectionWindow class to a more general ImageWindow class to make it easier for people to add trackbars and mouseclick events and listen to them.

magicwand's People

Contributors

alkasm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.