Changeset 1225
- Timestamp:
- Jul 15, 2004, 9:58:24 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageManip.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageManip.c
r1221 r1225 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-07-15 00:08:43$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-15 19:58:24 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 static int testImageOverlay(void); 27 27 static int testImageRebin(void); 28 static int testImageRoll(void); 28 29 29 30 testDescription tests[] = { … … 32 33 {testImageOverlay,573,"psImageOverlay",0,false}, 33 34 {testImageRebin,559,"psImageRebin",0,false}, 35 {testImageRoll,562,"psImageRoll",0,false}, 34 36 {NULL} 35 37 }; … … 637 639 return 0; 638 640 } 641 642 static int testImageRoll(void) 643 { 644 645 psImage* in; 646 psImage* out; 647 psImage* out2; 648 int rows = 64; 649 int cols = 64; 650 651 652 /* 653 The function psImageRoll shall generate a new psImage structure by 654 rolling the input image the correponding number of pixels in the vertical 655 and/or horizontal direction. The image output image shall be the same size 656 as the input image. Values which roll off the image are wrapped to the 657 other side. 658 659 Verify the returned psImage structure contains expected values, if the 660 input image contains known values and the roll performed is known. 661 Cases should include no roll, vertical roll, horizontal roll and 662 combination vertical/horizontal rolls. Positive and negative rolls 663 should be performed. 664 */ 665 666 in = psImageAlloc(cols,rows,PS_TYPE_F32); 667 for (int row=0;row<rows;row++) { 668 psF32* inRow = in->data.F32[row]; 669 for (int col=0;col<cols;col++) { 670 inRow[col] = (psF32)row+(psF32)col/1000.0f; 671 } 672 } 673 674 out = psImageRoll(NULL,in,0,0); 675 for (int row=0;row<rows;row++) { 676 psF32* inRow = in->data.F32[row]; 677 psF32* outRow = out->data.F32[row]; 678 for (int col=0;col<cols;col++) { 679 if (inRow[col] != outRow[col]) { 680 psError(__func__,"psImageRoll didn't produce expected result " 681 "at %d,%d (%f vs %f) for dx=0, dy=0.", 682 col,row,inRow[col],outRow[col]); 683 return 3; 684 } 685 } 686 } 687 688 out2 = psImageRoll(out,in,cols/4,0); 689 for (int row=0;row<rows;row++) { 690 psF32* inRow = in->data.F32[row]; 691 psF32* outRow = out->data.F32[row]; 692 for (int col=0;col<cols;col++) { 693 if (inRow[(col+cols/4) % cols] != outRow[col]) { 694 psError(__func__,"psImageRoll didn't produce expected result " 695 "at %d,%d (%f vs %f) for dx=cols/4, dy=0.", 696 col,row,inRow[(col+cols/4) % cols],outRow[col]); 697 return 4; 698 } 699 } 700 } 701 702 // Verify the returned psImage structure pointer is equal to the input 703 // parameter out if provided. 704 if (out2 != out) { 705 psError(__func__,"psImageRoll didn't recycle my out psImage!?"); 706 return 1; 707 } 708 709 out = psImageRoll(out,in,0,rows/4); 710 for (int row=0;row<rows;row++) { 711 psF32* inRow = in->data.F32[(row+rows/4)%rows]; 712 psF32* outRow = out->data.F32[row]; 713 for (int col=0;col<cols;col++) { 714 if (inRow[col] != outRow[col]) { 715 psError(__func__,"psImageRoll didn't produce expected result " 716 "at %d,%d (%f vs %f) for dx=0, dy=rows/4.", 717 col,row,inRow[col],outRow[col]); 718 return 5; 719 } 720 } 721 } 722 723 out = psImageRoll(out,in,cols/4,rows/4); 724 for (int row=0;row<rows;row++) { 725 psF32* inRow = in->data.F32[(row+rows/4)%rows]; 726 psF32* outRow = out->data.F32[row]; 727 for (int col=0;col<cols;col++) { 728 if (inRow[(col+cols/4) % cols] != outRow[col]) { 729 psError(__func__,"psImageRoll didn't produce expected result " 730 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.", 731 col,row,inRow[(col+cols/4) % cols],outRow[col]); 732 return 6; 733 } 734 } 735 } 736 737 out = psImageRoll(out,in,-cols/4,0); 738 for (int row=0;row<rows;row++) { 739 psF32* inRow = in->data.F32[row]; 740 psF32* outRow = out->data.F32[row]; 741 for (int col=0;col<cols;col++) { 742 if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) { 743 psError(__func__,"psImageRoll didn't produce expected result " 744 "at %d,%d (%f vs %f) for dx=-cols/4, dy=0.", 745 col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]); 746 return 7; 747 } 748 } 749 } 750 751 out = psImageRoll(out,in,0,-rows/4); 752 for (int row=0;row<rows;row++) { 753 psF32* inRow = in->data.F32[(row+rows-rows/4)%rows]; 754 psF32* outRow = out->data.F32[row]; 755 for (int col=0;col<cols;col++) { 756 if (inRow[col] != outRow[col]) { 757 psError(__func__,"psImageRoll didn't produce expected result " 758 "at %d,%d (%f vs %f) for dx=0, dy=-rows/4.", 759 col,row,inRow[col],outRow[col]); 760 return 8; 761 } 762 } 763 } 764 765 out = psImageRoll(out,in,-cols/4,-rows/4); 766 for (int row=0;row<rows;row++) { 767 psF32* inRow = in->data.F32[(row+rows-rows/4)%rows]; 768 psF32* outRow = out->data.F32[row]; 769 for (int col=0;col<cols;col++) { 770 if (inRow[(col+cols-cols/4) % cols] != outRow[col]) { 771 psError(__func__,"psImageRoll didn't produce expected result " 772 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.", 773 col,row,inRow[(col+cols-cols/4) % cols],outRow[col]); 774 return 9; 775 } 776 } 777 } 778 779 780 // Verify the returned psImage structure pointer is null and program 781 // execution doesn't stop, if input parameter input is null. 782 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error."); 783 out2 = psImageRoll(NULL,NULL,0,0); 784 if (out2 != NULL) { 785 psError(__func__,"psImageRoll did not return NULL though input image was NULL!?"); 786 return 2; 787 } 788 789 psFree(in); 790 psFree(out); 791 792 return 0; 793 }
Note:
See TracChangeset
for help on using the changeset viewer.
