Changeset 14801 for trunk/psModules/src/imcombine/pmSubtractionParams.c
- Timestamp:
- Sep 10, 2007, 10:10:05 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionParams.c
r14738 r14801 171 171 172 172 pmSubtractionKernels *pmSubtractionKernelsOptimumISIS(pmSubtractionKernelsType type, int size, int inner, 173 int spatialOrder, psVector *fwhms, int maxOrder, 174 const psArray *stamps, int footprint, float tolerance) 173 int spatialOrder, psVector *fwhms, int maxOrder, 174 const pmSubtractionStampList *stamps, int footprint, 175 float tolerance) 175 176 { 176 177 if (type != PM_SUBTRACTION_KERNEL_ISIS && type != PM_SUBTRACTION_KERNEL_GUNK) { … … 184 185 PS_ASSERT_VECTOR_TYPE(fwhms, PS_TYPE_F32, NULL); 185 186 PS_ASSERT_INT_NONNEGATIVE(maxOrder, NULL); 186 P S_ASSERT_ARRAY_NON_NULL(stamps, NULL);187 PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(stamps, NULL); 187 188 PS_ASSERT_INT_NONNEGATIVE(footprint, NULL); 188 189 PS_ASSERT_FLOAT_LARGER_THAN(tolerance, 0.0, NULL); … … 208 209 209 210 // Need to save the stamp inputs --- we're changing the values! 210 int numStamps = stamps->n ;// Number of stamps211 int numStamps = stamps->num; // Number of stamps 211 212 psArray *inputs = psArrayAlloc(numStamps); // Deep copies of the inputs 213 psVector *badStamps = psVectorAlloc(numStamps, PS_TYPE_U8); // Mark the bad stamps 214 psVectorInit(badStamps, 0); 212 215 for (int i = 0; i < numStamps; i++) { 213 pmSubtractionStamp *stamp = stamps->data[i]; // Stamp of interest 214 if (stamp->status == PM_SUBTRACTION_STAMP_REJECTED || stamp->status == PM_SUBTRACTION_STAMP_NONE) { 216 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 217 if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE && stamp->status != PM_SUBTRACTION_STAMP_USED) { 218 badStamps->data.U8[i] = 0xff; 215 219 continue; 216 220 } … … 230 234 int numPixels = 0; // Number of pixels contributing to chi^2 231 235 for (int i = 0; i < numStamps; i++) { 232 pmSubtractionStamp *stamp = stamps-> data[i]; // Stamp of interest233 if ( stamp->status == PM_SUBTRACTION_STAMP_REJECTED || stamp->status == PM_SUBTRACTION_STAMP_NONE) {236 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 237 if (badStamps->data.U8[i]) { 234 238 continue; 235 239 } … … 238 242 psFree(inputs); 239 243 psFree(kernels); 244 psFree(badStamps); 240 245 return NULL; 241 246 } … … 255 260 psFree(inputs); 256 261 psFree(kernels); 262 psFree(badStamps); 257 263 return NULL; 258 264 } … … 287 293 288 294 for (int j = 0; j < numStamps; j++) { 289 pmSubtractionStamp *stamp = stamps->data[j]; // Stamp of interest 290 if (stamp->status == PM_SUBTRACTION_STAMP_REJECTED || 291 stamp->status == PM_SUBTRACTION_STAMP_NONE) { 295 if (badStamps->data.U8[j]) { 292 296 continue; 293 297 } 298 pmSubtractionStamp *stamp = stamps->stamps->data[j]; // Stamp of interest 294 299 accumulateCross(&sumI, &sumII, &sumIC, stamp, inputs->data[j], i, footprint); 295 300 } … … 301 306 double chi2 = 0.0; // Chi^2 302 307 for (int j = 0; j < numStamps; j++) { 303 pmSubtractionStamp *stamp = stamps->data[j]; // Stamp of interest 304 if (stamp->status == PM_SUBTRACTION_STAMP_REJECTED || 305 stamp->status == PM_SUBTRACTION_STAMP_NONE) { 308 if (badStamps->data.U8[j]) { 306 309 continue; 307 310 } 311 pmSubtractionStamp *stamp = stamps->stamps->data[j]; // Stamp of interest 308 312 chi2 += accumulateChi2(inputs->data[j], stamp, i, coeff, bg, footprint); 309 313 } … … 329 333 psFree(ranking); 330 334 psFree(kernels); 335 psFree(badStamps); 331 336 return NULL; 332 337 } … … 336 341 // Remove its contribution, and don't include it in the future. 337 342 for (int j = 0; j < numStamps; j++) { 338 pmSubtractionStamp *stamp = stamps->data[j]; // Stamp of interest 339 if (stamp->status == PM_SUBTRACTION_STAMP_REJECTED || 340 stamp->status == PM_SUBTRACTION_STAMP_NONE) { 343 if (badStamps->data.U8[j]) { 341 344 continue; 342 345 } 346 pmSubtractionStamp *stamp = stamps->stamps->data[j]; // Stamp of interest 343 347 subtractConvolution(inputs->data[j], stamp, bestIndex, bestCoeff, bestBG, footprint); 344 348 } … … 365 369 psFree(ranking); 366 370 psFree(kernels); 371 psFree(badStamps); 367 372 return NULL; 368 373 } … … 376 381 psArray *convNew = psArrayAlloc(numStamps); 377 382 for (int i = 0; i < numStamps; i++) { 383 if (badStamps->data.U8[i]) { 384 continue; 385 } 378 386 convNew->data[i] = psArrayAlloc(newSize); 379 387 } … … 388 396 389 397 for (int j = 0; j < numStamps; j++) { 398 if (badStamps->data.U8[j]) { 399 continue; 400 } 401 pmSubtractionStamp *stamp = stamps->stamps->data[j]; // Stamp of interest 390 402 psArray *convolutions = convNew->data[j]; // Convolutions for this stamp 391 pmSubtractionStamp *stamp = stamps->data[j]; // Stamp of interest392 403 convolutions->data[rank] = psMemIncrRefCounter(stamp->convolutions->data[i]); 393 404 } … … 405 416 406 417 for (int i = 0; i < numStamps; i++) { 407 pmSubtractionStamp *stamp = stamps->data[i]; // Stamp of interest 418 if (badStamps->data.U8[i]) { 419 continue; 420 } 421 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 408 422 psFree(stamp->convolutions); 409 423 stamp->convolutions = convNew->data[i]; 410 424 } 411 425 426 psFree(badStamps); 412 427 psFree(ranking); 413 428
Note:
See TracChangeset
for help on using the changeset viewer.
