Changeset 4992 for trunk/psModules/src/pmImageCombine.c
- Timestamp:
- Sep 11, 2005, 12:25:39 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmImageCombine.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmImageCombine.c
r4425 r4992 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-29 01:39:10$10 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-09-11 22:25:39 $ 12 12 * 13 13 * XXX: pmRejectPixels() has a known bug with the pmImageTransform() call. … … 308 308 /****************************************************************************** 309 309 XXX: Directly from Paul Price 310 XXX: Must add mask parameter, use it in gradient calculation.311 310 *****************************************************************************/ 312 static psF32 CalcGradient(psImage *image, 313 psS32 x, 314 psS32 y) 311 static psF32 CalcGradient( 312 psImage *image, 313 psImage *imageMask, 314 psS32 x, 315 psS32 y 316 ) 315 317 { 316 318 psTrace("ImageCombine.CalcGradient", 4, "Calling CalcGradient(%d, %d)\n", x, y); … … 324 326 int yMin = PS_MAX(y - 1, 0); 325 327 int yMax = PS_MIN(y + 1, image->numRows - 1); 326 for (int j = yMin; j <= yMax; j++) { 327 for (int i = xMin; i <= xMax; i++) { 328 if ((i != x) && (j != y)) { 329 pixels->data.F32[num] = image->data.F32[j][i]; 330 mask->data.U8[num] = 0; 331 num++; 328 if (imageMask != NULL) { 329 for (int j = yMin; j <= yMax; j++) { 330 for (int i = xMin; i <= xMax; i++) { 331 if ((i != x) && (j != y) && (0 == imageMask->data.U8[j][i])) { 332 pixels->data.F32[num] = image->data.F32[j][i]; 333 mask->data.U8[num] = 0; 334 num++; 335 } else { 336 mask->data.U8[num] = 1; 337 } 332 338 } 333 339 } 334 } 340 } else { 341 // 342 // This code is simply the previous loop without the imageMask. 343 // XXX: Consider restructuring this. 344 // 345 for (int j = yMin; j <= yMax; j++) { 346 for (int i = xMin; i <= xMax; i++) { 347 if ((i != x) && (j != y)) { 348 pixels->data.F32[num] = image->data.F32[j][i]; 349 mask->data.U8[num] = 0; 350 num++; 351 } else { 352 mask->data.U8[num] = 1; 353 } 354 } 355 } 356 } 357 335 358 pixels->n = num; 336 359 mask->n = num; … … 472 495 XXX: The inToOut and outToIn transforms are confusing. Verify that what 473 496 I think they mean syncs with PWP. 474 XXX: Must add mask parameter, use it in gradient calculation.475 497 *****************************************************************************/ 476 psArray *pmRejectPixels(const psArray *images, ///< Array of input images 477 const psArray *errors, ///< The pixels which were rejected in the combination 478 const psArray *inToOut, ///< Transformation from input to output system 479 const psArray *outToIn, ///< Transformation from output to input system 480 psF32 rejThreshold, ///< Rejection threshold 481 psF32 gradLimit ///< Gradient limit 482 ) 498 psArray *pmRejectPixels( 499 const psArray *images, ///< Array of input images 500 const psArray *masks, ///< Array of input image masks 501 const psArray *errors, ///< The pixels which were rejected in the combination 502 const psArray *inToOut, ///< Transformation from input to output system 503 const psArray *outToIn, ///< Transformation from output to input system 504 psF32 rejThreshold, ///< Rejection threshold 505 psF32 gradLimit ///< Gradient limit 506 ) 483 507 { 484 508 psTrace("ImageCombine.pmRejectPixels", 3, "Calling pmRejectPixels()\n"); 485 509 PS_ASSERT_PTR_NON_NULL(images, NULL); 510 for (psS32 im = 0 ; im < images->n ; im++) { 511 psImage *tmpImage = (psImage *) images->data[im]; 512 PS_ASSERT_IMAGE_NON_NULL(tmpImage, NULL); 513 PS_ASSERT_IMAGE_NON_EMPTY(tmpImage, NULL); 514 PS_ASSERT_IMAGE_TYPE(tmpImage, PS_TYPE_F32, NULL); 515 if (masks != NULL) { 516 PS_ASSERT_INT_EQUAL(images->n, masks->n, NULL); 517 psImage *tmpMask = (psImage *) masks->data[im]; 518 PS_ASSERT_IMAGE_NON_NULL(tmpMask, NULL); 519 PS_ASSERT_IMAGE_NON_EMPTY(tmpMask, NULL); 520 PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL); 521 PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL); 522 } 523 PS_ASSERT_IMAGES_SIZE_EQUAL(((psImage *) images->data[0]), tmpImage, NULL); 524 } 486 525 PS_ASSERT_PTR_NON_NULL(errors, NULL); 487 526 PS_ASSERT_PTR_NON_NULL(inToOut, NULL); … … 492 531 PS_ASSERT_INT_EQUAL(numImages, inToOut->n, NULL); 493 532 PS_ASSERT_INT_EQUAL(numImages, outToIn->n, NULL); 494 // XXX: Loop through all images, ensure their sizes are equal495 533 496 534 // … … 570 608 if (im != otherImg) { 571 609 // Map the outCoords to inCoords that for otherImg space. 610 psImage *tmpMask = NULL; 611 if (masks != NULL) { 612 tmpMask = masks->data[otherImg]; 613 } 572 614 psPlaneTransformApply(inCoords, 573 615 (psPlaneTransform * )outToIn->data[otherImg], … … 577 619 if ((xPix >= 0) && (xPix <= ((psImage*)(images->data[otherImg]))->numCols - 1) && 578 620 (yPix >= 0) && (yPix <= ((psImage*)(images->data[otherImg]))->numRows - 1)) { 579 meanGrads += CalcGradient(images->data[otherImg], xPix, yPix);621 meanGrads += CalcGradient(images->data[otherImg], tmpMask, xPix, yPix); 580 622 numGrads++; 581 623 }
Note:
See TracChangeset
for help on using the changeset viewer.
