Class NLinearInterpolator<T extends NumericType<T>>
- Type Parameters:
T-
- All Implemented Interfaces:
EuclideanSpace, Positionable, RealLocalizable, RealPositionable, RealRandomAccess<T>, Sampler<T>, Typed<T>
- Direct Known Subclasses:
ClampingNLinearInterpolatorRealType, ClampingNLinearInterpolatorVolatileARGB, ClampingNLinearInterpolatorVolatileRealType, NLinearInterpolator1D, NLinearInterpolator2D, NLinearInterpolator3D, NLinearInterpolatorARGB
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Tprotected intIndex intoweightsarray.protected final Tprotected final double[]Weights for each pixel of the 2x2x...x2 hypercube of pixels participating in the interpolation.Fields inherited from class AbstractPositionableTransform
discrete, position, targetFields inherited from class AbstractEuclideanSpace
n -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNLinearInterpolator(NLinearInterpolator<T> interpolator) protectedNLinearInterpolator(RandomAccessible<T> randomAccessible) protectedNLinearInterpolator(RandomAccessible<T> randomAccessible, T type) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidmultiply current target value with current weight and add to accumulator.copy()protected voidFill theweightsarray.get()Get the interpolated value at the current position.getType()Get an instance ofT.private voidgraycodeBckRecursive(int dimension) private voidgraycodeFwdRecursive(int dimension) private voidprivate voidMethods inherited from class Floor
floor, floor, floor, floor, floor, move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPositionMethods inherited from class AbstractPositionableTransform
bck, fwd, getDoublePosition, getFloatPosition, localize, localize, move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPosition, toStringMethods inherited from class AbstractEuclideanSpace
numDimensionsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface EuclideanSpace
numDimensionsMethods inherited from interface Positionable
bck, fwd, move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPositionMethods inherited from interface RealLocalizable
getDoublePosition, getFloatPosition, localize, localize, localize, positionAsDoubleArray, positionAsRealPointMethods inherited from interface RealPositionable
move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPositionMethods inherited from interface RealRandomAccess
copyRealRandomAccess, setPositionAndGet, setPositionAndGet, setPositionAndGet
-
Field Details
-
code
protected int codeIndex intoweightsarray.To visit the pixels that contribute to an interpolated value, we move in a (binary-reflected) Gray code pattern, such that only one dimension of the target position is modified per move.
This index is the corresponding gray code bit pattern which will select the correct corresponding weight.
-
weights
protected final double[] weightsWeights for each pixel of the 2x2x...x2 hypercube of pixels participating in the interpolation.Indices into this array are arranged in the standard iteration order (as provided by
IntervalIndexer.positionToIndex(int[], int[])). Element 0 refers to position (0,0,...,0), element 1 refers to position (1,0,...,0), element 2 refers to position (0,1,...,0), etc. -
accumulator
-
tmp
-
-
Constructor Details
-
NLinearInterpolator
-
NLinearInterpolator
-
NLinearInterpolator
-
-
Method Details
-
fillWeights
protected void fillWeights()Fill theweightsarray.Let w_d denote the fraction of a pixel at which the sample position p_d lies from the floored position pf_d in dimension d. That is, the value at pf_d contributes with (1 - w_d) to the sampled value; the value at ( pf_d + 1 ) contributes with w_d.
At every pixel, the total weight results from multiplying the weights of all dimensions for that pixel. That is, the "top-left" contributing pixel (position floored in all dimensions) gets assigned weight (1-w_0)(1-w_1)...(1-w_n).
We work through the weights array starting from the highest dimension. For the highest dimension, the first half of the weights contain the factor (1 - w_n) because this first half corresponds to floored pixel positions in the highest dimension. The second half contain the factor w_n. In this first step, the first weight of the first half gets assigned (1 - w_n). The first element of the second half gets assigned w_n
From their, we work recursively down to dimension 0. That is, each half of weights is again split recursively into two partitions. The first element of the second partitions is the first element of the half multiplied with (w_d). The first element of the first partitions is multiplied with (1 - w_d).
When we have reached dimension 0, all weights will have a value assigned.
-
get
Get the interpolated value at the current position.To visit the pixels that contribute to an interpolated value, we move in a (binary-reflected) Gray code pattern, such that only one dimension of the target position is modified per move.
- Specified by:
getin interfaceSampler<T extends NumericType<T>>
-
getType
Description copied from interface:TypedGet an instance ofT.It should not be assumed that the returned
Tinstance is an independent copy. In particular, repeated calls togetType()may return the same instance.- Specified by:
getTypein interfaceSampler<T extends NumericType<T>>- Specified by:
getTypein interfaceTyped<T extends NumericType<T>>- Returns:
- an instance of
T
-
copy
- Specified by:
copyin interfaceRealRandomAccess<T extends NumericType<T>>- Specified by:
copyin interfaceSampler<T extends NumericType<T>>- Returns:
- - A new
Samplerin the same state accessing the same values. It does NOT copy T, just the state of theSampler. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for anArrayCursorfor example)
-
graycodeFwdRecursive
private void graycodeFwdRecursive(int dimension) -
graycodeBckRecursive
private void graycodeBckRecursive(int dimension) -
accumulate
private void accumulate()multiply current target value with current weight and add to accumulator. -
printWeights
private void printWeights() -
printCode
private void printCode()
-