Changeset 5625 for trunk/psLib/test/imageops/tst_psImagePixelExtract.c
- Timestamp:
- Nov 29, 2005, 4:00:37 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/tst_psImagePixelExtract.c
r5174 r5625 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 09-29 01:15:38$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-11-30 02:00:37 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 21 21 static psS32 testImageCut(void); 22 22 static psS32 testImageRadialCut(void); 23 static psS32 testImageRowCol(void); 23 static psS32 testImageRowColF32(void); 24 static psS32 testImageRowColF64(void); 25 static psS32 testImageRowColS8(void); 26 static psS32 testImageRowColS16(void); 27 static psS32 testImageRowColS32(void); 28 static psS32 testImageRowColS64(void); 29 static psS32 testImageRowColU8(void); 30 static psS32 testImageRowColU16(void); 31 static psS32 testImageRowColU32(void); 32 static psS32 testImageRowColU64(void); 33 24 34 25 35 … … 28 38 {testImageCut, 555, "psImageCut", 0, false}, 29 39 {testImageRadialCut, 557, "psImageRadialCut", 0, false}, 30 {testImageRowCol, 559, "psImageRowCol", 0, false}, 40 {testImageRowColF32, 558, "psImageRowColF32", 0, false}, 41 {testImageRowColF64, 559, "psImageRowColF64", 0, false}, 42 {testImageRowColU8, 560, "psImageRowColU8", 0, false}, 43 {testImageRowColU16, 561, "psImageRowColU16", 0, false}, 44 {testImageRowColU32, 562, "psImageRowColU32", 0, false}, 45 {testImageRowColU64, 563, "psImageRowColU64", 0, false}, 46 {testImageRowColS8, 564, "psImageRowColS8", 0, false}, 47 {testImageRowColS16, 565, "psImageRowColS16", 0, false}, 48 {testImageRowColS32, 566, "psImageRowColS32", 0, false}, 49 {testImageRowColS64, 567, "psImageRowColS64", 0, false}, 31 50 {NULL} 32 51 }; … … 745 764 } 746 765 747 psS32 testImageRowCol (void)766 psS32 testImageRowColF64(void) 748 767 { 749 768 psVector *rowcol = NULL; … … 794 813 } 795 814 815 psS32 testImageRowColF32(void) 816 { 817 psVector *rowcol = NULL; 818 psVector *empty = NULL; 819 psImage *image = NULL; 820 psImage *emptyImage = NULL; 821 822 float test1; 823 float test2; 824 float TOLTST = .01; 825 826 image = psImageAlloc(3, 3, PS_TYPE_F32); 827 rowcol = psVectorAlloc(3, PS_TYPE_F32); 828 829 image->data.F32[0][0] = 666.666; 830 image->data.F32[1][0] = 66.6; 831 image->data.F32[2][0] = 6.66; 832 image->data.F32[0][1] = 6.6; 833 image->data.F32[1][1] = 6.666; 834 image->data.F32[2][1] = 66.666; 835 image->data.F32[0][2] = 666.6; 836 image->data.F32[1][2] = 666.66; 837 image->data.F32[2][2] = 66.66; 838 839 //Test for error with NULL image 840 empty = psImageCol(empty, emptyImage, 0); 841 if (empty != NULL) { 842 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 843 "psImageCol failed to return NULL for NULL image input.\n"); 844 return 1; 845 } 846 //Test for error with Out of Range Row 847 empty = psImageRow(empty, image, 5); 848 if (empty != NULL) { 849 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 850 "psImageRow failed to return NULL for out of range row input.\n"); 851 return 2; 852 } 853 rowcol->data.F32[0] = 1.1; 854 rowcol->data.F32[2] = 2.2; 855 //Test recycling of non-NULL vector & correct output 856 rowcol = psImageCol(rowcol, image, 1); 857 test1 = abs(rowcol->data.F32[0]-66.6); 858 test2 = abs(rowcol->data.F32[2]-666.66); 859 if ( (test1>TOLTST) || (test2>TOLTST) ) { 860 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 861 "psImageCol failed to return correct values.\n"); 862 return 3; 863 } 864 865 psFree(rowcol); 866 psFree(image); 867 return 0; 868 } 869 870 psS32 testImageRowColU64(void) 871 { 872 psVector *rowcol = NULL; 873 psVector *empty = NULL; 874 psImage *image = NULL; 875 psImage *emptyImage = NULL; 876 877 image = psImageAlloc(3, 3, PS_TYPE_U64); 878 rowcol = psVectorAlloc(3, PS_TYPE_U64); 879 880 image->data.U64[0][0] = 666666; 881 image->data.U64[1][0] = 666; 882 image->data.U64[2][0] = 666; 883 image->data.U64[0][1] = 66; 884 image->data.U64[1][1] = 6666; 885 image->data.U64[2][1] = 66666; 886 image->data.U64[0][2] = 6666; 887 image->data.U64[1][2] = 66666; 888 image->data.U64[2][2] = 6666; 889 890 //Test for error with NULL image 891 empty = psImageCol(empty, emptyImage, 0); 892 if (empty != NULL) { 893 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 894 "psImageCol failed to return NULL for NULL image input.\n"); 895 return 1; 896 } 897 //Test for error with Out of Range Row 898 empty = psImageRow(empty, image, 5); 899 if (empty != NULL) { 900 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 901 "psImageRow failed to return NULL for out of range row input.\n"); 902 return 2; 903 } 904 rowcol->data.U64[0] = 11; 905 rowcol->data.U64[2] = 22; 906 //Test recycling of non-NULL vector & correct output 907 rowcol = psImageCol(rowcol, image, 1); 908 if (rowcol->data.U64[0] != 666 && rowcol->data.U64[2] != 66666) { 909 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 910 "psImageCol failed to return correct values.\n"); 911 return 3; 912 } 913 914 psFree(rowcol); 915 psFree(image); 916 return 0; 917 } 918 919 psS32 testImageRowColU32(void) 920 { 921 psVector *rowcol = NULL; 922 psVector *empty = NULL; 923 psImage *image = NULL; 924 psImage *emptyImage = NULL; 925 926 image = psImageAlloc(3, 3, PS_TYPE_U32); 927 rowcol = psVectorAlloc(3, PS_TYPE_U32); 928 929 image->data.U32[0][0] = 666666; 930 image->data.U32[1][0] = 666; 931 image->data.U32[2][0] = 666; 932 image->data.U32[0][1] = 66; 933 image->data.U32[1][1] = 6666; 934 image->data.U32[2][1] = 66666; 935 image->data.U32[0][2] = 6666; 936 image->data.U32[1][2] = 66666; 937 image->data.U32[2][2] = 6666; 938 939 //Test for error with NULL image 940 empty = psImageCol(empty, emptyImage, 0); 941 if (empty != NULL) { 942 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 943 "psImageCol failed to return NULL for NULL image input.\n"); 944 return 1; 945 } 946 //Test for error with Out of Range Row 947 empty = psImageRow(empty, image, 5); 948 if (empty != NULL) { 949 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 950 "psImageRow failed to return NULL for out of range row input.\n"); 951 return 2; 952 } 953 rowcol->data.U32[0] = 11; 954 rowcol->data.U32[2] = 22; 955 //Test recycling of non-NULL vector & correct output 956 rowcol = psImageCol(rowcol, image, 1); 957 if (rowcol->data.U32[0] != 666 && rowcol->data.U32[2] != 66666) { 958 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 959 "psImageCol failed to return correct values.\n"); 960 return 3; 961 } 962 963 psFree(rowcol); 964 psFree(image); 965 return 0; 966 } 967 968 psS32 testImageRowColS32(void) 969 { 970 psVector *rowcol = NULL; 971 psVector *empty = NULL; 972 psImage *image = NULL; 973 psImage *emptyImage = NULL; 974 975 image = psImageAlloc(3, 3, PS_TYPE_S32); 976 rowcol = psVectorAlloc(3, PS_TYPE_S32); 977 978 image->data.S32[0][0] = 666666; 979 image->data.S32[1][0] = 666; 980 image->data.S32[2][0] = 666; 981 image->data.S32[0][1] = 66; 982 image->data.S32[1][1] = 6666; 983 image->data.S32[2][1] = 66666; 984 image->data.S32[0][2] = 6666; 985 image->data.S32[1][2] = 66666; 986 image->data.S32[2][2] = 6666; 987 988 //Test for error with NULL image 989 empty = psImageCol(empty, emptyImage, 0); 990 if (empty != NULL) { 991 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 992 "psImageCol failed to return NULL for NULL image input.\n"); 993 return 1; 994 } 995 //Test for error with Out of Range Row 996 empty = psImageRow(empty, image, 5); 997 if (empty != NULL) { 998 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 999 "psImageRow failed to return NULL for out of range row input.\n"); 1000 return 2; 1001 } 1002 rowcol->data.S32[0] = 11; 1003 rowcol->data.S32[2] = 22; 1004 //Test recycling of non-NULL vector & correct output 1005 rowcol = psImageCol(rowcol, image, 1); 1006 if (rowcol->data.S32[0] != 666 && rowcol->data.S32[2] != 66666) { 1007 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1008 "psImageCol failed to return correct values.\n"); 1009 return 3; 1010 } 1011 1012 psFree(rowcol); 1013 psFree(image); 1014 return 0; 1015 } 1016 1017 psS32 testImageRowColS64(void) 1018 { 1019 psVector *rowcol = NULL; 1020 psVector *empty = NULL; 1021 psImage *image = NULL; 1022 psImage *emptyImage = NULL; 1023 1024 image = psImageAlloc(3, 3, PS_TYPE_S64); 1025 rowcol = psVectorAlloc(3, PS_TYPE_S64); 1026 1027 image->data.S64[0][0] = 666666; 1028 image->data.S64[1][0] = 666; 1029 image->data.S64[2][0] = 666; 1030 image->data.S64[0][1] = 66; 1031 image->data.S64[1][1] = 6666; 1032 image->data.S64[2][1] = 66666; 1033 image->data.S64[0][2] = 6666; 1034 image->data.S64[1][2] = 66666; 1035 image->data.S64[2][2] = 6666; 1036 1037 //Test for error with NULL image 1038 empty = psImageCol(empty, emptyImage, 0); 1039 if (empty != NULL) { 1040 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1041 "psImageCol failed to return NULL for NULL image input.\n"); 1042 return 1; 1043 } 1044 //Test for error with Out of Range Row 1045 empty = psImageRow(empty, image, 5); 1046 if (empty != NULL) { 1047 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1048 "psImageRow failed to return NULL for out of range row input.\n"); 1049 return 2; 1050 } 1051 rowcol->data.S64[0] = 11; 1052 rowcol->data.S64[2] = 22; 1053 //Test recycling of non-NULL vector & correct output 1054 rowcol = psImageCol(rowcol, image, 1); 1055 if (rowcol->data.S64[0] != 666 && rowcol->data.S64[2] != 66666) { 1056 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1057 "psImageCol failed to return correct values.\n"); 1058 return 3; 1059 } 1060 1061 psFree(rowcol); 1062 psFree(image); 1063 return 0; 1064 } 1065 1066 psS32 testImageRowColS16(void) 1067 { 1068 psVector *rowcol = NULL; 1069 psVector *empty = NULL; 1070 psImage *image = NULL; 1071 psImage *emptyImage = NULL; 1072 1073 image = psImageAlloc(3, 3, PS_TYPE_S16); 1074 rowcol = psVectorAlloc(3, PS_TYPE_S16); 1075 1076 image->data.S16[0][0] = 3333; 1077 image->data.S16[1][0] = 666; 1078 image->data.S16[2][0] = 666; 1079 image->data.S16[0][1] = 66; 1080 image->data.S16[1][1] = 6666; 1081 image->data.S16[2][1] = 4444; 1082 image->data.S16[0][2] = 6666; 1083 image->data.S16[1][2] = 4444; 1084 image->data.S16[2][2] = 6666; 1085 1086 //Test for error with NULL image 1087 empty = psImageCol(empty, emptyImage, 0); 1088 if (empty != NULL) { 1089 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1090 "psImageCol failed to return NULL for NULL image input.\n"); 1091 return 1; 1092 } 1093 //Test for error with Out of Range Row 1094 empty = psImageRow(empty, image, 5); 1095 if (empty != NULL) { 1096 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1097 "psImageRow failed to return NULL for out of range row input.\n"); 1098 return 2; 1099 } 1100 rowcol->data.S16[0] = 11; 1101 rowcol->data.S16[2] = 22; 1102 //Test recycling of non-NULL vector & correct output 1103 rowcol = psImageCol(rowcol, image, 1); 1104 if (rowcol->data.S16[0] != 666 && rowcol->data.S16[2] != 4444) { 1105 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1106 "psImageCol failed to return correct values.\n"); 1107 return 3; 1108 } 1109 1110 psFree(rowcol); 1111 psFree(image); 1112 return 0; 1113 } 1114 1115 psS32 testImageRowColU16(void) 1116 { 1117 psVector *rowcol = NULL; 1118 psVector *empty = NULL; 1119 psImage *image = NULL; 1120 psImage *emptyImage = NULL; 1121 1122 image = psImageAlloc(3, 3, PS_TYPE_U16); 1123 rowcol = psVectorAlloc(3, PS_TYPE_U16); 1124 1125 image->data.S16[0][0] = 3333; 1126 image->data.S16[1][0] = 666; 1127 image->data.S16[2][0] = 666; 1128 image->data.S16[0][1] = 66; 1129 image->data.S16[1][1] = 6666; 1130 image->data.S16[2][1] = 4444; 1131 image->data.S16[0][2] = 6666; 1132 image->data.S16[1][2] = 4444; 1133 image->data.S16[2][2] = 6666; 1134 1135 //Test for error with NULL image 1136 empty = psImageCol(empty, emptyImage, 0); 1137 if (empty != NULL) { 1138 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1139 "psImageCol failed to return NULL for NULL image input.\n"); 1140 return 1; 1141 } 1142 //Test for error with Out of Range Row 1143 empty = psImageRow(empty, image, 5); 1144 if (empty != NULL) { 1145 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1146 "psImageRow failed to return NULL for out of range row input.\n"); 1147 return 2; 1148 } 1149 rowcol->data.U16[0] = 11; 1150 rowcol->data.U16[2] = 22; 1151 //Test recycling of non-NULL vector & correct output 1152 rowcol = psImageCol(rowcol, image, 1); 1153 if (rowcol->data.U16[0] != 666 && rowcol->data.U16[2] != 4444) { 1154 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1155 "psImageCol failed to return correct values.\n"); 1156 return 3; 1157 } 1158 1159 psFree(rowcol); 1160 psFree(image); 1161 return 0; 1162 } 1163 1164 psS32 testImageRowColU8(void) 1165 { 1166 psVector *rowcol = NULL; 1167 psVector *empty = NULL; 1168 psImage *image = NULL; 1169 psImage *emptyImage = NULL; 1170 1171 image = psImageAlloc(3, 3, PS_TYPE_U8); 1172 rowcol = psVectorAlloc(3, PS_TYPE_U8); 1173 1174 image->data.U8[0][0] = 244; 1175 image->data.U8[1][0] = 123; 1176 image->data.U8[2][0] = 123; 1177 image->data.U8[0][1] = 66; 1178 image->data.U8[1][1] = 199; 1179 image->data.U8[2][1] = 249; 1180 image->data.U8[0][2] = 199; 1181 image->data.U8[1][2] = 249; 1182 image->data.U8[2][2] = 199; 1183 1184 //Test for error with NULL image 1185 empty = psImageCol(empty, emptyImage, 0); 1186 if (empty != NULL) { 1187 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1188 "psImageCol failed to return NULL for NULL image input.\n"); 1189 return 1; 1190 } 1191 //Test for error with Out of Range Row 1192 empty = psImageRow(empty, image, 5); 1193 if (empty != NULL) { 1194 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1195 "psImageRow failed to return NULL for out of range row input.\n"); 1196 return 2; 1197 } 1198 rowcol->data.U8[0] = 11; 1199 rowcol->data.U8[2] = 22; 1200 //Test recycling of non-NULL vector & correct output 1201 rowcol = psImageCol(rowcol, image, 1); 1202 if (rowcol->data.U8[0] != 123 && rowcol->data.U8[2] != 249) { 1203 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1204 "psImageCol failed to return correct values.\n"); 1205 return 3; 1206 } 1207 1208 psFree(rowcol); 1209 psFree(image); 1210 return 0; 1211 } 1212 psS32 testImageRowColS8(void) 1213 { 1214 psVector *rowcol = NULL; 1215 psVector *empty = NULL; 1216 psImage *image = NULL; 1217 psImage *emptyImage = NULL; 1218 1219 image = psImageAlloc(3, 3, PS_TYPE_S8); 1220 rowcol = psVectorAlloc(3, PS_TYPE_S8); 1221 1222 image->data.S8[0][0] = 44; 1223 image->data.S8[1][0] = 23; 1224 image->data.S8[2][0] = 23; 1225 image->data.S8[0][1] = 66; 1226 image->data.S8[1][1] = 99; 1227 image->data.S8[2][1] = 49; 1228 image->data.S8[0][2] = 99; 1229 image->data.S8[1][2] = 49; 1230 image->data.S8[2][2] = 99; 1231 1232 //Test for error with NULL image 1233 empty = psImageCol(empty, emptyImage, 0); 1234 if (empty != NULL) { 1235 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1236 "psImageCol failed to return NULL for NULL image input.\n"); 1237 return 1; 1238 } 1239 //Test for error with Out of Range Row 1240 empty = psImageRow(empty, image, 5); 1241 if (empty != NULL) { 1242 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1243 "psImageRow failed to return NULL for out of range row input.\n"); 1244 return 2; 1245 } 1246 rowcol->data.S8[0] = 11; 1247 rowcol->data.S8[2] = 22; 1248 //Test recycling of non-NULL vector & correct output 1249 rowcol = psImageCol(rowcol, image, 1); 1250 if (rowcol->data.S8[0] != 23 && rowcol->data.S8[2] != 49) { 1251 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1252 "psImageCol failed to return correct values.\n"); 1253 return 3; 1254 } 1255 1256 psFree(rowcol); 1257 psFree(image); 1258 return 0; 1259 }
Note:
See TracChangeset
for help on using the changeset viewer.
