BrushCue Example: Color Reducer¶

Open In Colab

You can use this tool online at https://www.brushcue.com/tools/color-reducer

In [ ]:
!pip install brushcue
In [1]:
import brushcue
from PIL import Image
import io

input_image_1 = brushcue.composition_monet_women_with_parasol() # insert your own image here
input_bounds_2 = brushcue.composition_bounds(input_image_1)
image_height_3 = brushcue.bounds2f_height(input_bounds_2)
scale_y_4 = brushcue.float_divide(100.0, image_height_3)
image_width_5 = brushcue.bounds2f_width(input_bounds_2)
scale_x_6 = brushcue.float_divide(100.0, image_width_5)
uniform_scale_7 = brushcue.float_min(scale_x_6, scale_y_4)
vector_2_float_from_components_8 = brushcue.vector2f_from_components(uniform_scale_7, uniform_scale_7)
transform_2d_identity_9 = brushcue.transform2_identity()
scale_transform_10 = brushcue.transform2_scale(transform_2d_identity_9, vector_2_float_from_components_8)
resized_image_11 = brushcue.composition_transform(input_image_1, scale_transform_10)
computed_palette_12 = brushcue.composition_palette(resized_image_11, 5)
composition_palette_reduction_13 = brushcue.composition_palette_reduction(input_image_1, computed_palette_12)

ctx = brushcue.Context()
result = composition_palette_reduction_13.execute(ctx)
composition = result.as_composition()
data_bytes = composition.to_image_bytes(ctx)
img = Image.open(io.BytesIO(data_bytes))
img.thumbnail((400, 400)) # remove this line for full resolution
img
new pipeline: blend_Alpha_rgba16float_compute_bg_false_fg_false
new pipeline: color_transformer_shader_rgba16float_compute_16683618810569050274_inarr_false
new pipeline: color_transformer_shader_rgba16float_compute_254168329423630019_inarr_false
Out[1]:
No description has been provided for this image