Skip to content

Commit de2d14b

Browse files
feat: add more docs and enable support for gil-less python
1 parent 8cc4551 commit de2d14b

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

docs/_static/pdfs/mediancut.pdf

32.9 KB
Binary file not shown.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Welcome to Modern Colorthief's documentation!
1919
parity
2020
differences
2121
roadmaps
22+
mmcq
2223
license
2324

2425

docs/mmcq.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Median Cut Color Quantization (MMCQ)
2+
====================================
3+
4+
Median Cut Color Quantization is an algorithm used to reduce the number of colors
5+
in an image while preserving visual similarity. It is widely used in image
6+
processing and color palette extraction.
7+
8+
Overview
9+
--------
10+
11+
The algorithm works by recursively dividing the RGB color space into smaller
12+
"boxes" and selecting representative colors.
13+
14+
Steps
15+
-----
16+
17+
1. Collect all pixels from the image.
18+
2. Place them into a single 3D RGB box.
19+
3. Find the color channel (R, G, or B) with the largest range.
20+
4. Sort pixels along that channel.
21+
5. Split the box at the median point.
22+
6. Repeat until the desired number of colors is reached.
23+
7. Compute the average color of each box to form the palette.
24+
25+
Advantages
26+
----------
27+
28+
- Simple and efficient
29+
- Produces visually good palettes
30+
- Widely used
31+
32+
Reference
33+
---------
34+
35+
:download:`Detailed PDF explanation <_static/pdfs/mediancut.pdf>`

src/rust/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn get_version() -> &'static str {
9595
VERSION.get_or_init(|| env!("CARGO_PKG_VERSION").to_owned())
9696
}
9797
/// A Python module implemented in Rust.
98-
#[pymodule]
98+
#[pymodule(gil_used = false)]
9999
fn _modern_colorthief(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
100100
m.add("__version__", get_version())?;
101101

0 commit comments

Comments
 (0)