33 Interpolator::Interpolator() {
50 Interpolator::~Interpolator() {}
53 void Interpolator::Init() {
72 double Interpolator::Interpolate(
const double isamp,
const double iline,
77 string message =
"Interpolator type not set";
81 case NearestNeighborType:
82 return NearestNeighbor(isamp, iline, buf);
85 return BiLinear(isamp, iline, buf);
87 case CubicConvolutionType:
88 return CubicConvolution(isamp, iline, buf);
92 string message =
"Invalid interpolator";
117 double Interpolator::NearestNeighbor(
const double isamp,
const double iline,
118 const double buf[]) {
134 double Interpolator::BiLinear(
const double isamp,
const double iline,
135 const double buf[]) {
138 double j = int (isamp);
139 double k = int (iline);
140 double a = isamp - j;
141 double b = iline - k;
144 for(
int i = 0; i < 4; i++) {
146 return NearestNeighbor(isamp, iline,
147 &buf[(
int)(a + 0.5) + 2 * (
int)(b+0.5)]);
153 return (1.0 - a) * (1.0 - b) * buf[0] +
154 a * (1.0 - b) * buf[1] +
155 (1.0 - a) * b * buf[2] +
172 double Interpolator::CubicConvolution(
const double isamp,
174 const double buf[]) {
177 for(
int i = 0; i < 16; i++) {
179 double tbuf[4] = {buf[5], buf[6], buf[9], buf[10]};
180 return BiLinear(isamp, iline, tbuf);
185 double j = int (isamp);
186 double k = int (iline);
187 double a = isamp - j;
188 double b = iline - k;
197 return -b * (1.0 - b) * (1.0 - b) * (-a * (1.0 - a) * (1.0 - a) * buf[0] +
198 (1.0 - 2.0 * a * a + a * a * a) * buf[1] +
199 a * (1.0 + a - a * a) * buf[2] -
200 a * a * (1.0 - a) * buf[3]) +
202 (1.0 - 2.0 * b * b + b * b * b) * (-a * (1.0 - a) * (1.0 - a) * buf[4] +
203 (1.0 - 2.0 * a * a + a * a * a) * buf[5] +
204 a * (1.0 + a - a * a) * buf[6] -
205 a * a * (1.0 - a) * buf[7]) +
207 b * (1.0 + b - b * b) * (-a * (1.0 - a) * (1.0 - a) * buf[8] +
208 (1.0 - 2.0 * a * a + a * a * a) * buf[9] +
209 a * (1.0 + a - a * a) * buf[10] -
210 a * a * (1.0 - a) * buf[11]) +
212 b * b * (b - 1.0) * (-a * (1.0 - a) * (1.0 - a) * buf[12] +
213 (1.0 - 2.0 * a * a + a * a * a) * buf[13] +
214 a * (1.0 + a - a * a) * buf[14] -
215 a * a * (1.0 - a) * buf[15]);
224 int Interpolator::Samples() {
228 string message =
"Interpolator type not set";
232 case NearestNeighborType:
238 case CubicConvolutionType:
243 string message =
"Invalid interpolator";
252 int Interpolator::Lines() {
256 string message =
"Interpolator type not set";
260 case NearestNeighborType:
266 case CubicConvolutionType:
271 string message =
"Invalid interpolator";
281 double Interpolator::HotSample() {
285 string message =
"Interpolator type not set";
290 case NearestNeighborType:
298 case CubicConvolutionType:
303 string message =
"Invalid interpolator";
313 double Interpolator::HotLine() {
317 string message =
"Interpolator type not set";
322 case NearestNeighborType:
330 case CubicConvolutionType:
335 string message =
"Invalid interpolator";
interpType
The interpolator type, including: None, Nearest Neighbor, BiLinear or Cubic Convultion.
Namespace for the standard library.
#define _FILEINFO_
Macro for the filename and line number.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Namespace for ISIS/Bullet specific routines.