Changeset 31358
- Timestamp:
- Apr 24, 2011, 9:40:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/psLib/src/imageops/psImageInterpolate.c
r28667 r31358 31 31 #include "psImageConvolve.h" 32 32 33 # define IS_BILIN_SEPARABLE 0 34 33 35 #include "psImageInterpolate.h" 34 36 … … 48 50 }; 49 51 52 # if (IS_BILIN_SEPARABLE) 50 53 /// Generate a linear interpolation kernel 51 54 static inline void interpolationKernelBilinear(psF32 *kernel, // Kernel vector to populate … … 56 59 kernel[1] = frac; 57 60 } 61 # else 62 /// Generate a linear interpolation kernel 63 static inline void interpolationKernelBilinear( 64 psF32 kernel[kernelSizes[PS_INTERPOLATE_BILINEAR]][kernelSizes[PS_INTERPOLATE_BILINEAR]], // Kernel 65 float xFrac, float yFrac // Fraction of pixel 66 ) 67 { 68 // (xF*yF, (1-xF)(1-yF) = 1 - xF - yF + xFyF 69 70 kernel[0][0] = 1.0 - xFrac - yFrac + xFrac*yFrac; 71 kernel[1][0] = yFrac - xFrac*yFrac; 72 kernel[0][1] = xFrac - xFrac*yFrac; 73 kernel[1][1] = xFrac*yFrac; 74 } 75 # endif 58 76 59 77 #if 0 … … 173 191 // Nothing to pre-compute 174 192 break; 193 # if (IS_BILIN_SEPARABLE) 175 194 case PS_INTERPOLATE_BILINEAR: 176 195 interpolationKernelBilinear(kernel, frac); 177 196 break; 197 # endif 178 198 case PS_INTERPOLATE_GAUSS: 179 199 interpolationKernelGauss(kernel, kernelSizes[mode], 0.5, frac); … … 184 204 interpolationKernelLanczos(kernel, kernelSizes[mode], frac); 185 205 break; 206 # if (!IS_BILIN_SEPARABLE) 207 case PS_INTERPOLATE_BILINEAR: 208 # endif 186 209 case PS_INTERPOLATE_BIQUADRATIC: // 2D kernel 187 210 default: … … 234 257 235 258 switch (mode) { 259 # if (IS_BILIN_SEPARABLE) 236 260 case PS_INTERPOLATE_BILINEAR: 261 # endif 237 262 case PS_INTERPOLATE_GAUSS: 238 263 case PS_INTERPOLATE_LANCZOS2: … … 258 283 } 259 284 break; 285 # if (!IS_BILIN_SEPARABLE) 286 case PS_INTERPOLATE_BILINEAR: 287 # endif 260 288 case PS_INTERPOLATE_BIQUADRATIC: 261 289 // 2D kernel, would cost too much memory to pre-calculate … … 360 388 int xCentral = floor((X) - 0.5), yCentral = floor((Y) - 0.5); /* Central pixel */ \ 361 389 float xFrac = (X) - xCentral - 0.5, yFrac = (Y) - yCentral - 0.5; /* Fraction of pixel */ \ 390 bool xExact = fabsf(xFrac) < FLT_EPSILON, yExact = fabsf(yFrac) < FLT_EPSILON; /* Are shifts exact? */ \ 391 392 // Set up the kernel parameters; defines some useful values 393 // EAM : I'm unsure of the right answer here 394 #define INTERPOLATE_SETUP_EAM(X, Y) \ 395 int xCentral = floor((X)), yCentral = floor((Y)); /* Central pixel */ \ 396 float xFrac = (X) - xCentral, yFrac = (Y) - yCentral; /* Fraction of pixel */ \ 362 397 bool xExact = fabsf(xFrac) < FLT_EPSILON, yExact = fabsf(yFrac) < FLT_EPSILON; /* Are shifts exact? */ \ 363 398 … … 722 757 } 723 758 724 // Interpolation engine for ( separable) interpolation kernels759 // Interpolation engine for (non-separable) interpolation kernels 725 760 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue, 726 761 psImageMaskType *maskValue, float x, float y, … … 747 782 // Get the appropriate kernels 748 783 psF32 kernel[size][size]; 784 785 # if (IS_BILIN_SEPARABLE) 749 786 psAssert(mode == PS_INTERPOLATE_BIQUADRATIC, "Mode is %x", mode); 750 787 interpolationKernelBiquadratic(kernel, xFrac, yFrac); 788 # else 789 psAssert((mode == PS_INTERPOLATE_BIQUADRATIC) || (mode == PS_INTERPOLATE_BILINEAR), "Mode is %x", mode); 790 if (mode == PS_INTERPOLATE_BIQUADRATIC) { 791 interpolationKernelBiquadratic(kernel, xFrac, yFrac); 792 } else { 793 interpolationKernelBilinear(kernel, xFrac, yFrac); 794 } 795 # endif 796 797 # if (0) 798 for (int i = 0; i < size; i++) { 799 for (int j = 0; j < size; j++) { 800 fprintf (stderr, "%f ", kernel[i][j]); 801 } 802 fprintf (stderr, "\n"); 803 } 804 # endif 751 805 752 806 float sumKernel = 0.0; // Sum of the kernel … … 908 962 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 909 963 case PS_INTERPOLATE_BILINEAR: 964 # if (!IS_BILIN_SEPARABLE) 965 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 966 # endif 910 967 case PS_INTERPOLATE_GAUSS: 911 968 case PS_INTERPOLATE_LANCZOS2:
Note:
See TracChangeset
for help on using the changeset viewer.
