Changeset 4322 for trunk/psModules/test/tst_pmImageSubtract.c
- Timestamp:
- Jun 20, 2005, 1:21:05 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
r4224 r4322 10 10 * data. More work need to be done to verify the results. 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-06- 13 20:12:18$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-06-20 23:21:05 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 int main(int argc, char* argv[]) 34 34 { 35 psLogSetFormat("HLNM"); 35 36 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 36 37 } … … 495 496 } 496 497 497 #define TST03_THRESHOLD 3.0 498 #define TST03_MASK_VAL 1 498 499 #define TST03_THRESHOLD 3.0 500 #define TST03_MASK_VAL 1 499 501 #define TST03_KERNEL_SIZE 2 500 502 #define TST03_SPATIAL_ORDER 3 501 503 #define TST03_ORDER_LENGTH 2 502 504 #define TST03_SIGMA_LENGTH 3 503 #define TST03_FOOTPRINT 5 505 #define TST03_PSF_MAX 10.0 506 #define TST03_IMAGE_SIZE 40 507 #define TST03_NUM_COLS TST03_IMAGE_SIZE 508 #define TST03_NUM_ROWS TST03_IMAGE_SIZE 509 #define TST03_NUM_STAMPS 2 510 #define TST03_NUM_STAMPS_COLS TST03_NUM_STAMPS 511 #define TST03_NUM_STAMPS_ROWS TST03_NUM_STAMPS 512 #define TST03_BORDER TST03_KERNEL_SIZE 513 //#define TST03_FOOTPRINT (((TST03_IMAGE_SIZE - (2 * TST03_BORDER)) / TST03_NUM_STAMPS) - TST03_KERNEL_SIZE) 514 #define TST03_FOOTPRINT 4 515 #define TST03_PSF_WIDTH (TST03_FOOTPRINT/2 - 1) 516 517 psBool genObject(psImage *tstImg, 518 psImage *refImg, 519 psS32 xMin, 520 psS32 xMax, 521 psS32 yMin, 522 psS32 yMax) 523 { 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 } 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 } 567 return(TRUE); 568 } 569 504 570 /******************************************************************************* 505 571 NOTE: This function returns FALSE if there were no errors. … … 548 614 psS32 xMax = PS_MIN(numCols-1, (border + (i + 1) * (numCols - 2.0 * border) / xNum) - 1); 549 615 550 // Set the center pixel in the stamp. 551 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (i + j); 552 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = TST03_THRESHOLD + (psF32) (i + j); 553 refImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 554 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2] = 100.0; 555 556 // Add some noise for the test image. 557 tstImg->data.F32[(yMax+yMin)/2][(xMax+xMin)/2]+= genRanFloat(0.0, 1.0); 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 } 558 628 } 559 629 } … … 593 663 //------------------------------------------------------------------------- 594 664 printf("Calling with a NULL psArray stamps. Should generate error, return FALSE.\n"); 595 psBool rc = pmSubtractionCalculateEquation(NULL, refImg, tstImg, myKernels, TST03_ KERNEL_SIZE);665 psBool rc = pmSubtractionCalculateEquation(NULL, refImg, tstImg, myKernels, TST03_FOOTPRINT); 596 666 if (rc == TRUE) { 597 667 printf("TEST ERROR: pmSubtractionCalculateEquation() returned TRUE.\n"); … … 601 671 //------------------------------------------------------------------------- 602 672 printf("Calling with a NULL reference images. Should generate error, return FALSE.\n"); 603 rc = pmSubtractionCalculateEquation(stamps, NULL, tstImg, myKernels, TST03_ KERNEL_SIZE);673 rc = pmSubtractionCalculateEquation(stamps, NULL, tstImg, myKernels, TST03_FOOTPRINT); 604 674 if (rc == TRUE) { 605 675 printf("TEST ERROR: pmSubtractionCalculateEquation() returned TRUE.\n"); … … 609 679 //------------------------------------------------------------------------- 610 680 printf("Calling with a NULL input images. Should generate error, return FALSE.\n"); 611 rc = pmSubtractionCalculateEquation(stamps, refImg, NULL, myKernels, TST03_ KERNEL_SIZE);681 rc = pmSubtractionCalculateEquation(stamps, refImg, NULL, myKernels, TST03_FOOTPRINT); 612 682 if (rc == TRUE) { 613 683 printf("TEST ERROR: pmSubtractionCalculateEquation() returned TRUE.\n"); … … 617 687 //------------------------------------------------------------------------- 618 688 printf("Calling with a NULL kernel basis functions. Should generate error, return FALSE.\n"); 619 rc = pmSubtractionCalculateEquation(stamps, refImg, tstImg, NULL, TST03_ KERNEL_SIZE);689 rc = pmSubtractionCalculateEquation(stamps, refImg, tstImg, NULL, TST03_FOOTPRINT); 620 690 if (rc == TRUE) { 621 691 printf("TEST ERROR: pmSubtractionCalculateEquation() returned TRUE.\n"); … … 626 696 printf("Calling with acceptable input parameters. Should return TRUE.\n"); 627 697 628 rc = pmSubtractionCalculateEquation(stamps, refImg, tstImg, myKernels, TST03_ KERNEL_SIZE);698 rc = pmSubtractionCalculateEquation(stamps, refImg, tstImg, myKernels, TST03_FOOTPRINT); 629 699 if (rc != TRUE) { 630 700 printf("TEST ERROR: pmSubtractionCalculateEquation() returned FALSE.\n"); … … 641 711 642 712 //------------------------------------------------------------------------- 643 printf("Calling with pmSubtractionSolveEquation()acceptable input parameters. Should return non-NULL.\n");713 printf("Calling pmSubtractionSolveEquation() with acceptable input parameters. Should return non-NULL.\n"); 644 714 solution = pmSubtractionSolveEquation(NULL, stamps); 645 715 if (solution == NULL) { 646 716 printf("TEST ERROR: pmSubtractionSolveEquation() returned NULL.\n"); 647 717 testStatus = true; 718 } else { 719 720 //------------------------------------------------------------------------- 721 printf("Calling pmSubtractionRejectStamps() with acceptable input parameters. Should return TRUE.\n"); 722 rc = pmSubtractionRejectStamps(stamps, maskImg, 0xff, TST03_FOOTPRINT, 1.0, refImg, 723 tstImg, solution, myKernels); 724 if (rc != TRUE) { 725 printf("TEST ERROR: pmSubtractionRejectStamps() returned FALSE.\n"); 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 } 734 735 //------------------------------------------------------------------------- 736 printf("Calling pmSubtractionKernelImage() with NULL solution. Should generate error, return NULL.\n"); 737 psImage *kernelImg = pmSubtractionKernelImage(NULL, NULL, myKernels, 0.0, 0.0); 738 if (kernelImg != NULL) { 739 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 740 testStatus = true; 741 } 742 free(kernelImg); 743 744 //------------------------------------------------------------------------- 745 printf("Calling pmSubtractionKernelImage() with NULL kernels. Should generate error, return NULL.\n"); 746 kernelImg = pmSubtractionKernelImage(NULL, solution, NULL, 0.0, 0.0); 747 if (kernelImg != NULL) { 748 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 749 testStatus = true; 750 } 751 free(kernelImg); 752 753 //------------------------------------------------------------------------- 754 printf("Calling pmSubtractionKernelImage() unallowable x value. Should generate error, return NULL.\n"); 755 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, -2.0, 0.0); 756 if (kernelImg != NULL) { 757 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 758 testStatus = true; 759 } 760 free(kernelImg); 761 762 //------------------------------------------------------------------------- 763 printf("Calling pmSubtractionKernelImage() unallowable x value. Should generate error, return NULL.\n"); 764 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 2.0, 0.0); 765 if (kernelImg != NULL) { 766 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 767 testStatus = true; 768 } 769 free(kernelImg); 770 771 //------------------------------------------------------------------------- 772 printf("Calling pmSubtractionKernelImage() unallowable y value. Should generate error, return NULL.\n"); 773 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.0, -2.0); 774 if (kernelImg != NULL) { 775 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 776 testStatus = true; 777 } 778 free(kernelImg); 779 780 //------------------------------------------------------------------------- 781 printf("Calling pmSubtractionKernelImage() unallowable y value. Should generate error, return NULL.\n"); 782 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.0, 2.0); 783 if (kernelImg != NULL) { 784 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n"); 785 testStatus = true; 786 } 787 free(kernelImg); 788 789 //------------------------------------------------------------------------- 790 printf("Calling pmSubtractionKernelImage() with acceptable input parameters. Should return a psImage.\n"); 791 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.5, 0.5); 792 if (kernelImg == NULL) { 793 printf("TEST ERROR: pmSubtractionKernelImage() returned NULL.\n"); 794 testStatus = true; 795 } else { 796 for (psS32 row = 0 ; row < kernelImg->numRows; row++) { 797 for (psS32 col = 0 ; col < kernelImg->numCols; col++) { 798 printf("%f ", kernelImg->data.F32[row][col]); 799 } 800 printf("\n"); 801 } 802 } 803 free(kernelImg); 804 805 psFree(solution); 648 806 } 649 650 //-------------------------------------------------------------------------651 printf("Calling with pmSubtractionRejectStamps() acceptable input parameters. Should return TRUE.\n");652 rc = pmSubtractionRejectStamps(stamps, maskImg, 0xff, TST03_FOOTPRINT, 1.0, refImg, tstImg, solution, myKernels);653 if (rc != TRUE) {654 printf("TEST ERROR: pmSubtractionRejectStamps() returned FALSE.\n");655 testStatus = true;656 }657 658 //-------------------------------------------------------------------------659 printf("Calling pmSubtractionKernelImage() with NULL solution. Should generate error, return NULL.\n");660 psImage *kernelImg = pmSubtractionKernelImage(NULL, NULL, myKernels, 0.0, 0.0);661 if (kernelImg != NULL) {662 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");663 testStatus = true;664 }665 free(kernelImg);666 667 //-------------------------------------------------------------------------668 printf("Calling pmSubtractionKernelImage() with NULL kernels. Should generate error, return NULL.\n");669 kernelImg = pmSubtractionKernelImage(NULL, solution, NULL, 0.0, 0.0);670 if (kernelImg != NULL) {671 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");672 testStatus = true;673 }674 free(kernelImg);675 676 //-------------------------------------------------------------------------677 printf("Calling pmSubtractionKernelImage() unallowable x value. Should generate error, return NULL.\n");678 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, -2.0, 0.0);679 if (kernelImg != NULL) {680 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");681 testStatus = true;682 }683 free(kernelImg);684 685 //-------------------------------------------------------------------------686 printf("Calling pmSubtractionKernelImage() unallowable x value. Should generate error, return NULL.\n");687 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 2.0, 0.0);688 if (kernelImg != NULL) {689 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");690 testStatus = true;691 }692 free(kernelImg);693 694 //-------------------------------------------------------------------------695 printf("Calling pmSubtractionKernelImage() unallowable y value. Should generate error, return NULL.\n");696 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.0, -2.0);697 if (kernelImg != NULL) {698 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");699 testStatus = true;700 }701 free(kernelImg);702 703 //-------------------------------------------------------------------------704 printf("Calling pmSubtractionKernelImage() unallowable y value. Should generate error, return NULL.\n");705 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.0, 2.0);706 if (kernelImg != NULL) {707 printf("TEST ERROR: pmSubtractionKernelImage() returned non-NULL.\n");708 testStatus = true;709 }710 free(kernelImg);711 712 //-------------------------------------------------------------------------713 printf("Calling with pmSubtractionKernelImage() acceptable input parameters. Should return a psImage.\n");714 kernelImg = pmSubtractionKernelImage(NULL, solution, myKernels, 0.0, 0.0);715 if (kernelImg == NULL) {716 printf("TEST ERROR: pmSubtractionKernelImage() returned NULL.\n");717 testStatus = true;718 }719 free(kernelImg);720 721 psFree(solution);722 807 } 723 808 } … … 739 824 bool testStatus = false; 740 825 741 testStatus|= testSubCalcEqu(100, 100, 2, 2, 3, PM_SUBTRACTION_KERNEL_POIS); 742 testStatus|= testSubCalcEqu(100, 100, 2, 2, 3, PM_SUBTRACTION_KERNEL_ISIS); 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); 743 839 744 840 return(!testStatus); 745 841 } 746 842 843 //This code will
Note:
See TracChangeset
for help on using the changeset viewer.
