31
31
#include " itkSpecializedImagePipelineFunctor.h"
32
32
#include " WebAssemblyInterfaceExport.h"
33
33
34
+ #include " itkImageJSON.h"
35
+
34
36
namespace itk
35
37
{
36
38
37
- namespace wasm
38
- {
39
+ WebAssemblyInterface_EXPORT bool lexical_cast (const std::string &input, ImageTypeJSON & imageType);
39
40
40
- struct InterfaceImageType
41
+ namespace wasm
41
42
{
42
- unsigned int dimension{2 };
43
- std::string componentType{" uint8" };
44
- std::string pixelType{" Scalar" };
45
- unsigned int components{1 };
46
- };
47
-
48
- WebAssemblyInterface_EXPORT bool lexical_cast (const std::string &input, InterfaceImageType & imageType);
49
43
50
44
/* * \class SupportInputImageTypes
51
45
*
@@ -98,7 +92,7 @@ SupportInputImageTypes
98
92
static int
99
93
Dimensions (const std::string & inputImageOptionName, Pipeline & pipeline)
100
94
{
101
- InterfaceImageType imageType;
95
+ ImageTypeJSON imageType;
102
96
103
97
const auto iwpArgc = pipeline.get_argc ();
104
98
const auto iwpArgv = pipeline.get_argv ();
@@ -128,17 +122,20 @@ SupportInputImageTypes
128
122
private:
129
123
template <unsigned int VDimension, typename TPixel, typename ...TPixelsRest>
130
124
static int
131
- IteratePixelTypes (Pipeline & pipeline, const InterfaceImageType & imageType, bool passThrough = false )
125
+ IteratePixelTypes (Pipeline & pipeline, const ImageTypeJSON & imageType, bool passThrough = false )
132
126
{
133
127
constexpr unsigned int Dimension = VDimension;
134
128
using PixelType = TPixel;
135
129
using ConvertPixelTraits = DefaultConvertPixelTraits<PixelType>;
136
130
137
131
if (passThrough ||
138
- imageType.componentType == MapComponentType<typename ConvertPixelTraits::ComponentType>::ComponentString &&
139
- imageType.pixelType == MapPixelType<PixelType>::PixelString )
132
+ imageType.componentType == MapComponentType<typename ConvertPixelTraits::ComponentType>::JSONComponentEnum &&
133
+ imageType.pixelType == MapPixelType<PixelType>::JSONPixelEnum )
140
134
{
141
- if (passThrough || imageType.pixelType == " VariableLengthVector" || imageType.pixelType == " VariableSizeMatrix" || imageType.components == ConvertPixelTraits::GetNumberOfComponents () )
135
+ if (passThrough ||
136
+ imageType.pixelType == JSONPixelTypesEnum::VariableLengthVector ||
137
+ imageType.pixelType == JSONPixelTypesEnum::VariableSizeMatrix ||
138
+ imageType.components == ConvertPixelTraits::GetNumberOfComponents () )
142
139
{
143
140
return SpecializedImagePipelineFunctor<TPipelineFunctor, Dimension, PixelType>()(pipeline);
144
141
}
@@ -149,14 +146,15 @@ SupportInputImageTypes
149
146
}
150
147
151
148
std::ostringstream ostrm;
152
- ostrm << " Unsupported pixel type: " << imageType.pixelType << " with component type: " << imageType.componentType << " and components: " << imageType.components ;
149
+ std::string imageTypeString = glz::write_json (imageType).value_or (" error" );
150
+ ostrm << " Unsupported image type: " << imageTypeString << std::endl;
153
151
CLI::Error err (" Runtime error" , ostrm.str (), 1 );
154
152
return pipeline.exit (err);
155
153
}
156
154
157
155
template <unsigned int VDimension, unsigned int ...VDimensions>
158
156
static int
159
- IterateDimensions (Pipeline & pipeline, const InterfaceImageType & imageType, bool passThrough = false )
157
+ IterateDimensions (Pipeline & pipeline, const ImageTypeJSON & imageType, bool passThrough = false )
160
158
{
161
159
if (passThrough || VDimension == imageType.dimension )
162
160
{
0 commit comments