Changeset 4418
- Timestamp:
- Jun 28, 2005, 1:28:18 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/tst_pmImageSubtract.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/tst_pmImageSubtract.c
r4322 r4418 10 10 * data. More work need to be done to verify the results. 11 11 * 12 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-06-2 0 23:21:05$12 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-06-28 23:28:18 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 305 305 bool testStatus = false; 306 306 307 testStatus|= testISISAlloc(1, 1, 1, 1); 308 testStatus|= testISISAlloc(2, 2, 2, 2); 309 testStatus|= testISISAlloc(2, 3, 4, 5); 310 testStatus|= testISISAlloc(3, 4, 5, 6); 307 /* 308 testStatus|= testISISAlloc(1, 1, 1, 1); 309 testStatus|= testISISAlloc(2, 2, 2, 2); 310 testStatus|= testISISAlloc(2, 3, 4, 5); 311 testStatus|= testISISAlloc(3, 4, 5, 6); 312 */ 311 313 312 314 return(!testStatus); … … 496 498 } 497 499 498 500 // 501 // XXX: POIS kernels are producing NANs if the image size is 20 or less. 502 // 503 // XXX: ISIS kernels are producing NANS if the TST03_ORDER_LENGTH is 2 or larger. 504 // 499 505 #define TST03_THRESHOLD 3.0 500 506 #define TST03_MASK_VAL 1 501 507 #define TST03_KERNEL_SIZE 2 502 #define TST03_SPATIAL_ORDER 3503 #define TST03_ORDER_LENGTH 2504 #define TST03_SIGMA_LENGTH 3508 #define TST03_SPATIAL_ORDER 2 509 #define TST03_ORDER_LENGTH 1 510 #define TST03_SIGMA_LENGTH 1 505 511 #define TST03_PSF_MAX 10.0 506 #define TST03_IMAGE_SIZE 40 512 #define TST03_BG 0.0 513 #define TST03_IMAGE_SIZE 25 507 514 #define TST03_NUM_COLS TST03_IMAGE_SIZE 508 515 #define TST03_NUM_ROWS TST03_IMAGE_SIZE … … 515 522 #define TST03_PSF_WIDTH (TST03_FOOTPRINT/2 - 1) 516 523 524 /******************************************************************************* 525 This routine generates an object in the center of the stamp defined by the 526 (xMin, xMax) and (yMin, yMax) boundary. 527 ******************************************************************************/ 517 528 psBool genObject(psImage *tstImg, 518 529 psImage *refImg, … … 522 533 psS32 yMax) 523 534 { 524 if (0) { 525 for (psS32 y = yMin ; y <= yMax ; y++) { 526 for (psS32 x = xMin ; x <= xMax ; x++) { 527 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (y/10 + x/10); 528 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (y/10 + x/10); 529 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 530 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 531 532 // Add some noise for the test image. 533 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2]+= genRanFloat(0.0, 1.0); 534 535 if (((1 + 2 * TST03_PSF_WIDTH) > (xMax - xMin)) || 536 ((1 + 2 * TST03_PSF_WIDTH) > (yMax - yMin))) { 537 printf("INCORRECT TEST CONFIGURATION: TST03_PSF_WIDTH is too big.\n"); 538 printf("TST03_PSF_WIDTH is %d: (xMin - xMax) is %d\n", TST03_PSF_WIDTH, (xMax - xMin)); 539 return(FALSE); 540 } 541 // 542 // This code basically creates a peak at the center of the stamp with 543 // a height of TST03_PSF_MAX 544 // 545 psS32 xCenter = (xMax + xMin) / 2; 546 psS32 yCenter = (yMax + yMin) / 2; 547 psF32 subImageWidth = 1.0 + sqrtf(PS_SQR(((psF32) ((yMax-yMin)/2))) + PS_SQR(((psF32) ((xMax-xMin)/2)))); 548 for (psS32 y = yMin ; y <= yMax ; y++) { 549 for (psS32 x = xMin ; x <= xMax ; x++) { 550 psF32 dist = sqrtf(PS_SQR((psF32) (y - yCenter)) + PS_SQR((psF32) (x - xCenter))); 551 psF32 pixel = TST03_PSF_MAX * PS_SQR(((psF32) (subImageWidth - dist)) / ((psF32) subImageWidth)); 552 if (pixel < 0.0) { 553 pixel = 0.0; 535 554 } 536 } 537 538 } else { 539 if (((1 + 2 * TST03_PSF_WIDTH) > (xMax - xMin)) || 540 ((1 + 2 * TST03_PSF_WIDTH) > (yMax - yMin))) { 541 printf("INCORRECT TEST CONFIGURATION: TST03_PSF_WIDTH is too big.\n"); 542 printf("TST03_PSF_WIDTH is %d: (xMin - xMax) is %d\n", TST03_PSF_WIDTH, (xMax - xMin)); 543 return(FALSE); 544 } 545 // 546 // HEY 547 // This code basically creates a peak at the center of the stamp with 548 // a height of TST03_PSF_MAX 549 // 550 psS32 xCenter = (xMax + xMin) / 2; 551 psS32 yCenter = (yMax + yMin) / 2; 552 psF32 subImageWidth = 1.0 + sqrtf(PS_SQR(((psF32) ((yMax-yMin)/2))) + PS_SQR(((psF32) ((xMax-xMin)/2)))); 553 for (psS32 y = yMin ; y <= yMax ; y++) { 554 for (psS32 x = xMin ; x <= xMax ; x++) { 555 psF32 dist = sqrtf(PS_SQR((psF32) (y - yCenter)) + PS_SQR((psF32) (x - xCenter))); 556 psF32 pixel = TST03_PSF_MAX * PS_SQR(((psF32) (subImageWidth - dist)) / ((psF32) subImageWidth)); 557 if (pixel < 0.0) { 558 pixel = 0.0; 559 } 560 refImg->data.F32[y][x] = pixel; 561 tstImg->data.F32[y][x] = pixel; 562 // Add some noise for the test image. 563 tstImg->data.F32[y][x]+= genRanFloat(0.0, 1.0); 564 } 565 } 566 } 555 refImg->data.F32[y][x] = pixel + TST03_BG; 556 tstImg->data.F32[y][x] = pixel + TST03_BG; 557 // Add some noise for the test image. 558 tstImg->data.F32[y][x]+= genRanFloat(0.0, 1.0); 559 } 560 } 561 567 562 return(TRUE); 568 563 } … … 573 568 XXX: We should use a larger variety of input parameter configurations. 574 569 575 XXX: I test the following functions here (since they linearly rely on a set of 576 datastructures that the previoues ones generate):570 I test the following functions here (since they linearly rely on a set of data 571 structures that the previoues ones generate): 577 572 pmSubtractionCalculateEquation() 578 573 pmSubtractionSolveEquation() 579 574 pmSubtractionRejectStamps() 580 575 pmSubtractionKernelImage() 581 582 XXX: We test that the functions do not seg fault, or generate other errors.583 However, additional work, and further understanding, is required to begin584 testing that the output values are correct as well.585 576 ******************************************************************************/ 586 577 psBool testSubCalcEqu(psS32 numCols, … … 614 605 psS32 xMax = PS_MIN(numCols-1, (border + (i + 1) * (numCols - 2.0 * border) / xNum) - 1); 615 606 616 if (0) { 617 // Set the center pixel in the stamp. 618 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (i + j); 619 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (i + j); 620 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 621 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 622 623 // Add some noise for the test image. 624 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2]+= genRanFloat(0.0, 1.0); 625 } else { 626 genObject(tstImg, refImg, xMin, xMax, yMin, yMax); 627 } 607 genObject(tstImg, refImg, xMin, xMax, yMin, yMax); 628 608 } 629 609 } … … 702 682 } else { 703 683 684 if (0) { 685 for (psS32 s = 0 ; s < stamps->n ; s++) { 686 printf("********************************* Stamp %d *********************************\n", s); 687 pmStamp *stamp = (pmStamp *) stamps->data[s]; 688 if (stamp->vector != NULL) { 689 PS_VECTOR_PRINT_F64(stamp->vector); 690 } 691 if (stamp->matrix != NULL) { 692 printf("Stamp matrix size is (%d, %d)\n", stamp->matrix->numRows, stamp->matrix->numCols); 693 PS_IMAGE_PRINT_F64(stamp->matrix); 694 } 695 } 696 } 697 698 704 699 //------------------------------------------------------------------------- 705 700 printf("Calling pmSubtractionSolveEquation() with a NULL stamp argument. Should generate error, return FALSE.\n"); … … 717 712 testStatus = true; 718 713 } else { 714 printf("The solution vector is:\n"); 715 for (psS32 i = 0 ; i < solution->n ; i++) { 716 printf("(%.2f) ", solution->data.F64[i]); 717 } 718 printf("\n"); 719 719 720 720 //------------------------------------------------------------------------- … … 725 725 printf("TEST ERROR: pmSubtractionRejectStamps() returned FALSE.\n"); 726 726 testStatus = true; 727 } else { 728 printf("The solution vector is:\n"); 729 for (psS32 i = 0 ; i < solution->n ; i++) { 730 printf("(%.2f) ", solution->data.F32[i]); 731 } 732 printf("\n"); 733 } 727 } else {} 734 728 735 729 //------------------------------------------------------------------------- … … 824 818 bool testStatus = false; 825 819 826 testStatus|= testSubCalcEqu(TST03_NUM_COLS, 827 TST03_NUM_ROWS, 828 TST03_NUM_STAMPS_COLS, 829 TST03_NUM_STAMPS_ROWS, 830 TST03_BORDER, 831 PM_SUBTRACTION_KERNEL_POIS); 832 833 testStatus|= testSubCalcEqu(TST03_NUM_COLS, 834 TST03_NUM_ROWS, 835 TST03_NUM_STAMPS_COLS, 836 TST03_NUM_STAMPS_ROWS, 837 TST03_BORDER, 838 PM_SUBTRACTION_KERNEL_ISIS); 820 821 srand(1995); 822 if (1) 823 testStatus|= testSubCalcEqu(TST03_NUM_COLS, 824 TST03_NUM_ROWS, 825 TST03_NUM_STAMPS_COLS, 826 TST03_NUM_STAMPS_ROWS, 827 TST03_BORDER, 828 PM_SUBTRACTION_KERNEL_POIS); 829 830 831 srand(1995); 832 if (1) 833 testStatus|= testSubCalcEqu(TST03_NUM_COLS, 834 TST03_NUM_ROWS, 835 TST03_NUM_STAMPS_COLS, 836 TST03_NUM_STAMPS_ROWS, 837 TST03_BORDER, 838 PM_SUBTRACTION_KERNEL_ISIS); 839 840 839 841 840 842 return(!testStatus); 841 843 } 842 843 //This code will
Note:
See TracChangeset
for help on using the changeset viewer.
