BrushCue Example: Lightness Threshold¶
You can use this tool online at https://www.brushcue.com/tools/lightness-threshold
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
string_constant_2 = brushcue.string_constant("\n if (input.x >= threshold) { \n return vec4<f32>(1.0, 1.0, 1.0, 1.0);\n } else { \n return vec4<f32>(0.0, 0.0, 0.0, 0.0); \n }")
string_constant_3 = brushcue.string_constant("\n// no helpers")
color_profile_oklaba_4 = brushcue.color_profile_ok_lab_a()
color_profile_srgb_5 = brushcue.color_profile_s_r_g_b()
bool_constant_6 = brushcue.bool_constant(False)
dictionary_create_7 = brushcue.dictionary_create()
string_constant_8 = brushcue.string_constant("threshold")
float_add_to_dictionary_9 = brushcue.float_add_to_dictionary(dictionary_create_7, string_constant_8, 0.39999998)
lightness_threshold_shader_10 = brushcue.composition_custom_transformer_shader(input_image_1, string_constant_2, string_constant_3, color_profile_oklaba_4, color_profile_srgb_5, float_add_to_dictionary_9, bool_constant_6)
ctx = brushcue.Context()
result = lightness_threshold_shader_10.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
Out[1]: