BrushCue Example: Color Reducer¶
You can use this tool online at https://www.brushcue.com/tools/color-reducer
In [ ]:
!pip install brushcue
In [1]:
import io
from PIL import Image
import brushcue as bc
variable_0 = bc.Composition.monet_women_with_parasol()
variable_1 = variable_0.bounds()
variable_2 = bc.Float.divide(100, bc.Bounds2f.width(variable_1)).min(
bc.Float.divide(100, bc.Bounds2f.height(variable_1))
)
graph = variable_0.palette_reduction(
bc.Composition.to_palette(
bc.Composition.transform(
variable_0,
bc.Transform2.scale(
bc.Transform2.identity(),
bc.Vector2f.from_components(variable_2, variable_2),
),
),
5,
)
)
ctx = bc.Context()
composition = graph.execute(ctx)
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]: