Generating Images in Python with OpenCV

These Python scripts demonstrates algorithmic approaches to creating image content for the Pausch Bridge. These are parameterized but are not interactive. The scripts use the Python bindings for the OpenCV library available via pip as opencv-contrib-python.

Installation Requirements

The code requires a working installation of Python 3 with OpenCV and its dependency NumPy. For suggestions on setting up your system please see Python 3 Installation.

pb_csv_to_png.py

This script converts a CSV file of intensity values into a color PNG image. This is used in the Spreadsheet Animation example, subsequently animated using pb_animate_image.py.

Script code: pb_csv_to_png.py

../_images/cellular-preview.png

Sample output as colorized representation of spreadsheet data, upscaled for preview.

pb_gen_rainbow_img.py

Generate a PNG image with a rainbow of vertical stripes spanning all hues.

Script code: pb_gen_rainbow_img.py

../_images/rainbow.png

Sample output sized for default 228 pixel bridge video width.

pb_gen_palette_img.py

Generate a PNG image with a color palette loaded from a CSV text file.

Script code: pb_gen_palette_img.py

The following colors were sampled from an image of the Mark Rothko painting, No 1 (Royal Red and Blue). The colors are specified as 8-bit RGB values in the CSV text file Rothko.csv.

199

42

11

207

61

24

189

48

77

180

35

52

30

89

151

27

84

148

The rendered output:

../_images/Rothko.png

Color palette image based on a Rothko painting, generated from the CSV color table.