The `color-operations` library applies basic color-oriented image operations, serving as a modified fork of Mapbox's `rio-color` library. It specifically removes the `rasterio` dependency and ensures compatibility with Python 3.10 and newer. Version 0.2.0 was released recently, focusing on distribution and Python version updates.
pip install color-operationsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic color operations (sigmoidal contrast, gamma correction, saturation adjustment) on a simulated NumPy image array. The library expects input arrays to be in `(bands, rows, columns)` order with pixel values scaled between 0.0 and 1.0.
Upgrade your Python environment to version 3.9 or higher.
Ensure all image data is provided as raw `numpy.ndarray` objects. If `rasterio` integration is critical, consider using `rio-color` instead.
Before passing data to `color-operations`, ensure your arrays are reshaped (e.g., `image.transpose(2, 0, 1)` for (H,W,C) to (C,H,W)) and rescaled (e.g., `image_255 / 255.0` for 0-255 to 0-1). Convert back if needed for display or other libraries.
Reshape your NumPy array. If your array is `(rows, columns, bands)`, use `your_array.transpose(2, 0, 1)` before passing it to `color-operations` functions.
Verify that your input NumPy array's pixel values are floating-point numbers between 0.0 and 1.0. If starting from an 8-bit image (0-255), convert it with `image_255.astype(np.float32) / 255.0`. Remember to convert output back to 0-255 for display/saving if necessary (e.g., `(output_array * 255).astype(np.uint8)`).
This library does not support `rasterio` directly. Extract the raw `numpy.ndarray` from your `rasterio` dataset to use with `color-operations`. If deep `rasterio` integration is required, use the original `rio-color` library.