BrushCue Example: Camera Moving Distortion¶
You can use this tool online at https://www.brushcue.com/tools/camera-moving-distortion
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
alpha_transform_2 = brushcue.composition_linear_transform(input_image_1, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.3)
transform_2d_identity_3 = brushcue.transform2_identity()
transform_2d_identity_4 = brushcue.transform2_identity()
vector_2_float_from_components_5 = brushcue.vector2f_from_components(21.0, 46.0)
composition_bounds_6 = brushcue.composition_bounds(input_image_1)
composition_bounds_7 = brushcue.composition_bounds(input_image_1)
composition_bounds_8 = brushcue.composition_bounds(input_image_1)
composition_bounds_9 = brushcue.composition_bounds(input_image_1)
vector_2_float_from_components_10 = brushcue.vector2f_from_components(39.0, -20.0)
second_offset_11 = brushcue.vector2f_passthrough(vector_2_float_from_components_5)
bounds2f_min_x_12 = brushcue.bounds2f_min_x(composition_bounds_6)
bounds2f_min_y_13 = brushcue.bounds2f_min_y(composition_bounds_7)
bounds2f_width_14 = brushcue.bounds2f_width(composition_bounds_8)
bounds2f_height_15 = brushcue.bounds2f_height(composition_bounds_9)
first_offset_16 = brushcue.vector2f_passthrough(vector_2_float_from_components_10)
vector_2_float_get_x_17 = brushcue.vector2f_x(first_offset_16)
vector_2_float_get_x_18 = brushcue.vector2f_x(second_offset_11)
vector_2_float_get_y_19 = brushcue.vector2f_y(first_offset_16)
vector_2_float_get_y_20 = brushcue.vector2f_y(second_offset_11)
transform_2d_translation_21 = brushcue.transform2_translation(transform_2d_identity_3, second_offset_11)
transform_2d_translation_22 = brushcue.transform2_translation(transform_2d_identity_4, first_offset_16)
absolute_value_23 = brushcue.abs(vector_2_float_get_x_17)
absolute_value_24 = brushcue.abs(vector_2_float_get_x_18)
absolute_value_25 = brushcue.abs(vector_2_float_get_y_19)
absolute_value_26 = brushcue.abs(vector_2_float_get_y_20)
first_blend_27 = brushcue.composition_blend_alpha(alpha_transform_2, input_image_1, transform_2d_translation_22)
float_max_28 = brushcue.float_max(absolute_value_23, absolute_value_24)
float_max_29 = brushcue.float_max(absolute_value_25, absolute_value_26)
second_blend_30 = brushcue.composition_blend_alpha(alpha_transform_2, first_blend_27, transform_2d_translation_21)
max_x_31 = brushcue.float_passthrough(float_max_28)
max_y_32 = brushcue.float_passthrough(float_max_29)
float_multiply_33 = brushcue.float_multiply(max_x_31, 2.0)
float_multiply_34 = brushcue.float_multiply(max_y_32, 2.0)
float_add_35 = brushcue.float_add(bounds2f_min_x_12, max_x_31)
float_add_36 = brushcue.float_add(bounds2f_min_y_13, max_y_32)
float_subtract_37 = brushcue.float_subtract(bounds2f_width_14, float_multiply_33)
float_subtract_38 = brushcue.float_subtract(bounds2f_height_15, float_multiply_34)
bounds_2d_float_from_x_y_width_height_39 = brushcue.bounds2f_from_x_y_width_height(float_add_35, float_add_36, float_subtract_37, float_subtract_38)
cropped_output_40 = brushcue.composition_crop(second_blend_30, bounds_2d_float_from_x_y_width_height_39)
ctx = brushcue.Context()
result = cropped_output_40.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]: