Reading a sequence of optical images#

Read several photographs into a single space-time OpticalImage, applying a curvature correction while reading, then slice and recolour it.

import json
import os

import darsia

folder = os.path.join("..", "images")
optical_paths = [os.path.join(folder, f"co2_{i}.jpg") for i in range(3)]
metadata = {"dimensions": [1.5, 2.8]}

The config.json shipped with the examples holds parameters for several correction routines; here we build a curvature correction from it.

with open(os.path.join(folder, "config.json"), "r") as f:
    config = json.load(f)
curvature_correction = darsia.CurvatureCorrection(config=config["curvature"])
/home/runner/work/DarSIA/DarSIA/src/darsia/corrections/shape/curvature.py:193: UserWarning: No image provided. Please provide an image or a config file.
  warn("No image provided. Please provide an image or a config file.")

A single corrected image.

single = darsia.imread(
    optical_paths[0], transformations=[curvature_correction], **metadata
)
single.show(f"single image - {single.time}")
plot reading images
Warning: No exif metafile found. Please install ImageMagick to read metadata from terminal.

All three frames as one space-time image.

  • plot reading images
  • plot reading images
  • plot reading images
Warning: No exif metafile found. Please install ImageMagick to read metadata from terminal.
Warning: No exif metafile found. Please install ImageMagick to read metadata from terminal.
Warning: No exif metafile found. Please install ImageMagick to read metadata from terminal.
/home/runner/work/DarSIA/DarSIA/src/darsia/image/image.py:181: UserWarning: No time information provided for the image.
  warn("No time information provided for the image.")
space-time shape: (1703, 3180, 3, 3)

Recolour the whole space-time image, and reduce it to a single channel.

spacetime.to_trichromatic("hsv")
spacetime.show("space-time, HSV")

red = spacetime.to_monochromatic("red")
red.show("space-time, red channel")
  • plot reading images
  • plot reading images
  • plot reading images
  • plot reading images
  • plot reading images
  • plot reading images

Total running time of the script: (0 minutes 7.553 seconds)

Gallery generated by Sphinx-Gallery