@@ -134,7 +134,7 @@ for color in vars(MaterialDynamicColors).keys():
134134# Pillow is required to open image to array of pixels
135135from PIL import Image
136136# C++ QuantizeCelebi
137- from materialyoucolor.quantize import QuantizeCelebi, StbLoadImage
137+ from materialyoucolor.quantize import QuantizeCelebi, ImageQuantizeCelebi
138138# Material You's default scoring of colors
139139from materialyoucolor.score.score import Score
140140
@@ -143,17 +143,17 @@ image = Image.open("path_to_some_image.jpg")
143143pixel_len = image.width * image.height
144144image_data = image.getdata()
145145
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-
151146# Quality 1 means skip no pixels
152147quality = 1
153148pixel_array = [image_data[_] for _ in range (0 , pixel_len, quality)]
154149
155150# Run algorithm
156151result = 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+
157157print (result)
158158# {4278722365: 2320, 4278723396: 2405, 4278723657: 2366,...
159159# result is a dict where key is
0 commit comments