Scope and Architecture
Scope
This library is build focusing on 2D interpolations that satisfy the following constraints
-
Interpolation output must be linear in the original image data.
In equations each output of the interpolation \(v\) must be computable via $$\displaystyle v = \sum_i d_i w_i $$ where \(d_i\) the data values and \(w_i\) are weights that must be independent from the data values.
-
Data is given on panels consisting of square pixels
(or multiples of this pixel size like e.g. 2x1 pixels with twice the width). -
Image data changes frequently while the sampling points stay fixed.
Architecture
Static-interpolation treates an interpolation via 5 separate components.
-
A data structure describing the input
ImageLayout, e.g.from static_interpolation.data_structures import ImageLayout layout = ImageLayout(n_panels=3,num_x=64, num_y=16) # Describes an input with two pixel panels of shape 64x16. -
A data structure dercribing the
SamplingGrid, e.g.from static_interpolation.data_structures import SamplingGrid points = np.zeros((3,10,2),float) points[...,0] = (np.random.rand(10)*64)[None,...] points[...,1] = (np.random.rand(10)*16)[None,...] samples = SamplingGrid(points=points,n_panels=3) # Describes 10 random sampling points on the entire detector 64x16. -
A
CoordinateMapper. that maps sample points to image panel coordinates, e.g.from static_interpolation.coordinate_mappers import IdentityMapper idmapper = IdentityMapper() # Simplest possible coordinate mapper. assert idmapper.map(samples)==samples -
An
InterpolationPlanner, that precomputes the weights \(w_i\) and stors them in an InterpolationPlan, e.g.The policy object simply stores settings like whether to use linear or cubic interpolation.from static_interpolation.planning import InterpolationPlanner from static_interpolation.config import InterpolationPolicy policy = InterpolationPolicy() planner = InterpolationPlanner() plan = planner.build(samples,layout,policy) -
An
InterpolationEngine, that takes an InterpolationPlan and actually performs the interpolation, e.g.from static_interpolation.engines import NumbaEngine engine = NumbaEngine(plan,layout,policy) # given some input data one can then perfom the interpolation via data = np.random.rand(layout.shape) engine(data)