@@ -134,7 +134,7 @@ for color in vars(MaterialDynamicColors).keys():
134
134
# Pillow is required to open image to array of pixels
135
135
from PIL import Image
136
136
# C++ QuantizeCelebi
137
- from materialyoucolor.quantize import QuantizeCelebi, StbLoadImage
137
+ from materialyoucolor.quantize import QuantizeCelebi, ImageQuantizeCelebi
138
138
# Material You's default scoring of colors
139
139
from materialyoucolor.score.score import Score
140
140
@@ -143,17 +143,17 @@ image = Image.open("path_to_some_image.jpg")
143
143
pixel_len = image.width * image.height
144
144
image_data = image.getdata()
145
145
146
- # Alternate method
147
- # image_data = StbLoadImage("path_to_some_image.jpg")
148
- # Warning: This method is slower and much more resource intensive
149
- # (eats too much ram) so use it with caution
150
-
151
146
# Quality 1 means skip no pixels
152
147
quality = 1
153
148
pixel_array = [image_data[_] for _ in range (0 , pixel_len, quality)]
154
149
155
150
# Run algorithm
156
151
result = QuantizeCelebi(pixel_array, 128 ) # 128 -> number desired colors, default 128
152
+
153
+ # Alternate C++ method
154
+ # this is generally faster, but gives less control over image
155
+ # result = ImageQuantizeCelebi("path_to_some_image.jpg", quality, 128)
156
+
157
157
print (result)
158
158
# {4278722365: 2320, 4278723396: 2405, 4278723657: 2366,...
159
159
# result is a dict where key is
0 commit comments