Optimized OpenCV extra algorithms for Python
Project description
cv_algorithms
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
- 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/ 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
- Resize an image, maintaining the aspect ratio
As OpenCV's Python bindings (cv2
) represents images as numpy arrays, most algorithms generically work with numpy1 arrays.
Installation
Install the stable version:
pip install cv_algorithms
How to install the bleeding-edge version from GitHub
pip install git+https://github.com/ulikoehler/cv_algorithms.git
How to build yourself - we use Poetry:
poetry build
Potentially, you need to install OpenCV if not already present. I recommend first trying to install without that, since modern Python versions will take care of that automatically.
Usage
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
Contributions of any shape or form are welcome. Please submit a pull request or file an issue on GitHub.
Copyright (c) 2016-2022 Uli Köhler <cv_algorithms@techoverflow.net>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cv_algorithms-1.1.0-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ea451d1077a262e01679cc1a83cdc01d039de68398963d1f09b12465f23c335 |
|
MD5 | 40c27e1808b0c0e1bdbbb6cc1767a467 |
|
BLAKE2b-256 | 1c524787bf288649b58b17db69cad4cec374458a01e448503ebbdcefb7a9760e |