![]() ![]() |
![]() |
File: [Development] / JSOC / proj / maps_avgs / apps / ccinterp.c
(download)
Revision: 1.1, Mon Sep 20 22:48:48 2010 UTC (12 years, 8 months ago) by beck Branch: MAIN CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, HEAD *** empty log message *** |
/* * Cubic convolution interpolation, based on GONG software, received Apr-88 * Interpolation by cubic convolution in 2 dimensions with 32-bit float data * * Reference: * R.G. Keys in IEEE Trans. Acoustics, Speech, and Signal Processing, * Vol. 29, 1981, pp. 1153-1160. * * Usage: * float ccint2 (float *f, int nx, int ny, double x, double y) * double ccint2d (double *f, int nx, int ny, double x, double y) * * Bugs: * Currently interpolation within one pixel of edge is not * implemented. If x or y is in this range or off the picture, the * function value returned is NaN. */ #include <math.h> /* Calculate the interpolation kernel. */ static void ccker (double *u, double s) { double s2, s3; s2= s * s; s3= s2 * s; u[0] = s2 - 0.5 * (s3 + s); u[1] = 1.5*s3 - 2.5*s2 + 1.0; u[2] = -1.5*s3 + 2.0*s2 + 0.5*s; u[3] = 0.5 * (s3 - s2); } /* Cubic convolution interpolation */ float ccint2 (float *f, int nx, int ny, double x, double y) { double ux[4], uy[4]; double sum; int ix, iy, ix1, iy1, i, j; if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2)) return 0.0/ 0.0; // a quiet NaN Value ix = (int)x; ccker (ux, x - (double)ix); iy = (int)y; ccker (uy, y - (double)iy); ix1 = ix - 1; iy1 = iy - 1; sum = 0.; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j]; return (float)sum; } double ccint2d (double *f, int nx, int ny, double x, double y) { double ux[4], uy[4]; double sum; int ix, iy, ix1, iy1, i, j; if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2)) return 0.0/ 0.0; // a quiet NaN Value ix = (int)x; ccker (ux, x - (double)ix); iy = (int)y; ccker (uy, y - (double)iy); ix1 = ix - 1; iy1 = iy - 1; sum = 0.; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j]; return sum; }
Karen Tian |
Powered by ViewCVS 0.9.4 |