Changeset 34800 for trunk/psLib/src/imageops/psImageInterpolate.c
- Timestamp:
- Dec 11, 2012, 2:04:31 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psLib/src/imageops/psImageInterpolate.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/psLib/src/imageops/psImageInterpolate.c
r34365 r34800 31 31 #include "psImageConvolve.h" 32 32 33 # define IS_BILIN_SEPARABLE 033 # define IS_BILIN_SEPARABLE 1 34 34 35 35 #include "psImageInterpolate.h" … … 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 950 xl = floor(x); 951 if (xl < 0) { xl = 0; } 952 if (xl >= image->numCols) {xl = image->numCols - 1; } 953 xh = xl + 1; 954 if (xh >= image->numCols) {xh = image->numCols - 1; } 955 956 yl = floor(y); 957 if (yl < 0) { yl = 0; } 958 if (yl >= image->numRows) {yl = image->numRows - 1; } 959 yh = yl + 1; 960 if (yh >= image->numRows) {yh = image->numRows - 1; } 961 962 if (imageValue && image) { 963 if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) { 964 u1 = image->data.F32[yl][xh]; 965 } 966 else { 967 u1 = (xh - x) * image->data.F32[yl][xl] + (x - xl) * image->data.F32[yl][xh]; 968 } 969 if (image->data.F32[yh][xl] == image->data.F32[yh][xh]) { 970 u2 = image->data.F32[yh][xh]; 971 } 972 else { 973 u2 = (xh - x) * image->data.F32[yh][xl] + (x - xl) * image->data.F32[yh][xh]; 974 } 975 if (u1 == u2) { 976 *imageValue = u1; 977 } 978 else { 979 *imageValue = (yh - y) * u1 + (y - yl) * u2; 980 } 981 if ((floor(x) >= image->numCols)|| 982 (floor(y) >= image->numRows)) { 983 *imageValue = NAN; 984 } 985 } 986 #if (0) 987 if (*imageValue == 0.0) { 988 fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n", 989 x,y,xl,xh,yl,yh,u1,u2, 990 image->data.F32[yl][xl],image->data.F32[yl][xh],image->data.F32[yh][xl],image->data.F32[yh][xh] 991 ); 992 } 993 #endif 994 return PS_INTERPOLATE_STATUS_GOOD; 995 } 996 939 997 940 998 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, … … 969 1027 case PS_INTERPOLATE_BIQUADRATIC: 970 1028 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 1029 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1030 return interpolateJustWork(imageValue, varianceValue, maskValue, x, y, interp); 971 1031 case PS_INTERPOLATE_BILINEAR: 972 1032 # if (!IS_BILIN_SEPARABLE) 973 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);1033 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 974 1034 # endif 975 1035 case PS_INTERPOLATE_GAUSS: … … 1019 1079 switch (mode) { 1020 1080 case PS_INTERPOLATE_FLAT: 1081 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1021 1082 // No smearing by design 1022 1083 return 1.0; … … 1083 1144 if (!strcasecmp(name, "FLAT")) return PS_INTERPOLATE_FLAT; 1084 1145 if (!strcasecmp(name, "BILINEAR")) return PS_INTERPOLATE_BILINEAR; 1146 if (!strcasecmp(name, "SIMPLEBILINEAR")) return PS_INTERPOLATE_BILINEAR_SIMPLE; 1085 1147 if (!strcasecmp(name, "BIQUADRATIC")) return PS_INTERPOLATE_BIQUADRATIC; 1086 1148 if (!strcasecmp(name, "GAUSS")) return PS_INTERPOLATE_GAUSS;
Note:
See TracChangeset
for help on using the changeset viewer.
