Changeset 13483 for trunk/psLib/src/imageops/psImageInterpolate.c
- Timestamp:
- May 22, 2007, 4:55:01 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageInterpolate.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageInterpolate.c
r12802 r13483 7 7 * @author Paul Price, IfA 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-0 4-11 19:54:47$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-05-23 02:55:01 $ 11 11 * 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 65 65 66 66 // Interpolation engine for flat mode (nearest pixel) 67 static inline bool interpolateFlat(double *imageValue, double *varianceValue, psMaskType *maskValue, 68 float x, float y, const psImageInterpolateOptions *options) 67 static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue, 68 psMaskType *maskValue, float x, float y, 69 const psImageInterpolateOptions *options) 69 70 { 70 71 // Parameters have been checked by psImageInterpolate() … … 87 88 *maskValue = options->badMask; 88 89 } 90 91 return PS_INTERPOLATE_STATUS_OFF; 89 92 } else { 90 93 … … 115 118 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x", 116 119 options->image->type.type); 117 return false;120 return PS_INTERPOLATE_STATUS_ERROR; 118 121 } 119 122 … … 122 125 } 123 126 } 124 return true;127 return PS_INTERPOLATE_STATUS_GOOD; 125 128 } 126 129 127 130 // Interpolation engine using interpolation kernel 128 static bool interpolateKernel(double *imageValue, double *varianceValue, psMaskType *maskValue, 129 float x, float y, const psImageInterpolateOptions *options) 131 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue, 132 psMaskType *maskValue, float x, float y, 133 const psImageInterpolateOptions *options) 130 134 { 131 135 // Parameters have been checked by psImageInterpolate() … … 171 175 *maskValue = options->badMask; 172 176 } 173 return true;177 return PS_INTERPOLATE_STATUS_OFF; 174 178 } 175 179 double kernel[yNum][xNum]; // Interpolation kernel for straight interpolation … … 259 263 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x", 260 264 image->type.type); 261 return false;265 return PS_INTERPOLATE_STATUS_ERROR; 262 266 } 263 267 } … … 265 269 // Check the mask value 266 270 const psImage *mask = options->mask; // Image mask 271 psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation 267 272 if (maskValue && mask) { 268 273 *maskValue = 0; … … 285 290 if (badContrib / totContrib >= options->poorFrac) { 286 291 *maskValue |= options->badMask; 292 status = PS_INTERPOLATE_STATUS_BAD; 287 293 } else { 288 294 *maskValue |= options->poorMask; 295 status = PS_INTERPOLATE_STATUS_POOR; 289 296 } 290 297 } … … 321 328 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x", 322 329 image->type.type); 323 return false;324 } 325 } 326 327 return true;330 return PS_INTERPOLATE_STATUS_ERROR; 331 } 332 } 333 334 return status; 328 335 } 329 336 … … 364 371 365 372 // Interpolation engine for separable interpolation kernels (either for good reasons or for practical reasons) 366 static bool interpolateSeparate(double *imageValue, double *varianceValue, psMaskType *maskValue, 367 float x, float y, const psImageInterpolateOptions *options) 373 static psImageInterpolateStatus interpolateSeparate(double *imageValue, double *varianceValue, 374 psMaskType *maskValue, float x, float y, 375 const psImageInterpolateOptions *options) 368 376 { 369 377 // Parameters have been checked by psImageInterpolate() … … 406 414 *maskValue = options->badMask; 407 415 } 408 return true;416 return PS_INTERPOLATE_STATUS_OFF; 409 417 } 410 418 … … 477 485 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x", 478 486 image->type.type); 479 return false;487 return PS_INTERPOLATE_STATUS_ERROR; 480 488 } 481 489 } … … 483 491 // Check the mask value 484 492 const psImage *mask = options->mask; // Image mask 493 psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation 485 494 if (maskValue && mask) { 486 495 psMaskType maskVal = options->maskVal; // Mask value … … 509 518 if (badContrib / totContrib >= options->poorFrac) { 510 519 *maskValue |= options->badMask; 520 status = PS_INTERPOLATE_STATUS_BAD; 511 521 } else { 512 522 *maskValue |= options->poorMask; 523 status = PS_INTERPOLATE_STATUS_POOR; 513 524 } 514 525 } … … 547 558 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x", 548 559 variance->type.type); 549 return false;550 } 551 } 552 553 return true;554 } 555 556 557 558 boolpsImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,560 return PS_INTERPOLATE_STATUS_ERROR; 561 } 562 } 563 564 return status; 565 } 566 567 568 569 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue, 559 570 float x, float y, const psImageInterpolateOptions *options) 560 571 { 561 PS_ASSERT_PTR_NON_NULL(options, false);572 PS_ASSERT_PTR_NON_NULL(options, PS_INTERPOLATE_STATUS_ERROR); 562 573 563 574 const psImage *image = options->image; // Image to interpolate … … 565 576 const psImage *variance = options->variance; // Variance to interpolate 566 577 567 PS_ASSERT_IMAGE_NON_NULL(image, false);578 PS_ASSERT_IMAGE_NON_NULL(image, PS_INTERPOLATE_STATUS_ERROR); 568 579 if (varianceValue && variance) { 569 PS_ASSERT_IMAGE_NON_NULL(variance, false);570 PS_ASSERT_IMAGE_TYPE(variance, image->type.type, false);571 PS_ASSERT_IMAGES_SIZE_EQUAL(variance, image, false);580 PS_ASSERT_IMAGE_NON_NULL(variance, PS_INTERPOLATE_STATUS_ERROR); 581 PS_ASSERT_IMAGE_TYPE(variance, image->type.type, PS_INTERPOLATE_STATUS_ERROR); 582 PS_ASSERT_IMAGES_SIZE_EQUAL(variance, image, PS_INTERPOLATE_STATUS_ERROR); 572 583 } 573 584 if (maskValue && mask) { 574 PS_ASSERT_IMAGE_NON_NULL(mask, false);575 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);576 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);577 } 578 579 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(options->poorFrac, 0.0, false);585 PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR); 586 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, PS_INTERPOLATE_STATUS_ERROR); 587 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, PS_INTERPOLATE_STATUS_ERROR); 588 } 589 590 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(options->poorFrac, 0.0, PS_INTERPOLATE_STATUS_ERROR); 580 591 581 592 switch (options->mode) { … … 594 605 _("Specified interpolation method (%d) is not supported."), 595 606 options->mode); 596 return false;607 return PS_INTERPOLATE_STATUS_ERROR; 597 608 } 598 609 599 610 psAbort("Should never reach here."); 600 return false;611 return PS_INTERPOLATE_STATUS_ERROR; 601 612 } 602 613
Note:
See TracChangeset
for help on using the changeset viewer.
