Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alkasm/colorfilters
Image thresholding in multiple colorspaces.
https://github.com/alkasm/colorfilters
computer-vision image-processing opencv
Last synced: 18 days ago
JSON representation
Image thresholding in multiple colorspaces.
- Host: GitHub
- URL: https://github.com/alkasm/colorfilters
- Owner: alkasm
- License: mit
- Created: 2017-06-11T05:05:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T06:13:12.000Z (about 3 years ago)
- Last Synced: 2024-10-12T16:27:26.420Z (about 1 month ago)
- Topics: computer-vision, image-processing, opencv
- Language: Python
- Homepage:
- Size: 967 KB
- Stars: 100
- Watchers: 3
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](readme-example.png)
## Getting Started
Install into a Python virtual environment, as you would any other Python project.
```sh
$ 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:
```sh
(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:
```sh
(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 inoptional arguments:
-h, --help show this help message and exit
```Use inside your own Python projects:
```python
>>> 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:
```python
>>> 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
```