A Python package (Python3 ready!) that contains implementations of various OpenCV algorithms are are not available in OpenCV or OpenCV-contrib. This package is intended to be used with OpenCV 3.
Some performance-critical algorithms are written in optimized C code. The C code is accessed using cffi.
Currently implemented:
- Morphological algorithms
- Guo-Hall thinning (C-optimized)
- Zhang-Suen thinning (C-optimized)
- Difference-of-Gaussian transform
- Algorithms on contours
- Masking extraction of convex polygon area from image without rotation
- Scale around reference point or center
- Fast computation of center by coordinate averaging
- Center-invariant rescaling of upright bounding rectangle by x/y factors
- Filter by min/max area
- Sort by area
- Create binary contour mask
- Grassfire transform
- Colorspace metrics & utilities:
- Convert image to any colorspace supported by OpenCV
- Extract any channel from any colorspace directly
- Euclidean RGB distance
- Other structural algorithms
- Which neighboring pixels are set in a binary image?
- Algorithms on text rendering
- Center text at coordinates
- Auto-scale text to fix into box
- Other algorithms
- Remove n percent of image borders
- Popcount (number of one bits) for 8, 16, 32 and 64 bit numpy arrays
As cv2 represents images as numpy arrays, most algorithms generically work with numpy arrays.
# Python2
$ sudo pip install git+https://github.com/ulikoehler/cv_algorithms.git
# or (Python3)
$ sudo pip3 install git+https://github.com/ulikoehler/cv_algorithms.git
Difference of Gaussian transform documentation & example
Grassfire transform documentation & example
Thinning documentation & example
Here's a simple usage showcase:
import cv_algorithms
# img must be a binary, single-channel (grayscale) image.
thinned = cv_algorithms.guo_hall(img)
Contributions of any shape or form are welcome. Please submit a pull request or file an issue on GitHub.
Copyright (c) 2016 Uli Köhler <[email protected]>