BrushCue Example: Emberlight¶

Open In Colab

You can use this tool online at https://www.brushcue.com/tools/emberlight

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

import brushcue as bc


@bc.brushcue_fn
def apply(input_image, strength):
    graded = input_image.color_transformer_shader(
        "let l = clamp(input.x, 0.0, 1.0);\nlet lit = smoothstep(0.30, 0.85, l);\nlet shadow = 1.0 - smoothstep(0.08, 0.52, l);\nlet density = l - 0.13 * sin(l * 3.14159265) * shadow;\nlet ab = input.yz * (0.76 + 0.24 * lit) + vec2f(0.018, 0.038) * lit + vec2f(0.008, 0.014) * shadow;\nlet result = vec3f(density, ab);\nreturn vec4f(mix(input.xyz, result, amount), input.w);",
        "",
        bc.ColorRepresentation.oklab_a(),
        bc.ColorRepresentation.oklab_a(),
        bc.Dictionary.create().add("amount", strength),
    )
    bounds = input_image.bounds()
    return graded.crop(bounds)


strength = 1.0
input_image = bc.Composition.monet_women_with_parasol()
graph = apply(input_image, strength)

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
[wgpu] using backend Vulkan — adapter 'NVIDIA GeForce RTX 5070' (DiscreteGpu), driver 'NVIDIA'
Out[1]:
No description has been provided for this image