ITK  6.0.0
Insight Toolkit
itkPixelTraits.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkPixelTraits_h
29#define itkPixelTraits_h
30
31#include "itkMacro.h"
32
33namespace itk
34{
44template <typename TPixelType>
46{
47public:
49 static constexpr unsigned int Dimension = TPixelType::Length;
50
52 using ValueType = typename TPixelType::ValueType;
53};
54
56
61template <>
62class PixelTraits<bool>
63{
64public:
65 static constexpr unsigned int Dimension = 1;
66 using ValueType = bool;
67};
68
69template <>
70class PixelTraits<char>
71{
72public:
73 static constexpr unsigned int Dimension = 1;
74 using ValueType = char;
75};
76
77template <>
78class PixelTraits<signed char>
79{
80public:
81 static constexpr unsigned int Dimension = 1;
82 using ValueType = char;
83};
84
85template <>
86class PixelTraits<unsigned char>
87{
88public:
89 static constexpr unsigned int Dimension = 1;
90 using ValueType = unsigned char;
91};
92
93template <>
94class PixelTraits<short>
95{
96public:
97 static constexpr unsigned int Dimension = 1;
98 using ValueType = short;
99};
100
101template <>
102class PixelTraits<unsigned short>
103{
104public:
105 static constexpr unsigned int Dimension = 1;
106 using ValueType = unsigned short;
107};
108
109template <>
110class PixelTraits<int>
111{
112public:
113 static constexpr unsigned int Dimension = 1;
114 using ValueType = int;
115};
116
117template <>
118class PixelTraits<unsigned int>
119{
120public:
121 static constexpr unsigned int Dimension = 1;
122 using ValueType = unsigned int;
123};
124
125template <>
126class PixelTraits<long>
127{
128public:
129 static constexpr unsigned int Dimension = 1;
130 using ValueType = long;
131};
132
133template <>
134class PixelTraits<unsigned long>
135{
136public:
137 static constexpr unsigned int Dimension = 1;
138 using ValueType = unsigned long;
139};
140
141
142template <>
143class PixelTraits<long long>
144{
145public:
146 static constexpr unsigned int Dimension = 1;
147 using ValueType = long long;
148};
149
150template <>
151class PixelTraits<unsigned long long>
152{
153public:
154 static constexpr unsigned int Dimension = 1;
155 using ValueType = unsigned long long;
156};
157
158template <>
159class PixelTraits<float>
160{
161public:
162 static constexpr unsigned int Dimension = 1;
163 using ValueType = float;
164};
165
166template <>
167class PixelTraits<double>
168{
169public:
170 static constexpr unsigned int Dimension = 1;
171 using ValueType = double;
172};
173
175
194template <typename TValue1, typename TValue2>
196{
197public:
198 using ValueType = TValue1;
199};
200
202
207template <>
208class JoinTraits<bool, bool>
209{
210public:
211 using ValueType = bool;
212};
213
214template <>
215class JoinTraits<bool, char>
216{
217public:
218 using ValueType = char;
219};
220
221template <>
222class JoinTraits<bool, unsigned char>
223{
224public:
225 using ValueType = unsigned char;
226};
227
228template <>
229class JoinTraits<bool, short>
230{
231public:
232 using ValueType = short;
233};
234
235template <>
236class JoinTraits<bool, unsigned short>
237{
238public:
239 using ValueType = unsigned short;
240};
241
242template <>
243class JoinTraits<bool, int>
244{
245public:
246 using ValueType = int;
247};
248
249template <>
250class JoinTraits<bool, unsigned int>
251{
252public:
253 using ValueType = unsigned int;
254};
255
256template <>
257class JoinTraits<bool, long>
258{
259public:
260 using ValueType = long;
261};
262
263template <>
264class JoinTraits<bool, unsigned long>
265{
266public:
267 using ValueType = unsigned long;
268};
269
270
271template <>
272class JoinTraits<bool, long long>
273{
274public:
275 using ValueType = long long;
276};
277
278template <>
279class JoinTraits<bool, unsigned long long>
280{
281public:
282 using ValueType = unsigned long long;
283};
284
285template <>
286class JoinTraits<bool, float>
287{
288public:
289 using ValueType = float;
290};
291
292template <>
293class JoinTraits<bool, double>
294{
295public:
296 using ValueType = double;
297};
298
303template <>
304class JoinTraits<char, bool>
305{
306public:
307 using ValueType = char;
308};
309
310template <>
311class JoinTraits<char, char>
312{
313public:
314 using ValueType = char;
315};
316
317template <>
318class JoinTraits<char, unsigned char>
319{
320public:
321 using ValueType = short;
322};
323
324template <>
325class JoinTraits<char, short>
326{
327public:
328 using ValueType = short;
329};
330
331template <>
332class JoinTraits<char, unsigned short>
333{
334public:
335 using ValueType = int;
336};
337
338template <>
339class JoinTraits<char, int>
340{
341public:
342 using ValueType = int;
343};
344
345template <>
346class JoinTraits<char, unsigned int>
347{
348public:
349 // unsigned int & unsigned long may be the same size, so promote to float
350 using ValueType = float;
351};
352
353template <>
354class JoinTraits<char, long>
355{
356public:
357 using ValueType = long;
358};
359
360template <>
361class JoinTraits<char, unsigned long>
362{
363public:
364 using ValueType = float;
365};
366
367template <>
368class JoinTraits<char, long long>
369{
370public:
371 using ValueType = long long;
372};
373
374template <>
375class JoinTraits<char, unsigned long long>
376{
377public:
378 using ValueType = double;
379};
380
381template <>
382class JoinTraits<char, float>
383{
384public:
385 using ValueType = float;
386};
387
388template <>
389class JoinTraits<char, double>
390{
391public:
392 using ValueType = double;
393};
394
399template <>
400class JoinTraits<unsigned char, bool>
401{
402public:
403 using ValueType = unsigned char;
404};
405
406template <>
407class JoinTraits<unsigned char, char>
408{
409public:
410 using ValueType = short;
411};
412
413template <>
414class JoinTraits<unsigned char, unsigned char>
415{
416public:
417 using ValueType = unsigned char;
418};
419
420template <>
421class JoinTraits<unsigned char, short>
422{
423public:
424 using ValueType = short;
425};
426
427template <>
428class JoinTraits<unsigned char, unsigned short>
429{
430public:
431 using ValueType = unsigned short;
432};
433
434template <>
435class JoinTraits<unsigned char, int>
436{
437public:
438 using ValueType = int;
439};
440
441template <>
442class JoinTraits<unsigned char, unsigned int>
443{
444public:
445 using ValueType = unsigned int;
446};
447
448template <>
449class JoinTraits<unsigned char, long>
450{
451public:
452 using ValueType = long;
453};
454
455template <>
456class JoinTraits<unsigned char, unsigned long>
457{
458public:
459 using ValueType = unsigned long;
460};
461
462template <>
463class JoinTraits<unsigned char, long long>
464{
465public:
466 using ValueType = long long;
467};
468
469template <>
470class JoinTraits<unsigned char, unsigned long long>
471{
472public:
473 using ValueType = unsigned long long;
474};
475
476template <>
477class JoinTraits<unsigned char, float>
478{
479public:
480 using ValueType = float;
481};
482
483template <>
484class JoinTraits<unsigned char, double>
485{
486public:
487 using ValueType = double;
488};
489
494template <>
495class JoinTraits<short, bool>
496{
497public:
498 using ValueType = short;
499};
500
501template <>
502class JoinTraits<short, char>
503{
504public:
505 using ValueType = short;
506};
507
508template <>
509class JoinTraits<short, unsigned char>
510{
511public:
512 using ValueType = short;
513};
514
515template <>
516class JoinTraits<short, short>
517{
518public:
519 using ValueType = short;
520};
521
522template <>
523class JoinTraits<short, unsigned short>
524{
525public:
526 using ValueType = int;
527};
528
529template <>
530class JoinTraits<short, int>
531{
532public:
533 using ValueType = int;
534};
535
536template <>
537class JoinTraits<short, unsigned int>
538{
539public:
540 // unsigned int & unsigned long may be the same size, so promote to float
541 using ValueType = float;
542};
543
544template <>
545class JoinTraits<short, long>
546{
547public:
548 using ValueType = long;
549};
550
551template <>
552class JoinTraits<short, unsigned long>
553{
554public:
555 using ValueType = float;
556};
557
558template <>
559class JoinTraits<short, long long>
560{
561public:
562 using ValueType = long long;
563};
564
565template <>
566class JoinTraits<short, unsigned long long>
567{
568public:
569 using ValueType = double;
570};
571
572template <>
573class JoinTraits<short, float>
574{
575public:
576 using ValueType = float;
577};
578
579template <>
580class JoinTraits<short, double>
581{
582public:
583 using ValueType = double;
584};
585
590template <>
591class JoinTraits<unsigned short, bool>
592{
593public:
594 using ValueType = unsigned short;
595};
596
597template <>
598class JoinTraits<unsigned short, char>
599{
600public:
601 using ValueType = int;
602};
603
604template <>
605class JoinTraits<unsigned short, unsigned char>
606{
607public:
608 using ValueType = unsigned short;
609};
610
611template <>
612class JoinTraits<unsigned short, short>
613{
614public:
615 using ValueType = int;
616};
617
618template <>
619class JoinTraits<unsigned short, unsigned short>
620{
621public:
622 using ValueType = unsigned short;
623};
624
625template <>
626class JoinTraits<unsigned short, int>
627{
628public:
629 using ValueType = int;
630};
631
632template <>
633class JoinTraits<unsigned short, unsigned int>
634{
635public:
636 using ValueType = unsigned int;
637};
638
639template <>
640class JoinTraits<unsigned short, long>
641{
642public:
643 using ValueType = long;
644};
645
646template <>
647class JoinTraits<unsigned short, unsigned long>
648{
649public:
650 using ValueType = unsigned long;
651};
652
653template <>
654class JoinTraits<unsigned short, long long>
655{
656public:
657 using ValueType = long long;
658};
659
660template <>
661class JoinTraits<unsigned short, unsigned long long>
662{
663public:
664 using ValueType = unsigned long long;
665};
666
667template <>
668class JoinTraits<unsigned short, float>
669{
670public:
671 using ValueType = float;
672};
673
674template <>
675class JoinTraits<unsigned short, double>
676{
677public:
678 using ValueType = double;
679};
680
685template <>
686class JoinTraits<int, bool>
687{
688public:
689 using ValueType = int;
690};
691
692template <>
693class JoinTraits<int, char>
694{
695public:
696 using ValueType = int;
697};
698
699template <>
700class JoinTraits<int, unsigned char>
701{
702public:
703 using ValueType = int;
704};
705
706template <>
707class JoinTraits<int, short>
708{
709public:
710 using ValueType = int;
711};
712
713template <>
714class JoinTraits<int, unsigned short>
715{
716public:
717 using ValueType = int;
718};
719
720template <>
721class JoinTraits<int, int>
722{
723public:
724 using ValueType = int;
725};
726
727template <>
728class JoinTraits<int, unsigned int>
729{
730public:
731 // unsigned int & unsigned long may be the same size, so promote to float
732 using ValueType = float;
733};
734
735template <>
736class JoinTraits<int, long>
737{
738public:
739 using ValueType = long;
740};
741
742template <>
743class JoinTraits<int, unsigned long>
744{
745public:
746 using ValueType = float;
747};
748
749template <>
750class JoinTraits<int, long long>
751{
752public:
753 using ValueType = long long;
754};
755
756template <>
757class JoinTraits<int, unsigned long long>
758{
759public:
760 using ValueType = double;
761};
762
763template <>
764class JoinTraits<int, float>
765{
766public:
767 using ValueType = float;
768};
769
770template <>
771class JoinTraits<int, double>
772{
773public:
774 using ValueType = double;
775};
776
781template <>
782class JoinTraits<unsigned int, bool>
783{
784public:
785 using ValueType = unsigned int;
786};
787
788template <>
789class JoinTraits<unsigned int, char>
790{
791public:
792 // unsigned int & unsigned long may be the same size, so promote to float
793 using ValueType = float;
794};
795
796template <>
797class JoinTraits<unsigned int, unsigned char>
798{
799public:
800 using ValueType = unsigned int;
801};
802
803template <>
804class JoinTraits<unsigned int, short>
805{
806public:
807 // unsigned int & unsigned long may be the same size, so promote to float
808 using ValueType = float;
809};
810
811template <>
812class JoinTraits<unsigned int, unsigned short>
813{
814public:
815 using ValueType = unsigned int;
816};
817
818template <>
819class JoinTraits<unsigned int, int>
820{
821public:
822 // unsigned int & unsigned long may be the same size, so promote to float
823 using ValueType = float;
824};
825
826template <>
827class JoinTraits<unsigned int, unsigned int>
828{
829public:
830 using ValueType = unsigned int;
831};
832
833template <>
834class JoinTraits<unsigned int, long>
835{
836public:
837 using ValueType = float;
838};
839
840template <>
841class JoinTraits<unsigned int, unsigned long>
842{
843public:
844 using ValueType = unsigned long;
845};
846
847template <>
848class JoinTraits<unsigned int, long long>
849{
850public:
851 using ValueType = long long;
852};
853
854template <>
855class JoinTraits<unsigned int, unsigned long long>
856{
857public:
858 using ValueType = unsigned long long;
859};
860
861template <>
862class JoinTraits<unsigned int, float>
863{
864public:
865 using ValueType = float;
866};
867
868template <>
869class JoinTraits<unsigned int, double>
870{
871public:
872 using ValueType = double;
873};
874
879template <>
880class JoinTraits<long, bool>
881{
882public:
883 using ValueType = long;
884};
885
886template <>
887class JoinTraits<long, char>
888{
889public:
890 using ValueType = long;
891};
892
893template <>
894class JoinTraits<long, unsigned char>
895{
896public:
897 using ValueType = long;
898};
899
900template <>
901class JoinTraits<long, short>
902{
903public:
904 using ValueType = long;
905};
906
907template <>
908class JoinTraits<long, unsigned short>
909{
910public:
911 using ValueType = long;
912};
913
914template <>
915class JoinTraits<long, int>
916{
917public:
918 using ValueType = long;
919};
920
921template <>
922class JoinTraits<long, unsigned int>
923{
924public:
925 using ValueType = float;
926};
927
928template <>
929class JoinTraits<long, long>
930{
931public:
932 using ValueType = long;
933};
934
935template <>
936class JoinTraits<long, unsigned long>
937{
938public:
939 using ValueType = float;
940};
941
942
943template <>
944class JoinTraits<long, long long>
945{
946public:
947 using ValueType = long long;
948};
949
950template <>
951class JoinTraits<long, unsigned long long>
952{
953public:
954 using ValueType = double;
955};
956
957template <>
958class JoinTraits<long, float>
959{
960public:
961 using ValueType = float;
962};
963
964template <>
965class JoinTraits<long, double>
966{
967public:
968 using ValueType = double;
969};
970
975template <>
976class JoinTraits<unsigned long, bool>
977{
978public:
979 using ValueType = unsigned long;
980};
981
982template <>
983class JoinTraits<unsigned long, char>
984{
985public:
986 using ValueType = float;
987};
988
989template <>
990class JoinTraits<unsigned long, unsigned char>
991{
992public:
993 using ValueType = unsigned long;
994};
995
996template <>
997class JoinTraits<unsigned long, short>
998{
999public:
1000 using ValueType = float;
1001};
1002
1003template <>
1004class JoinTraits<unsigned long, unsigned short>
1005{
1006public:
1007 using ValueType = unsigned long;
1008};
1009
1010template <>
1011class JoinTraits<unsigned long, int>
1012{
1013public:
1014 using ValueType = float;
1015};
1016
1017template <>
1018class JoinTraits<unsigned long, unsigned int>
1019{
1020public:
1021 using ValueType = unsigned long;
1022};
1023
1024template <>
1025class JoinTraits<unsigned long, long>
1026{
1027public:
1028 using ValueType = float;
1029};
1030
1031template <>
1032class JoinTraits<unsigned long, unsigned long>
1033{
1034public:
1035 using ValueType = unsigned long;
1036};
1037
1038template <>
1039class JoinTraits<unsigned long, long long>
1040{
1041public:
1042 using ValueType = double;
1043};
1044
1045template <>
1046class JoinTraits<unsigned long, unsigned long long>
1047{
1048public:
1049 using ValueType = unsigned long long;
1050};
1051
1052template <>
1053class JoinTraits<unsigned long, float>
1054{
1055public:
1056 using ValueType = float;
1057};
1058
1059template <>
1060class JoinTraits<unsigned long, double>
1061{
1062public:
1063 using ValueType = double;
1064};
1065
1066
1071template <>
1072class JoinTraits<long long, bool>
1073{
1074public:
1075 using ValueType = long long;
1076};
1077
1078template <>
1079class JoinTraits<long long, char>
1080{
1081public:
1082 using ValueType = long long;
1083};
1084
1085template <>
1086class JoinTraits<long long, unsigned char>
1087{
1088public:
1089 using ValueType = long long;
1090};
1091
1092template <>
1093class JoinTraits<long long, short>
1094{
1095public:
1096 using ValueType = long long;
1097};
1098
1099template <>
1100class JoinTraits<long long, unsigned short>
1101{
1102public:
1103 using ValueType = long long;
1104};
1105
1106template <>
1107class JoinTraits<long long, int>
1108{
1109public:
1110 using ValueType = long long;
1111};
1112
1113template <>
1114class JoinTraits<long long, unsigned int>
1115{
1116public:
1117 using ValueType = long long;
1118};
1119
1120template <>
1121class JoinTraits<long long, long>
1122{
1123public:
1124 using ValueType = long long;
1125};
1126
1127template <>
1128class JoinTraits<long long, unsigned long>
1129{
1130public:
1131 using ValueType = double;
1132};
1133
1134template <>
1135class JoinTraits<long long, long long>
1136{
1137public:
1138 using ValueType = long long;
1139};
1140
1141template <>
1142class JoinTraits<long long, unsigned long long>
1143{
1144public:
1145 using ValueType = double;
1146};
1147
1148template <>
1149class JoinTraits<long long, float>
1150{
1151public:
1152 using ValueType = double;
1153};
1154
1155template <>
1156class JoinTraits<long long, double>
1157{
1158public:
1159 using ValueType = double;
1160};
1161
1166template <>
1167class JoinTraits<unsigned long long, bool>
1168{
1169public:
1170 using ValueType = unsigned long long;
1171};
1172
1173template <>
1174class JoinTraits<unsigned long long, char>
1175{
1176public:
1177 using ValueType = double;
1178};
1179
1180template <>
1181class JoinTraits<unsigned long long, unsigned char>
1182{
1183public:
1184 using ValueType = unsigned long long;
1185};
1186
1187template <>
1188class JoinTraits<unsigned long long, short>
1189{
1190public:
1191 using ValueType = double;
1192};
1193
1194template <>
1195class JoinTraits<unsigned long long, unsigned short>
1196{
1197public:
1198 using ValueType = unsigned long long;
1199};
1200
1201template <>
1202class JoinTraits<unsigned long long, int>
1203{
1204public:
1205 using ValueType = double;
1206};
1207
1208template <>
1209class JoinTraits<unsigned long long, unsigned int>
1210{
1211public:
1212 using ValueType = unsigned long long;
1213};
1214
1215template <>
1216class JoinTraits<unsigned long long, long>
1217{
1218public:
1219 using ValueType = double;
1220};
1221
1222template <>
1223class JoinTraits<unsigned long long, unsigned long>
1224{
1225public:
1226 using ValueType = unsigned long long;
1227};
1228
1229template <>
1230class JoinTraits<unsigned long long, long long>
1231{
1232public:
1233 using ValueType = double;
1234};
1235
1236template <>
1237class JoinTraits<unsigned long long, unsigned long long>
1238{
1239public:
1240 using ValueType = unsigned long long;
1241};
1242
1243template <>
1244class JoinTraits<unsigned long long, float>
1245{
1246public:
1247 using ValueType = double;
1248};
1249
1250template <>
1251class JoinTraits<unsigned long long, double>
1252{
1253public:
1254 using ValueType = double;
1255};
1256
1257
1262template <>
1263class JoinTraits<float, bool>
1264{
1265public:
1266 using ValueType = float;
1267};
1268
1269template <>
1270class JoinTraits<float, char>
1271{
1272public:
1273 using ValueType = float;
1274};
1275
1276template <>
1277class JoinTraits<float, unsigned char>
1278{
1279public:
1280 using ValueType = float;
1281};
1282
1283template <>
1284class JoinTraits<float, short>
1285{
1286public:
1287 using ValueType = float;
1288};
1289
1290template <>
1291class JoinTraits<float, unsigned short>
1292{
1293public:
1294 using ValueType = float;
1295};
1296
1297template <>
1298class JoinTraits<float, int>
1299{
1300public:
1301 using ValueType = float;
1302};
1303
1304template <>
1305class JoinTraits<float, unsigned int>
1306{
1307public:
1308 using ValueType = float;
1309};
1310
1311template <>
1312class JoinTraits<float, long>
1313{
1314public:
1315 using ValueType = float;
1316};
1317
1318template <>
1319class JoinTraits<float, unsigned long>
1320{
1321public:
1322 using ValueType = float;
1323};
1324
1325template <>
1326class JoinTraits<float, long long>
1327{
1328public:
1329 using ValueType = double;
1330};
1331
1332template <>
1333class JoinTraits<float, unsigned long long>
1334{
1335public:
1336 using ValueType = double;
1337};
1338
1339template <>
1340class JoinTraits<float, float>
1341{
1342public:
1343 using ValueType = float;
1344};
1345
1346template <>
1347class JoinTraits<float, double>
1348{
1349public:
1350 using ValueType = double;
1351};
1352
1357template <>
1358class JoinTraits<double, bool>
1359{
1360public:
1361 using ValueType = double;
1362};
1363
1364template <>
1365class JoinTraits<double, char>
1366{
1367public:
1368 using ValueType = double;
1369};
1370
1371template <>
1372class JoinTraits<double, unsigned char>
1373{
1374public:
1375 using ValueType = double;
1376};
1377
1378template <>
1379class JoinTraits<double, short>
1380{
1381public:
1382 using ValueType = double;
1383};
1384
1385template <>
1386class JoinTraits<double, unsigned short>
1387{
1388public:
1389 using ValueType = double;
1390};
1391
1392template <>
1393class JoinTraits<double, int>
1394{
1395public:
1396 using ValueType = double;
1397};
1398
1399template <>
1400class JoinTraits<double, unsigned int>
1401{
1402public:
1403 using ValueType = double;
1404};
1405
1406template <>
1407class JoinTraits<double, long>
1408{
1409public:
1410 using ValueType = double;
1411};
1412
1413template <>
1414class JoinTraits<double, unsigned long>
1415{
1416public:
1417 using ValueType = double;
1418};
1419
1420template <>
1421class JoinTraits<double, long long>
1422{
1423public:
1424 using ValueType = double;
1425};
1426
1427template <>
1428class JoinTraits<double, unsigned long long>
1429{
1430public:
1431 using ValueType = double;
1432};
1433
1434template <>
1435class JoinTraits<double, float>
1436{
1437public:
1438 using ValueType = double;
1439};
1440
1441template <>
1442class JoinTraits<double, double>
1443{
1444public:
1445 using ValueType = double;
1446};
1447
1449
1450} // end namespace itk
1451
1452#endif // itkPixelTraits_h
Trait to determine what datatype is needed if the specified pixel types are "joined" into a single ve...
Traits for a pixel that define the dimension and component type.
typename TPixelType::ValueType ValueType
static constexpr unsigned int Dimension
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....