Changeset 9866
- Timestamp:
- Nov 5, 2006, 4:11:04 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourcePhotometry.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r9843 r9866 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-11-0 3 15:21:15$5 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-06 02:11:04 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 182 182 } 183 183 184 // XXX the implemented version of psImageShift does not work (is inconsistent wrt psImageInterpolate frac pix def?)185 psImage *tmp_psImageShift (psImage *in, float dx, float dy)186 {187 188 int nx = in->numCols;189 int ny = in->numRows;190 191 psImage *out = psImageAlloc (nx, ny, PS_TYPE_F32);192 193 // we define an integer shift and a (positive) fractional shift194 int dxi = floor(dx);195 int dyi = floor(dy);196 float dxf = dx - dxi; // +2.3 -> 2 and 0.3; -2.3 -> -3 and +0.7197 float dyf = dy - dyi; // +2.3 -> 2 and 0.3; -2.3 -> -3 and +0.7198 199 // apply the integer shift200 int DXin = (dxi < 0) ? -dxi : 0;201 int DXot = (dxi < 0) ? 0 : dxi;202 int DYin = (dyi < 0) ? -dyi : 0;203 int DYot = (dyi < 0) ? 0 : dyi;204 205 for (int j = 0; j < ny - abs(dyi); j++) {206 for (int i = 0; i < nx - abs(dxi); i++) {207 out->data.F32[j+DYot][i+DXot] = in->data.F32[j+DYin][i+DXin];208 }209 // fill in the exposed x-border with 0.0210 int pix = (dxi > 0) ? 0 : nx - abs(dxi);211 for (int i = 0; i < abs(dxi); i++, pix++) {212 out->data.F32[j+DYot][pix] = 0.0;213 }214 }215 216 // fill in the exposed y-border with 0.0217 int pix = (dyi > 0) ? 0 : ny - abs(dyi);218 for (int j = 0; j < abs(dyi); j++, pix++) {219 for (int i = 0; i < nx; i++) {220 out->data.F32[pix][i] = 0.0;221 }222 }223 224 // apply the fractional shift225 if ((dxf > 0) || (dyf > 0)) {226 float value;227 228 double f00 = dxf * dyf;229 double f01 = dxf *(1-dyf);230 double f10 = (1-dxf)* dyf;231 double f11 = (1-dxf)*(1-dyf);232 233 for (int j = ny - 2; j >= 0; j--) {234 psF32 *V0 = out->data.F32[j+0];235 psF32 *V1 = out->data.F32[j+1];236 for (int i = nx - 2; i >= 0; i--, V0--, V1--) {237 value = V0[0] * f00;238 value += V0[1] * f10;239 value += V1[0] * f01;240 value += V1[1] * f11;241 V1[1] = value;242 }243 }244 }245 return out;246 }247 248 184 // return source aperture magnitude 249 185 // interpolate the image pixels to place the center at xi+0.5,yi+0.5 … … 265 201 266 202 // shift image to have centroid at xi+0.5, yi+0.5 267 # if (1) 203 # if (0) 204 // this is necessary to make the measurement consistent with the growth model. 205 // only do this if we are applying the model? 268 206 float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS]; 269 207 float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS]; 270 psImage *tmpImage = tmp_psImageShift (image, dx, dy);208 psImage *tmpImage = psImageShift (NULL, image, dx, dy, 0.0, PS_INTERPOLATE_BICUBE); 271 209 # else 272 210
Note:
See TracChangeset
for help on using the changeset viewer.
