Changeset 938 for trunk/psLib/test/image/tst_psImage.c
- Timestamp:
- Jun 8, 2004, 1:57:00 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImage.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r856 r938 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 4 03:12:11$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-08 23:57:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 static int testImageSubset(void); 25 25 static int testImageCopy(void); 26 static int testImageClip(void); 26 27 27 28 testDescription tests[] = { … … 29 30 {testImageSubset,"547/550-testImageSubset",0}, 30 31 {testImageCopy,"551-testImageCopy",0}, 32 {testImageClip,"571-testImageClip",0}, 31 33 {NULL} 32 34 }; … … 618 620 return 0; 619 621 } 622 623 int testImageClip(void) 624 { 625 psImage* img = NULL; 626 unsigned int c = 128; 627 unsigned int r = 256; 628 psF32 min; 629 psF32 max; 630 int currentId = psMemGetId(); 631 int numClipped = 0; 632 int retVal; 633 634 psLogMsg(__func__,PS_LOG_INFO, 635 "psImageClip shall limit the minimum and maximum data value within a psImage structure"); 636 637 /* 638 639 psImageClip shall limit the minimum and maximum data value within a 640 psImage structure to a specified min and max value. 641 642 Verify the returned integer is equal to the number of pixels clipped, 643 if the input psImage structure contains known values and input parameters 644 min and max have know values. 645 646 Verify the psImage structure specified by the input parameter input is 647 modified to contain the expected values, if the input psImage structure 648 contains known values, min and max are specified and vmin and vmax 649 parameters are known. 650 651 Verify the retuned integer is zero, psImage structure input is unmodified 652 and program executions doesn't stop, if input parameter psImage structure 653 pointer is null. 654 655 Verify the retuned integer is zero, psImage structure input is unmodified 656 and program executions doesn't stop, if input parameter min is larger than max. 657 */ 658 659 // create image 660 #define testImageClipByType(datatype) \ 661 img = psImageAlloc(c,r,PS_TYPE_##datatype); \ 662 for (unsigned row=0;row<r;row++) { \ 663 ps##datatype* imgRow = img->data.datatype[row]; \ 664 for (unsigned col=0;col<c;col++) { \ 665 imgRow[col] = (ps##datatype)(row+col); \ 666 } \ 667 } \ 668 min = (float)r/2.0f; \ 669 max = (float)r; \ 670 \ 671 retVal = psImageClip(img,min,-1.0f,max,-2.0f); \ 672 \ 673 numClipped = 0; \ 674 for (unsigned row=0;row<r;row++) { \ 675 ps##datatype* imgRow = img->data.datatype[row]; \ 676 for (unsigned col=0;col<c;col++) { \ 677 ps##datatype value = (ps##datatype)(row+col); \ 678 if (value < (ps##datatype)min) { \ 679 numClipped++; \ 680 value = -1; \ 681 } else if (value > (ps##datatype)max) { \ 682 numClipped++; \ 683 value = -2; \ 684 } \ 685 if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \ 686 psError(__func__,"Pixel value is not as expected (%d vs %d) at %d,%d", \ 687 imgRow[col],value,col,row); \ 688 return 1; \ 689 } \ 690 } \ 691 } \ 692 if (retVal != numClipped) { \ 693 psError(__func__,"Expected %d clips, but got %d", \ 694 numClipped,retVal); \ 695 return 2; \ 696 } \ 697 psImageFree(img); 698 699 testImageClipByType(F64); 700 testImageClipByType(F32); 701 testImageClipByType(S64); 702 testImageClipByType(S32); 703 testImageClipByType(S16); 704 testImageClipByType(S8); 705 testImageClipByType(U64); 706 testImageClipByType(U32); 707 testImageClipByType(U16); 708 testImageClipByType(U8); 709 710 // Verify the retuned integer is zero, psImage structure input is unmodified 711 // and program executions doesn't stop, if input parameter psImage structure 712 // pointer is null. 713 retVal = psImageClip(NULL,min,-1.0f,max,-2.0f); 714 if (retVal != 0) { 715 psError(__func__,"Expected zero return for clips of a NULL image."); 716 return 3; 717 } 718 719 // Verify the retuned integer is zero, psImage structure input is unmodified 720 // and program executions doesn't stop, if input parameter min is larger than max. 721 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error (max<min)"); 722 retVal = psImageClip(img,max,-1.0f,min,-2.0f); 723 if (retVal != 0) { 724 psError(__func__,"Expected zero return for clips when max < min."); 725 return 4; 726 } 727 728 if (psMemCheckLeaks(currentId,NULL,NULL) != 0) { 729 psAbort(__func__,"Memory Leaks!"); 730 } 731 psMemCheckCorruption(1); 732 733 return 0; 734 }
Note:
See TracChangeset
for help on using the changeset viewer.
