Changeset 14724
- Timestamp:
- Sep 1, 2007, 4:42:55 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.c
r14723 r14724 11 11 * @author Eugene Magnier, IfA 12 12 * 13 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-09-02 02: 03:58$13 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-09-02 02:42:55 $ 15 15 * 16 16 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 34 34 #include "psPolynomial.h" 35 35 #include "psPolynomialUtils.h" 36 #include "psMinimizePolyFit.h" 36 37 #include "psImage.h" 37 38 #include "psImageInterpolate.h" … … 49 50 if (jx + ix >= mask->numCols) { continue; } \ 50 51 /* do not test self */ \ 51 if (!jx && jy) { continue; } \52 if (mask->data.PS_TYPE_MASK_DATA[iy ][ix] & maskVal) { continue; } \52 if (!jx && !jy) { continue; } \ 53 if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \ 53 54 nGood ++; \ 54 55 } \ … … 115 116 // fit a quadratic to the valid neighbor pixels 116 117 // apply the quadratic to get the poor pixel value 117 psPolynomial2D *poly = psImageBicubeFit (image, mask, maskVal, ix, iy); 118 psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 2, 2); 119 poly->mask[2][2] = 1; 120 poly->mask[2][1] = 1; 121 poly->mask[1][2] = 1; 122 psVector *f = psVectorAlloc (9, PS_TYPE_F32); 123 psVector *df = psVectorAlloc (9, PS_TYPE_F32); 124 psVector *x = psVectorAlloc (9, PS_TYPE_F32); 125 psVector *y = psVectorAlloc (9, PS_TYPE_F32); 126 127 int n = 0; 128 for (int jy = -1; jy <= +1; jy++) { 129 // skip invalid pixels (jx < 0, >= Nx), etc 130 if (jy + iy < 0) { continue; } 131 if (jy + iy >= image->numRows) { continue; } 132 for (int jx = -1; jx <= +1; jx++) { 133 // skip invalid pixels (jx < 0, >= Nx), etc 134 if (jx + ix < 0) { continue; } 135 if (jx + ix >= mask->numCols) { continue; } 136 /* skip self */ 137 if (!jx && !jy) { continue; } 138 // skip masked pixels 139 if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \ 140 f->data.F32[n] = image->data.F32[iy+jy][ix+jx]; 141 // df->data.F32[n] = weight->data.F32[jy][jx]; 142 x->data.F32[n] = jx; 143 y->data.F32[n] = jy; 144 n++; 145 } 146 } 147 // XXX set vector lengths here 148 x->n = n; 149 y->n = n; 150 f->n = n; 151 // df->n = n; 152 psVectorFitPolynomial2D (poly, mask, maskValue, f, df, x, y); 118 153 image->data.F32[iy][ix] = poly->coeff[0][0]; 119 154 break; } 120 155 121 156 case PS_IMAGE_INTERPOLATE_LL: { 122 // fit a plane to the valid neighbor pixels 123 // apply the plane to get the poor pixel value 124 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 1); 125 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0] + poly->coeff[0][1]; 157 // fit a plane to the 3 pixels at (0,1),(1,0),(1,1), extend to pixel at (0,0) 158 image->data.F32[iy][ix] = image->data.F32[iy+1][ix+0] - image->data.F32[iy+0][ix+1] - image->data.F32[iy+1][ix+1]; 126 159 break; } 127 160 128 161 case PS_IMAGE_INTERPOLATE_LR: { 129 // fit a plane to the valid neighbor pixels 130 // apply the plane to get the poor pixel value 131 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 1); 132 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[0][1]; 162 // fit a plane to the 3 pixels at (0,1),(-1,0),(-1,1), extend to pixel at (0,0) 163 image->data.F32[iy][ix] = image->data.F32[iy+1][ix+0] - image->data.F32[iy+0][ix-1] - image->data.F32[iy+1][ix-1]; 133 164 break; } 134 165 135 166 case PS_IMAGE_INTERPOLATE_UL: { 136 // fit a plane to the valid neighbor pixels 137 // apply the plane to get the poor pixel value 138 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 0); 139 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0]; 167 // fit a plane to the 3 pixels at (0,-1),(1,0),(1,-1), extend to pixel at (0,0) 168 image->data.F32[iy][ix] = image->data.F32[iy-1][ix+0] - image->data.F32[iy+0][ix+1] - image->data.F32[iy-1][ix+1]; 140 169 break; } 141 170 142 171 case PS_IMAGE_INTERPOLATE_UR: { 143 // fit a plane to the valid neighbor pixels 144 // apply the plane to get the poor pixel value 145 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 0); 146 image->data.F32[iy][ix] = poly->coeff[0][0]; 172 // fit a plane to the 3 pixels at (0,-1),(-1,0),(-1,-1), extend to pixel at (0,0) 173 image->data.F32[iy][ix] = image->data.F32[iy-1][ix+0] - image->data.F32[iy+0][ix-1] - image->data.F32[iy-1][ix-1]; 147 174 break; } 148 175
Note:
See TracChangeset
for help on using the changeset viewer.
