File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Welcome to Modern Colorthief's documentation!
1919 parity
2020 differences
2121 roadmaps
22+ mmcq
2223 license
2324
2425
Original file line number Diff line number Diff line change 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 >`
Original file line number Diff line number Diff 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 ) ]
9999fn _modern_colorthief ( _py : Python , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
100100 m. add ( "__version__" , get_version ( ) ) ?;
101101
You can’t perform that action at this time.
0 commit comments