#! /usr/bin/python3 # _*_ coding: iso-8859-1 _*_ # Last edited on 2019-08-25 21:46:10 by jstolfi import sys, copy class t: def __init__(self,dims,smp) : "Initalizes an instance the given data fields. The array {smp} is shared, not copied." # Instance setup: self.dims = dims; self.smp = smp # -------------------------------------------------------------------- def get_dims(self): return self.dims # -------------------------------------------------------------------- def get_samples(self): return self.smp # -------------------------------------------------------------------- # ---------------------------------------------------------------------- def create(dims,val): smp = make_sample_array(dims[0],dims[1],dims[2],val) img = t(dims,smp) return img # ---------------------------------------------------------------------- def make_sample_array(chns,cols,rows,val) : "Allocates a sample array with the given dimensions." sys.stderr.write("allocating array\n"); a = chns*[None]; for c in range(chns) : a[c] = copy.copy(rows*[None]) for y in range(rows) : a[y] = copy.copy(nx*[val]) return a; # ---------------------------------------------------------------------- # ----------------------------------------------------------------------