Tutorial 03: storing 2D image in larcv

Posted on Wed 06 December 2017 in misc by Corey Adams, Kazuhiro Terao

As an example, this notebook shows how to store 2D images in larcv data formats using image2d data product. How to store other form of data (2D/3D sparse data, clusters, etc.) would be a simple extension once you learn about this.

In [1]:
from __future__ import print_function
import ROOT
import numpy
from ROOT import larcv
import matplotlib.pyplot as plt
from scipy.ndimage import imread
Welcome to JupyROOT 6.08/06

Getting an image sample

Need an image to convert. Since I'm writing the tutorial, I get to use my daughter :)

In [2]:
_file = '/home/cadams/Desktop/norasaurus.jpg'
nora = imread(_file)
<type 'numpy.ndarray'>

Nora's type should actually be 'baby' but OK.

In [3]:
fig = plt.figure(figsize=(16,16))
plt.imshow(nora, interpolation='none')