InkGenerator#

class augraphy.utilities.inkgenerator.InkGenerator(ink_type, ink_draw_method, ink_draw_iterations, ink_location, ink_background, ink_background_size, ink_background_color, ink_color, ink_min_brightness, ink_min_brightness_value_range, ink_draw_size_range, ink_thickness_range, ink_brightness_change, ink_skeletonize, ink_skeletonize_iterations_range, ink_text, ink_text_font, ink_text_rotate_range, ink_lines_coordinates, ink_lines_stroke_count_range)[source]#

Bases: object

Core object to generate different inks effect.

Parameters:
  • ink_type (string) – Types of ink, select from “pencil”, “pen”, “marker” or “highlighter”.

  • ink_draw_method – Content of ink generation, select from “lines” or “text”.

  • ink_draw_method – string

  • ink_draw_iterations – Tuple of ints determining the drawing iterations

  • ink_draw_iterations – int

  • ink_location (tuple or string) – Tuple of ints determining location of ink drawings. Or use “random: for random line location.

  • ink_background – Background of ink generation.

  • ink_background – numpy array

  • ink_background_size – Tuple of ints (height, width) or (height, width, channels) determining the size of new background for ink generation. A new background will be created only if ink_background is not provided.

  • ink_background_size – tuple

  • ink_background_color (tuple) – Tuple of ints (BGR) determining the color of background.

  • ink_color (tuple) – Tuple of ints (BGR) determining the color of ink.

  • ink_min_brightness (int) – Flag to enable min brightness in the generated ink.

  • ink_min_brightness_value_range (tuple) – Pair of ints determining the range for min brightness value in the generated ink.

  • ink_draw_size_range (tuple) – Pair of floats determining the range for the size of the ink drawing.

  • ink_thickness_range – Pair of floats determining the range for the thickness of the generated ink.

  • ink_brightness_change (list) – A list of value change for the brightness of the ink. If more than one value is provided, the final value will be randomly selected.

  • ink_skeletonize (int) – Flag to enable skeletonization in the generated drawings.

  • ink_skeletonize_iterations_range (int) – Pair of ints determining the number of iterations in skeletonization process.

  • ink_text – Text value of ink generation, valid only if ink_draw_method is “text”.

  • ink_text – string

  • ink_text_font (list) – List contain paths to font types. Valid only if ink content is “text”.

  • ink_text_rotate_range (tuple) – Tuple of ints to determine rotation angle of “text” based drawings.

  • ink_lines_coordinates (list) – A list contain coordinates of line.

  • ink_lines_stroke_count_range (tuple) – Pair of floats determining the range for the number of created lines.

apply_brightness(image)[source]#

Brighten image based on the minimum brightness value by using Brightness augmentation.

Parameters:

image (numpy.array (numpy.uint8)) – The image to be brighten.

apply_highlighter_effect(ink_image, ink_background)[source]#

Apply foreground image with highlighter effect to background image.

Parameters:
  • ink_image (numpy.array (numpy.uint8)) – Image with highlighter drawings.

  • ink_background (numpy.array (numpy.uint8)) – The background image.

apply_ink_effect(foreground_image, background_image)[source]#

Function to apply various ink effect.

Parameters:
  • foreground_image (numpy.array (numpy.uint8)) – Foreground image with lines or text.

  • background_image (numpy.array (numpy.uint8)) – The background image.

apply_marker_effect(ink_image, ink_background)[source]#

Apply foreground image with marker effect to background image.

Parameters:
  • ink_image (numpy.array (numpy.uint8)) – Image with marker drawings.

  • image (numpy.array (numpy.uint8)) – The background image.

apply_pen_effect(ink_image, ink_background)[source]#

Apply foreground image with pen effect to background image.

Parameters:
  • ink_image (numpy.array (numpy.uint8)) – Image with pen drawings.

  • image (numpy.array (numpy.uint8)) – The background image.

apply_pencil_effect(ink_image, ink_background)[source]#

Apply foreground image with pencil effect to background image.

Parameters:
  • ink_image (numpy.array (numpy.uint8)) – Image with pencil drawings.

  • image (numpy.array (numpy.uint8)) – The background image.

generate_edges(image, repeat=0, randomize=0)[source]#

Generate edges based on image gradients.

Parameters:
  • image (numpy.array (numpy.uint8)) – Image with lines ot text drawings.

  • repeat (int, optional) – Number of recursive edge generation iterations.

  • randomize (int, optional) – Number of recursive edge generation iterations.

generate_ink(ink_type=None, ink_draw_method=None, ink_draw_iterations=None, ink_location=None, ink_background=None, ink_background_size=None, ink_background_color=None, ink_color=None, ink_min_brightness=None, ink_min_brightness_value_range=None, ink_draw_size_range=None, ink_thickness_range=None, ink_brightness_change=None, ink_skeletonize=None, ink_text=None, ink_text_font=None, ink_text_rotate_range=None, ink_lines_coordinates=None, ink_lines_curvy=None, ink_lines_stroke_count_range=None)[source]#

Main function to print ink into the background.

Parameters:
  • ink_type (string, optional) – Types of ink, select from “pencil”, “pen”, “marker” or “highlighter”.

  • ink_draw_method – Content of ink generation, select from “lines” or “text”.

  • ink_draw_method – string, optional

  • ink_draw_iterations – Tuple of ints determining the drawing iterations

  • ink_draw_iterations – int, optional

  • ink_location (tuple or string, optional) – Tuple of ints determining location of ink drawings. Or use “random: for random line location.

  • ink_background – Background of ink generation.

  • ink_background – numpy array, optional

  • ink_background_size – Tuple of ints (height, width) or (height, width, channels) determining the size of new background for ink generation. A new background will be created only if ink_background is not provided.

  • ink_background_size – tuple, optional

  • ink_background_color (tuple, optional) – Tuple of ints (BGR) determining the color of background.

  • ink_color (tuple, optional :param ink_min_brightness: Flag to enable min brightness in the generated ink.) – Tuple of ints (BGR) determining the color of ink.

  • ink_min_brightness_value_range (tuple, optional) – Pair of ints determining the range for min brightness value in the generated ink.

  • ink_draw_size_range (tuple, optional) – Pair of floats determining the range for the size of the ink drawing.

  • ink_thickness_range – Pair of floats determining the range for the thickness of the created ink.

  • ink_brightness_change (list, optional) – A list of value change for the brightness of the ink. If more than one value is provided, the final value will be randomly selected.

  • ink_skeletonize (int, optional) – Flag to enable skeletonization in the generated drawings.

  • ink_skeletonize_iterations_range (int, optional) – Pair of ints determining the number of iterations in skeletonization process.

  • ink_text – Text value of ink generation, valid only if ink_draw_method is “text”.

  • ink_text – string, optional

  • ink_text_font (list, optional) – List contain paths to font types. Valid only if ink content is “text”.

  • ink_text_rotate_range (tuple, optional) – Tuple of ints to determine rotation angle of “text” based drawings.

  • ink_lines_coordinates (list, optional) – A list contain coordinates of line.

  • ink_lines_stroke_count_range (tuple, optional) – Pair of floats determining the range for the number of created lines.

generate_lines(ink_background)[source]#

Generated lines drawing in background image.

Parameters:

ink_backgrounde – The background image.

generate_noise_clusters(image, n_clusters=(200, 200), n_samples=(300, 300), std_range=(5, 10))[source]#

Generate clusters of noise with make_blobs.

Parameters:
  • image (numpy.array (numpy.uint8)) – Image with lines ot text drawings.

  • n_clusters (tuple, optional) – Tuple of ints determining number of noise clusters.

  • n_samples (tuple, optional) – Tuple of ints determining number of noise sample in each cluster.

  • std_range (int, optional) – Tuple of ints determining spreadness of noise clusters.

generate_text(ink_background)[source]#

Generated texts drawing in background image.

Parameters:

ink_backgrounde – The background image.

Overview#

InkGenerator is the base class to generate different ink effect such as pen, pencil, marker or highlighter in the provided background image. It can generate texts or lines with different ink effect in the provide image.