Changeset 1926 for trunk/psLib/test/image/tst_psImageManip.c
- Timestamp:
- Sep 29, 2004, 9:50:43 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageManip.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageManip.c
r1922 r1926 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-09-29 00:28:21$8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-09-29 19:50:43 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 860 860 psImage* out = NULL; 861 861 psImage* out2 = NULL; 862 psImage* out3 = NULL; 863 psImage* mask = NULL; 862 864 psImage* meanTruth = NULL; 865 psImage* meanTruthWMask = NULL; 863 866 psImage* maxTruth = NULL; 864 867 psStats stats; … … 875 878 #define testRebinType(DATATYPE) \ 876 879 in = psImageAlloc(16,16,PS_TYPE_##DATATYPE); \ 880 mask = psImageAlloc(16,16,PS_TYPE_U8); \ 877 881 meanTruth = psImageAlloc(4,4,PS_TYPE_F32); \ 882 meanTruthWMask = psImageAlloc(4,4,PS_TYPE_F32); \ 878 883 maxTruth = psImageAlloc(6,6,PS_TYPE_F32); \ 879 884 memset(meanTruth->data.F32[0],0,sizeof(psF32)*4*4); \ 885 memset(meanTruthWMask->data.F32[0],0,sizeof(psF32)*4*4); \ 880 886 memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \ 881 887 for (int row = 0; row<16; row++) { \ 882 888 ps##DATATYPE* inRow = in->data.DATATYPE[row]; \ 883 889 psF32* meanTruthRow = meanTruth->data.F32[row/4]; \ 890 psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row/4]; \ 884 891 psF32* maxTruthRow = maxTruth->data.F32[row/3]; \ 892 psU8* maskRow = mask->data.U8[row]; \ 885 893 for (int col = 0; col<16; col++) { \ 894 if(col != 15) { \ 895 maskRow[col] = 0; \ 896 } else { \ 897 maskRow[col] = 1; \ 898 } \ 886 899 inRow[col] = row + col; \ 887 900 meanTruthRow[col/4] += row + col; \ … … 889 902 maxTruthRow[col/3] = row+col; \ 890 903 } \ 904 if(maskRow[col] == 0 ) { \ 905 meanTruthWMaskRow[col/4] += row + col; \ 906 } \ 891 907 } \ 892 908 } \ 893 909 for (int row = 0; row<4; row++) { \ 894 910 psF32* meanTruthRow = meanTruth->data.F32[row]; \ 911 psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row]; \ 895 912 for (int col = 0; col<4; col++) { \ 896 913 meanTruthRow[col] /= 16; \ 914 if ( col == 3 ) { \ 915 meanTruthWMaskRow[col] /= 12; \ 916 } else { \ 917 meanTruthWMaskRow[col] /= 16; \ 918 } \ 897 919 } \ 898 920 } \ … … 921 943 } \ 922 944 } \ 945 stats.options = PS_STAT_SAMPLE_MEAN; \ 946 out3 = psImageRebin(NULL,in,mask,1,4,&stats); \ 947 for (int row = 0; row<4; row++) { \ 948 ps##DATATYPE* outRow = out3->data.DATATYPE[row]; \ 949 psF32* truthRow = meanTruthWMask->data.F32[row]; \ 950 for ( int col = 0; col<4; col++) { \ 951 if(abs((int)outRow[col]-(int)truthRow[col]) > FLT_EPSILON) { \ 952 psError(__func__,"psImageRebin with mask didn't produce the proper mean " \ 953 "result at (%d,%d) [%f vs %f].", \ 954 col,row,outRow[col],truthRow[col]); \ 955 return 3; \ 956 } \ 957 } \ 958 } \ 923 959 stats.options = PS_STAT_MAX; \ 924 960 out2 = psImageRebin(out,in,NULL,0,3,&stats); \ … … 951 987 psFree(in); \ 952 988 psFree(out); \ 989 psFree(out3); \ 990 psFree(mask); \ 953 991 psFree(meanTruth); \ 992 psFree(meanTruthWMask); \ 954 993 psFree(maxTruth); 955 994 … … 961 1000 // Verify the returned psImage structure is null and program execution 962 1001 // doesn't stop, if the input image type is not supported. 963 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1002 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for unsupported type."); 964 1003 in = psImageAlloc(16,16,PS_TYPE_U8); 1004 mask = psImageAlloc(16,16,PS_TYPE_F32); 965 1005 stats.options = PS_STAT_SAMPLE_MEAN; 966 1006 out = psImageRebin(NULL,in,NULL,0,4,&stats); … … 970 1010 return 14; 971 1011 } 1012 // Verify the returned psImage structure is null and program execution 1013 // doesn't stop, if the mask type is not U8 1014 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invallid mask type."); 1015 out = psImageRebin(NULL,in,mask,1,4,&stats); 1016 if(out != NULL) { 1017 psError(__func__,"psImageRebin return an image eventhough the " 1018 "mask is not the correct type."); 1019 return 17; 1020 } 1021 psFree(mask); 972 1022 psFree(in); 973 1023 … … 986 1036 // doesn't stop, if the input parameter scale is less than or equal to zero. 987 1037 in = psImageAlloc(16, 16, PS_TYPE_F32); 988 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1038 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for scale < 0."); 989 1039 out2 = psImageRebin(NULL,in,NULL,0,0,&stats); 990 1040 … … 997 1047 // Verify the returned psImage structure is null and program execution 998 1048 // doesn't stop, if the input parameter stats is null. 999 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1049 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats null."); 1000 1050 out2 = psImageRebin(NULL,in,NULL,0,1,NULL); 1001 1051 … … 1010 1060 // is zero or any value which doesn't correspond to a valid statistical 1011 1061 // method. 1012 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1062 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats options 0."); 1013 1063 stats.options = 0; 1014 1064 out2 = psImageRebin(NULL,in,NULL,0,1,&stats); … … 1020 1070 } 1021 1071 1022 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1072 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stat options use range."); 1023 1073 stats.options = PS_STAT_USE_RANGE; 1024 1074 out2 = psImageRebin(NULL,in,NULL,0,1,&stats); … … 1033 1083 // doesn't stop, if the input parameter psStats structure member options 1034 1084 // specifies more than one valid statistical method. 1035 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error .");1085 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats with multiple options."); 1036 1086 stats.options = PS_STAT_SAMPLE_MEAN + PS_STAT_MAX; 1037 1087 out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
Note:
See TracChangeset
for help on using the changeset viewer.
