# coloranalysis coloranalysis is a python package for calculating the percentage of area covered by one or more colors in an image.
### Prerequisites numpy, opencv and matplotlib are required to execute coloranalysis, you can download them using the following commands: ` pip install numpy pip install opencv-python pip install matplotlib `
### Installing You can either clone or download this repository, or use this command: ` pip install coloranalysis `
### Usage
See [this notebook](https://github.com/sravyadhulipala/coloranalysis/blob/master/example/colorAreasExample.ipynb) for an example program on how to use this package. However, reading this document entirely is recommended.
Let us consider this image of a rainbow.
<img src=https://github.com/sravyadhulipala/coloranalysis/blob/master/example/IPTestRainbow.jpg width=”400” height=”200”>
To know the area covered by red color, or the area covered by multiple colors in the image, we should get the HEX codes using a [colorpicker.](https://imagecolorpicker.com/)
In the above image, HEX codes of all colors are: [“#FE0000”, “#FD6400”, “#FFFF02”, “#008101”, “#0000FE”, “#4B0081”, “#BC31FD”]
Import colorArea, the class that calculates the area of the colors we want, as follows. ` from coloranalysis.colors import colorAreas ` colorAreas takes no arguments.
getArea
returns a list of the percentages of area covered by the given colors.
arguments
hexColours: A list of strings representing the HEX codes.
path: A string specifying the path of the image.
diff: An integer to determine the lower and upper boundaries of the given colors, in the HSV color space.
hexColours - colour with a ‘u’
For a digital image as above, the recommended diff value is 10. While the recommended diff value for images of real-life objects is 30-50. For more information on HSV color space, see [this link.](https://www.linuxtopia.org/online_books/graphics_tools/gimp_advanced_guide/gimp_guide_node51.html)
detectColor
returns a tuple with ‘mask’ and ‘result’ representing the pixels that match a single color
arguments - colour: Values of the color in HSV color space, in the range H[0-360], S[0-100], V[0-100] - img: A numpy array returned by cv2.imread() - hsv_img: A numpy array returned by cv2.cvtColor() - diff: An integer to determine the lower and upper boundaries of the given colors, in the HSV color space.
colour - colour with a ‘u’
‘mask’ and ‘result’ can be used to visualize the presence of the color in the given image
convertHEXColours
returns a tuple with two lists representing values of the colors in HSV colorspace and RGB colorspace respectively.
arguments - hexColours: A list of strings representing the HEX codes.
Metadata
Release files for coloranalysis 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coloranalysis-1.3.2.tar.gz | 3.6 kB | Without provenance | Details for coloranalysis-1.3.2.tar.gz |
Release files / coloranalysis-1.3.2.tar.gz
| Download URL | coloranalysis-1.3.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cb6e542f1c24e68c18321718d9a1ac23afb726714c0d8c620b97de541660619
|
|
BLAKE2b-256 checksum How to use checksums |
af85353d1ed4b07153403ed2492f6583672792d888735a06af9ade17b705eb35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for coloranalysis 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.