Resampling¶
- class odl.discr.discr_ops.Resampling(*args, **kwargs)[source]¶
Bases:
Operator
An operator that resamples on a different grid in the same set.
- Attributes:
adjoint
Return an (approximate) adjoint.
domain
Set of objects on which this operator can be evaluated.
interp
Interpolation scheme or tuple of per-axis interpolation schemes.
interp_byaxis
Tuple of per-axis interpolation schemes.
inverse
An (approximate) inverse of this resampling operator.
is_functional
True
if this operator's range is aField
.is_linear
True
if this operator is linear.range
Set in which the result of an evaluation of this operator lies.
Methods
__call__
(x[, out])Return
self(x[, out, **kwargs])
.derivative
(point)Return the operator derivative at
point
.norm
([estimate])Return the operator norm of this operator.
- __init__(domain, range, interp)[source]¶
Initialize a new instance.
- Parameters:
- domain
DiscretizedSpace
Set of elements that are to be resampled.
- range
DiscretizedSpace
Set in which the resampled elements lie. Must have the same
DiscretizedSpace.domain
asdomain
.- interpstr or sequence of str
Interpolation type that should be used to resample. A single value applies to all axes, and a sequence gives the interpolation scheme per axis.
Supported values:
'nearest'
,'linear'
- domain
Examples
Create two spaces with different number of points and a resampling operator using nearest-neighbor interpolation:
>>> coarse_discr = odl.uniform_discr(0, 1, 3) >>> fine_discr = odl.uniform_discr(0, 1, 6) >>> resampling = odl.Resampling(coarse_discr, fine_discr, 'nearest') >>> resampling.domain uniform_discr(0.0, 1.0, 3) >>> resampling.range uniform_discr(0.0, 1.0, 6) >>> resampling.interp 'nearest'
Apply the corresponding resampling operator to an element:
>>> print(resampling([0, 1, 0])) [ 0., 0., 1., 1., 0., 0.]
With linear interpolation:
>>> resampling = odl.Resampling(coarse_discr, fine_discr, 'linear') >>> print(resampling([0, 1, 0])) [ 0. , 0.25, 0.75, 0.75, 0.25, 0. ]