- Timestamp:
- Sep 14, 2012, 6:10:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c
r34414 r34442 189 189 switch (mode) { 190 190 case PS_INTERPOLATE_FLAT: 191 case PS_INTERPOLATE_BILINEAR_SIMPLE: 191 192 // Nothing to pre-compute 192 193 break; … … 287 288 # endif 288 289 case PS_INTERPOLATE_BIQUADRATIC: 290 case PS_INTERPOLATE_BILINEAR_SIMPLE: 289 291 // 2D kernel, would cost too much memory to pre-calculate 290 292 break; 293 291 294 default: 292 295 psAbort("Unsupported interpolation mode: %x", mode); … … 937 940 938 941 942 psImageInterpolateStatus interpolateJustWork(double *imageValue, double *varianceValue, 943 psImageMaskType *maskValue, float x, float y, 944 const psImageInterpolation *interp) { 945 float u1,u2; 946 int xl,xh; 947 int yl,yh; 948 const psImage *image = interp->image; // Image to interpolate 949 // const psImage *mask = interp->mask; // Mask to interpolate 950 const psImage *variance = interp->variance; // Variance to interpolate 951 952 xl = floor(x); 953 if (xl < 0) { xl = 0; } 954 if (xl >= image->numCols) {xl = image->numCols - 1; } 955 xh = xl + 1; 956 if (xh >= image->numCols) {xh = image->numCols - 1; } 957 yl = floor(y); 958 if (yl < 0) { yl = 0; } 959 if (yl >= image->numRows) {yl = image->numRows - 1; } 960 yh = yl + 1; 961 if (yh >= image->numRows) {yh = image->numRows - 1; } 962 if (varianceValue && variance) { 963 u1 = (xh - x) * variance->data.F32[yl][xl] + (x - xl) * variance->data.F32[yl][xh]; 964 u2 = (xh - x) * variance->data.F32[yh][xl] + (x - xl) * variance->data.F32[yh][xh]; 965 966 *varianceValue = (yh - y) * u1 + (y - yl) * u2; 967 } 968 #if 0 969 if (maskValue && mask) { 970 u1 = (xh - x) * mask->data.F32[yl][xl] + (x - xl) * mask->data.F32[yl][xh]; 971 u2 = (xh - x) * mask->data.F32[yh][xl] + (x - xl) * mask->data.F32[yh][xh]; 972 973 maskValue = (yh - y) * u1 + (y - yl) * u2; 974 } 975 #endif 976 if (imageValue && image) { 977 if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) { 978 u1 = image->data.F32[yl][xh]; 979 } 980 else { 981 u1 = (xh - x) * image->data.F32[yl][xl] + (x - xl) * image->data.F32[yl][xh]; 982 } 983 if (image->data.F32[yh][xl] == image->data.F32[yh][xh]) { 984 u2 = image->data.F32[yh][xh]; 985 } 986 else { 987 u2 = (xh - x) * image->data.F32[yh][xl] + (x - xl) * image->data.F32[yh][xh]; 988 } 989 if (u1 == u2) { 990 *imageValue = u1; 991 } 992 else { 993 *imageValue = (yh - y) * u1 + (y - yl) * u2; 994 } 995 if ((floor(x) >= image->numCols)|| 996 (floor(y) >= image->numRows)) { 997 *imageValue = NAN; 998 } 999 } 1000 if (*imageValue == 0.0) { 1001 fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n", 1002 x,y,xl,xh,yl,yh,u1,u2, 1003 image->data.F32[yl][xl],image->data.F32[yl][xh],image->data.F32[yh][xl],image->data.F32[yh][xh] 1004 ); 1005 } 1006 return PS_INTERPOLATE_STATUS_GOOD; 1007 } 1008 939 1009 940 1010 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, … … 969 1039 case PS_INTERPOLATE_BIQUADRATIC: 970 1040 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 1041 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1042 return interpolateJustWork(imageValue, varianceValue, maskValue, x, y, interp); 971 1043 case PS_INTERPOLATE_BILINEAR: 972 1044 # if (!IS_BILIN_SEPARABLE) 973 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);1045 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 974 1046 # endif 975 1047 case PS_INTERPOLATE_GAUSS: … … 1019 1091 switch (mode) { 1020 1092 case PS_INTERPOLATE_FLAT: 1093 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1021 1094 // No smearing by design 1022 1095 return 1.0; … … 1083 1156 if (!strcasecmp(name, "FLAT")) return PS_INTERPOLATE_FLAT; 1084 1157 if (!strcasecmp(name, "BILINEAR")) return PS_INTERPOLATE_BILINEAR; 1158 if (!strcasecmp(name, "SIMPLEBILINEAR")) return PS_INTERPOLATE_BILINEAR_SIMPLE; 1085 1159 if (!strcasecmp(name, "BIQUADRATIC")) return PS_INTERPOLATE_BIQUADRATIC; 1086 1160 if (!strcasecmp(name, "GAUSS")) return PS_INTERPOLATE_GAUSS;
Note:
See TracChangeset
for help on using the changeset viewer.
