[Insight-developers] RFC: Proposal for Pixel Interpolation Methods
Paul Hughett
hughett@mercur.uphs.upenn.edu
Fri, 5 Jan 2001 15:06:13 -0500
Here is a proposed interface for adding pixel interpolation methods
(and some related methods) to the Image class. Comments are welcome.
Paul Hughett
/**
* Interpolation method
*
* The possible values of this enum select among different methods for
* interpolating the value of an image at points between those defined.
* NearestNeighbor takes the value at the defined pixel nearest the
* desired point. Linear interpolates linearly between the nearest
* neighbors along each coordinate axis, using a total of 2^N
* neighboring pixels (where N is the number of dimensions).
* CubicSpline uses a cubic spline interpolation along each axes, using
* a total of 4^N * neighboring pixels.
*/
enum InterpolationType {NearestNeighbor, Linear, CubicSpline};
/**
* Interpolate pixel value at random point
*
* This method interpolates to estimate the pixel value at points between
* the sample points of the image, using a given interpolation method.
* If the given point is near or outside the RequestedRegion of the image,
* the missing points are assumed to have the value given by pad; in effect,
* the RequestedRegion of the image is treated as if it were embedded in
* an infinite image of pad values. By default, the point is assumed to
* be in the physical coordinates defined by the Origin and Spacing attributes
* of the Image. If useindex is set to true, then index coordinates are used
* instead; this may improve efficiency if many points are computed using
* some transformation that can be composed with the physical-to-index
* transformation.
*/
PixelType
Image::
InterpolatePixel(
const Point<VImageDimension,double> &point,
const InterpolationType type,
const PixelType &pad = 0,
const bool useindex = 0) const;
/**
* Get pixel value or default
*
* If the given index is inside the RequestedRegion, return the value
* of the pixel at that index; otherwise return the default value.
* This method may be useful in algorithms that can treat an image
* as embedded in a infinite image of some default value; for example,
* convolution and resampling algorithms would use a default of zero.
* (Note that morphological operators might want a non-zero default.)
*/
PixelType
Image::
GetPixelOrDefault(
const IndexType &index,
const PixelType &default) const;
/**
* Return physical-to-index transform
*
* This method returns the AffineTransform which defines the transformation
* from physical to index coordinates for this Image.
*/
AffineTransform<double, VImageDimension>
Image::
GetPhysicalToIndexTransform() const;
/**
* Return index-to-physical transform
*
* This method returns the AffineTransform which defines the transformation
* from index to physical coordinates for this Image.
*/
AffineTransform<double, VImageDimension>
Image::
GetIndexToPhysicalTransform() const;