colorsort-0.0.1
توضیحات
Perceptually sorted colors
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | colorsort-0.0.1 |
| نام | colorsort |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | James Rowland |
| ایمیل نویسنده | rowland.208@gmail.com |
| آدرس صفحه اصلی | https://github.com/rowland-208/colorsort |
| آدرس اینترنتی | https://pypi.org/project/colorsort/ |
| مجوز | - |
The colorsort python library provides algorithms for sorting colors.
You can use colorsort to:
* Convert an image into a color vector
* Reduce the number of colors in a color vector while maintaining the overall pallete
* Sort the colors in a color vector
For an interactive demo check out [this jupyter notebook](https://github.com/rowland-208/colorsort/blob/main/etc/examples.ipynb).
Example converting image into color vector:
>>> import colorsort as csort
>>> num_x_pixels = 16
>>> num_y_pixels = 16
>>> num_channels = 3
>>> image_shape = (num_x_pixels, num_y_pixels, num_channels)
>>> image_rgb = np.random.randint(0,255,image_shape).astype(np.uint8)
>>> vec_rgb = csort.image_to_vec(image_rgb)
Casting the array to uint8 is crucial.
Colorsort uses opencv under the hood and expects uint8.
Example reducing the number of colors in a color vector
>>> print(vec_rgb.shape)
(256, 3)
>>> vec_rgb_reduced = csort.reduce_colors(vec_rgb, 10)
>>> print(vec_rgb_reduced.shape)
(10, 3)
Colors are reduced using K-means clustering in the LAB colorspace.
If the input has fewer than 10 colors,
a copy of the input color vector is returned.
Example sorting colors in a color vector
>>> vec_rgb_sorted = csort.sort_colors(vec_rgb_reduced)
>>> print(vec_rgb_sorted.shape)
(10, 3)
The color sorting algorighm maps the problem of sorting colors onto
a travelling salesman problem.
The route starts at the brightest color,
and ends at the darkest color.
The distance between two colors is calculated using the
Delta E CIE2000 standard.
By finding the shortest path that visits all colors
the resulting colors are perceptually sorted,
with minimal jumps between neighboring colors.
This is useful for constructing colormaps from arbitrary images.
نیازمندی
| مقدار | نام |
|---|---|
| >=4.5.3 | opencv-python |
| >=3.0 | colormath |
| >=1.19.5 | numpy |
| >=9.0 | ortools |
| >=1.5.4 | scipy |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl colorsort-0.0.1:
pip install colorsort-0.0.1.whl
نصب پکیج tar.gz colorsort-0.0.1:
pip install colorsort-0.0.1.tar.gz