Git Product home page Git Product logo

colorfilters's Introduction

colorfilters

Threshold your images in any colorspace!

  • BGR (RGB)
  • HSV
  • HLS (HSL)
  • Lab (CIELAB/L*a*b*)
  • Luv (L*u*v*)
  • YCrCb (YCbCr/YCC)
  • XYZ (CIEXYZ)
  • Grayscale (single channel)

Example Image

Getting Started

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

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

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

(venv) $ python3 -m colorfilters path/to/image.png hsv

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:

(venv) $ python3 -m colorfilters --help
usage: test color thresholding of images in different colorspaces
       [-h] image {bgr,hsv,hls,lab,luv,ycc,xyz,gray}

positional arguments:
  image                 path to image
  {bgr,hsv,hls,lab,luv,ycc,xyz,gray}
                        colorspace to filter in

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

Use inside your own Python projects:

>>> from colorfilters import HSVFilter
>>> import cv2 as cv
>>> 
>>> img = cv.imread("lane.jpg")
>>> window = HSVFilter(img)
>>> window.show()
>>> 
>>> print(f"Image filtered in HSV between {window.lowerb} and {window.upperb}.")
Image filtered in HSV between [51, 0, 183] and [63, 255, 255].

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

>>> window.lowerb     # lower bound used for cv.inRange()
>>> window.upperb     # upper bound used for cv.inRange()
>>> window.mask       # mask from cv.inRange()
>>> window.masked     # image with mask applied
>>> window.img        # image input into the window
>>> window.converted  # image converted into the corresponding colorspace

colorfilters'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.