10#include "Interpolator.h"
61 string message =
"Interpolator type not set";
62 throw IException(IException::Programmer, message, _FILEINFO_);
65 case NearestNeighborType:
71 case CubicConvolutionType:
76 string message =
"Invalid interpolator";
77 throw IException(IException::Programmer, message, _FILEINFO_);
102 const double buf[]) {
119 const double buf[]) {
122 double j = int (isamp);
123 double k = int (iline);
124 double a = isamp - j;
125 double b = iline - k;
128 for(
int i = 0; i < 4; i++) {
129 if(Isis::IsSpecial(buf[i])) {
131 &buf[(
int)(a + 0.5) + 2 * (
int)(b+0.5)]);
137 return (1.0 - a) * (1.0 - b) * buf[0] +
138 a * (1.0 - b) * buf[1] +
139 (1.0 - a) * b * buf[2] +
158 const double buf[]) {
161 for(
int i = 0; i < 16; i++) {
162 if(Isis::IsSpecial(buf[i])) {
163 double tbuf[4] = {buf[5], buf[6], buf[9], buf[10]};
164 return BiLinear(isamp, iline, tbuf);
169 double j = int (isamp);
170 double k = int (iline);
171 double a = isamp - j;
172 double b = iline - k;
181 return -b * (1.0 - b) * (1.0 - b) * (-a * (1.0 - a) * (1.0 - a) * buf[0] +
182 (1.0 - 2.0 * a * a + a * a * a) * buf[1] +
183 a * (1.0 + a - a * a) * buf[2] -
184 a * a * (1.0 - a) * buf[3]) +
186 (1.0 - 2.0 * b * b + b * b * b) * (-a * (1.0 - a) * (1.0 - a) * buf[4] +
187 (1.0 - 2.0 * a * a + a * a * a) * buf[5] +
188 a * (1.0 + a - a * a) * buf[6] -
189 a * a * (1.0 - a) * buf[7]) +
191 b * (1.0 + b - b * b) * (-a * (1.0 - a) * (1.0 - a) * buf[8] +
192 (1.0 - 2.0 * a * a + a * a * a) * buf[9] +
193 a * (1.0 + a - a * a) * buf[10] -
194 a * a * (1.0 - a) * buf[11]) +
196 b * b * (b - 1.0) * (-a * (1.0 - a) * (1.0 - a) * buf[12] +
197 (1.0 - 2.0 * a * a + a * a * a) * buf[13] +
198 a * (1.0 + a - a * a) * buf[14] -
199 a * a * (1.0 - a) * buf[15]);
212 string message =
"Interpolator type not set";
213 throw IException(IException::Programmer, message, _FILEINFO_);
216 case NearestNeighborType:
222 case CubicConvolutionType:
227 string message =
"Invalid interpolator";
228 throw IException(IException::Programmer, message, _FILEINFO_);
240 string message =
"Interpolator type not set";
241 throw IException(IException::Programmer, message, _FILEINFO_);
244 case NearestNeighborType:
250 case CubicConvolutionType:
255 string message =
"Invalid interpolator";
256 throw IException(IException::Programmer, message, _FILEINFO_);
269 string message =
"Interpolator type not set";
270 throw IException(IException::Programmer, message, _FILEINFO_);
274 case NearestNeighborType:
282 case CubicConvolutionType:
287 string message =
"Invalid interpolator";
288 throw IException(IException::Programmer, message, _FILEINFO_);
301 string message =
"Interpolator type not set";
302 throw IException(IException::Programmer, message, _FILEINFO_);
306 case NearestNeighborType:
314 case CubicConvolutionType:
319 string message =
"Invalid interpolator";
320 throw IException(IException::Programmer, message, _FILEINFO_);
Interpolator()
Constructs an empty Interpolator object.
int Samples()
Returns the number of samples needed by the interpolator.
~Interpolator()
Destroys the Interpolator object.
double CubicConvolution(const double isamp, const double iline, const double buf[])
Performs a cubic-convulsion interpolation on the buffer data.
int Lines()
Returns the number of lines needed by the interpolator.
double HotSample()
Returns the sample coordinate of the center pixel in the buffer for the interpolator.
double NearestNeighbor(const double isamp, const double iline, const double buf[])
Performs a nearest-neighbor interpolation on the buffer data.
void Init()
Initializes the object data members.
double BiLinear(const double isamp, const double iline, const double buf[])
Performs a bi-linear interpolation on the buffer data.
double HotLine()
Returns the line coordinate of the center pixel in the buffer for the interpolator.
interpType p_type
The type of interpolation to be performed.
interpType
The interpolator type, including: None, Nearest Neighbor, BiLinear or Cubic Convultion.
void SetType(const interpType &type)
Sets the type of interpolation.
double Interpolate(const double isamp, const double iline, const double buf[])
Performs an interpolation on the data according to the parameters set in the constructor.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.