Changeset 9843
- Timestamp:
- Nov 3, 2006, 5:21:15 AM (20 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourcePhotometry.c (modified) (4 diffs)
-
pmSourcePhotometry.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r9810 r9843 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-1 0-31 19:38:44$5 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-03 15:21:15 $ 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 shift 194 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.7 197 float dyf = dy - dyi; // +2.3 -> 2 and 0.3; -2.3 -> -3 and +0.7 198 199 // apply the integer shift 200 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.0 210 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.0 217 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 shift 225 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 184 248 // return source aperture magnitude 249 // interpolate the image pixels to place the center at xi+0.5,yi+0.5 185 250 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask) 186 251 { … … 199 264 } 200 265 266 // shift image to have centroid at xi+0.5, yi+0.5 267 # if (1) 268 float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS]; 269 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); 271 # else 272 273 psImage *tmpImage = psImageCopy (NULL, image, PS_TYPE_F32); 274 # endif 275 201 276 // measure apMag 202 277 for (int ix = 0; ix < image->numCols; ix++) { … … 204 279 if (mask->data.U8[iy][ix]) 205 280 continue; 206 apSum += image->data.F32[iy][ix] - sky; 207 } 208 } 281 apSum += tmpImage->data.F32[iy][ix] - sky; 282 } 283 } 284 psFree (tmpImage); 209 285 if (apSum <= 0) 210 286 return false; -
trunk/psModules/src/objects/pmSourcePhotometry.h
r9527 r9843 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-1 0-13 02:24:34$5 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-03 15:21:15 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 51 51 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask); 52 52 53 psImage *tmp_psImageShift (psImage *in, float dx, float dy); 54 53 55 # endif /* PM_SOURCE_PHOTOMETRY_H */
Note:
See TracChangeset
for help on using the changeset viewer.
