Changeset 14480 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Aug 13, 2007, 4:14:30 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14456 r14480 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-08- 09 21:20:35$6 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-08-14 02:14:30 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 217 217 int index, // Kernel basis function index 218 218 int x, int y, // Pixel around which to convolve 219 const ps Image *image // Image to convolve219 const psKernel *image // Image to convolve (a kernel for convenience) 220 220 ) 221 221 { … … 225 225 int u = kernels->u->data.S32[index]; // Offset in x 226 226 int v = kernels->v->data.S32[index]; // Offset in y 227 float value = image-> data.F32[y + v][x + u]; // Value of convolution227 float value = image->kernel[y + v][x + u]; // Value of convolution 228 228 if (kernels->spatialOrder > 0 && index != kernels->subIndex) { 229 229 // The (0,0) element is subtracted from most kernels to preserve photometric scaling 230 value -= image-> data.F32[y][x];230 value -= image->kernel[y][x]; 231 231 } 232 232 return value; … … 242 242 for (int v = vStart; v <= vStop; v++) { 243 243 for (int u = uStart; u <= uStop; u++) { 244 sum += image-> data.F32[y + v][x + u];244 sum += image->kernel[y + v][x + u]; 245 245 } 246 246 } … … 248 248 if (kernels->spatialOrder > 0 && index != kernels->subIndex) { 249 249 // The (0,0) element is subtracted from most kernels to preserve photometric scaling 250 sum -= image-> data.F32[y][x];250 sum -= image->kernel[y][x]; 251 251 } 252 252 return sum; … … 260 260 for (int v = -size; v <= size; v++) { 261 261 for (int u = -size; u <= size; u++) { 262 sum += kernel->kernel[v][u] * image-> data.F32[y + v][x + u];262 sum += kernel->kernel[v][u] * image->kernel[y + v][x + u]; 263 263 } 264 264 } … … 268 268 int u = kernels->u->data.S32[index]; // Offset in x 269 269 int v = kernels->v->data.S32[index]; // Offset in y 270 float value = image-> data.F32[y + v][x + u]; // Value of convolution270 float value = image->kernel[y + v][x + u]; // Value of convolution 271 271 // The (0,0) delta function is subtracted from most kernels to preserve photometric scaling 272 272 if (kernels->spatialOrder > 0 && index != kernels->subIndex) { 273 value -= image-> data.F32[y][x];273 value -= image->kernel[y][x]; 274 274 } 275 275 return value; … … 281 281 for (int v = -size; v <= size; v++) { 282 282 for (int u = -size; u <= size; u++) { 283 sum += kernel->kernel[v][u] * image-> data.F32[y + v][x + u];283 sum += kernel->kernel[v][u] * image->kernel[y + v][x + u]; 284 284 // Photometric scaling is already built in to the precalculated kernel 285 285 } … … 289 289 case PM_SUBTRACTION_KERNEL_RINGS: { 290 290 if (index == kernels->subIndex) { 291 return image-> data.F32[y][x];291 return image->kernel[y][x]; 292 292 } 293 293 psArray *preCalc = kernels->preCalc->data[index]; // Precalculated data … … 299 299 for (int j = 0; j < num; j++) { 300 300 int u = uCoords->data.S32[j], v = vCoords->data.S32[j]; // Kernel coordinates 301 sum += image-> data.F32[y + v][x + u] * poly->data.F32[j];301 sum += image->kernel[y + v][x + u] * poly->data.F32[j]; 302 302 } 303 303 // The (0,0) kernel is subtracted from other kernels to preserve photometric scaling 304 return sum - num * image-> data.F32[y][x];304 return sum - num * image->kernel[y][x]; 305 305 } 306 306 default: … … 436 436 437 437 438 bool pmSubtractionCalculateEquation(psArray *stamps, const psImage *reference, const psImage *input, 439 const psImage *weight, const pmSubtractionKernels *kernels, int footprint) 438 bool pmSubtractionCalculateEquation(psArray *stamps, const pmSubtractionKernels *kernels, int footprint) 440 439 { 441 440 PS_ASSERT_ARRAY_NON_NULL(stamps, false); 442 PS_ASSERT_IMAGE_NON_NULL(reference, false);443 PS_ASSERT_IMAGE_TYPE(reference, PS_TYPE_F32, false);444 PS_ASSERT_IMAGE_NON_NULL(input, false);445 PS_ASSERT_IMAGE_TYPE(input, PS_TYPE_F32, false);446 PS_ASSERT_IMAGES_SIZE_EQUAL(reference, input, false);447 441 PS_ASSERT_PTR_NON_NULL(kernels, false); 448 442 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->v, false); 449 if (weight) {450 PS_ASSERT_IMAGE_NON_NULL(weight, false);451 PS_ASSERT_IMAGES_SIZE_EQUAL(weight, input, false);452 PS_ASSERT_IMAGE_TYPE(weight, PS_TYPE_F32, false);453 }454 443 PS_ASSERT_INT_NONNEGATIVE(footprint, false); 455 456 // Image size457 int numCols = reference->numCols;458 int numRows = reference->numRows;459 444 460 445 int spatialOrder = kernels->spatialOrder; // Maximum order of spatial variation … … 491 476 psVectorInit(stampVector, 0.0); 492 477 493 float xNorm = 2.0 * (float)(stamp->x - numCols/2.0) / (float)numCols; // Normalised x coord 494 float yNorm = 2.0 * (float)(stamp->y - numRows/2.0) / (float)numRows; // Normalised y coord 495 psImage *polyValues = spatialPolyValues(spatialOrder, xNorm, yNorm); // Spatial polynomial terms 496 497 for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) { 498 for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) { 499 float invNoise2 = 1.0 / (weight ? weight->data.F32[y][x] : 500 input->data.F32[y][x]); // Inverse square noise 478 // Spatial polynomial terms 479 psImage *polyValues = spatialPolyValues(spatialOrder, stamp->xNorm, stamp->yNorm); 480 481 psKernel *reference = stamp->reference; // Reference postage stamp 482 psKernel *input = stamp->input; // Input postage stamp 483 psKernel *weight = stamp->weight; // Weight map postage stamp 484 485 for (int y = - footprint; y <= footprint; y++) { 486 for (int x = - footprint; x <= footprint; x++) { 487 float invNoise2 = 1.0 / weight->kernel[y][x]; // Inverse square noise 501 488 502 489 // Generate the convolutions … … 519 506 convolutions->data.F64[j] * invNoise2; 520 507 } 521 stampVector->data.F64[i] += input-> data.F32[y][x] * convolutions->data.F64[i] *508 stampVector->data.F64[i] += input->kernel[y][x] * convolutions->data.F64[i] * 522 509 invNoise2; 523 510 … … 527 514 // Background only terms 528 515 stampMatrix->data.F64[bgIndex][bgIndex] += invNoise2; 529 stampVector->data.F64[bgIndex] += input-> data.F32[y][x] * invNoise2;516 stampVector->data.F64[bgIndex] += input->kernel[y][x] * invNoise2; 530 517 } 531 518 }
Note:
See TracChangeset
for help on using the changeset viewer.
