display

Displaying and writing SVG files from stroke data.

Matplotlib Display


source

plot_strokes

 plot_strokes (strokes, target_size=200, figsz=5, lw=2,
               bounding_boxes=False, transparent=False, frameon=False,
               fname=None)

Matplotlib Video


source

create_animation

 create_animation (strokes, fname='video.mp4', fps=60, target_size=200,
                   figsz=5, lw=2, trailing_frames=30, facecolor='white',
                   linecolor=None)

source

show_video

 show_video (fname='video.mp4')

SVG Display


source

render_strokes

 render_strokes (strokes, target_size=200, stroke_width=1)

source

randcolor

 randcolor (min_color_intensity=0, max_color_intensity=255)

source

render_deltas

 render_deltas (deltas, target_size=200, color_mode=True, stroke_width=1,
                factor=1.0)

HTML Image display

Code here is from the Tensorflow Lucid project’s showing.py.


source

image_urls

 image_urls (urls, labels=None, domain=None, w=None)

Display a list of images with optional labels.

Args: arrays: A list of image URLs labels: A list of strings to label each image. Defaults to show index if None domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor interpolation. size unchanged if None


source

images

 images (arrays, labels=None, domain=None, w=None)

Display a list of images with optional labels.

Args: arrays: A list of NumPy arrays representing images labels: A list of strings to label each image. Defaults to show index if None domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor interpolation. size unchanged if None


source

image

 image (array, domain=None, w=None, format='png', **kwargs)

Display an image.

Args: array: NumPy array representing the image fmt: Image format e.g. png, jpeg domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor interpolation. size unchanged if None


source

serialize_array

 serialize_array (array, domain=(0, 1), fmt='png', quality=70)

Given an arbitrary rank-3 NumPy array, returns the byte representation of the encoded image.

Args: array: NumPy array of dtype uint8 and range 0 to 255 domain: expected range of values in array, see _normalize_array() fmt: string describing desired file format, defaults to ‘png’ quality: specifies compression quality from 0 to 100 for lossy formats

Returns: image data as BytesIO buffer