@@ -184,73 +184,66 @@ def wasm_type_from_image_type(itkimage): # noqa: C901
184
184
component = itk .template (itkimage )[1 ][0 ]
185
185
if component == itk .UL :
186
186
if os .name == 'nt' :
187
- return 'uint32_t ' , 1
187
+ return 'uint32 ' , 'Scalar'
188
188
else :
189
- return 'uint64_t ' , 1
189
+ return 'uint64 ' , 'Scalar'
190
190
mangle = None
191
- pixelType = 1
191
+ pixelType = 'Scalar'
192
192
if component == itk .SL :
193
193
if os .name == 'nt' :
194
- return 'int32_t ' , 1 ,
194
+ return 'int32 ' , 'Scalar' ,
195
195
else :
196
- return 'int64_t ' , 1 ,
196
+ return 'int64 ' , 'Scalar' ,
197
197
if component in (itk .SC , itk .UC , itk .SS , itk .US , itk .SI , itk .UI , itk .F ,
198
198
itk .D , itk .B , itk .SL , itk .SLL , itk .UL , itk .ULL ):
199
199
mangle = component
200
200
elif component in [i [1 ] for i in itk .Vector .items ()]:
201
201
mangle = itk .template (component )[1 ][0 ]
202
- pixelType = 5
202
+ pixelType = 'Vector'
203
203
elif component == itk .complex [itk .F ]:
204
- # complex float
205
- return 'float' , 10
204
+ return 'float32' , 'Complex'
206
205
elif component == itk .complex [itk .D ]:
207
- # complex float
208
- return 'double' , 10
206
+ return 'float64' , 'Complex'
209
207
elif component in [i [1 ] for i in itk .CovariantVector .items ()]:
210
- # CovariantVector
211
208
mangle = itk .template (component )[1 ][0 ]
212
- pixelType = 7
209
+ pixelType = 'CovariantVector' ,
213
210
elif component in [i [1 ] for i in itk .Offset .items ()]:
214
- # Offset
215
- return 'int64_t' , 4
211
+ return 'int64' , 'Offset'
216
212
elif component in [i [1 ] for i in itk .FixedArray .items ()]:
217
- # FixedArray
218
213
mangle = itk .template (component )[1 ][0 ]
219
- pixelType = 11
214
+ pixelType = 'FixedArray'
220
215
elif component in [i [1 ] for i in itk .RGBAPixel .items ()]:
221
- # RGBA
222
216
mangle = itk .template (component )[1 ][0 ]
223
- pixelType = 3
217
+ pixelType = 'RGBA'
224
218
elif component in [i [1 ] for i in itk .RGBPixel .items ()]:
225
- # RGB
226
219
mangle = itk .template (component )[1 ][0 ]
227
- pixelType = 2
220
+ pixelType = 'RGB'
228
221
elif component in [i [1 ] for i in itk .SymmetricSecondRankTensor .items ()]:
229
222
# SymmetricSecondRankTensor
230
223
mangle = itk .template (component )[1 ][0 ]
231
- pixelType = 8
224
+ pixelType = 'SymmetrySecondRankTensor'
232
225
else :
233
226
raise RuntimeError ('Unrecognized component type: {0}' .format (str (component )))
234
227
235
228
def _long_type ():
236
229
if os .name == 'nt' :
237
- return 'int32_t '
230
+ return 'int32 '
238
231
else :
239
- return 'int64_t '
232
+ return 'int64 '
240
233
_python_to_js = {
241
- itk .SC : 'int8_t ' ,
242
- itk .UC : 'uint8_t ' ,
243
- itk .SS : 'int16_t ' ,
244
- itk .US : 'uint16_t ' ,
245
- itk .SI : 'int32_t ' ,
246
- itk .UI : 'uint32_t ' ,
247
- itk .F : 'float ' ,
248
- itk .D : 'double ' ,
249
- itk .B : 'uint8_t ' ,
234
+ itk .SC : 'int8 ' ,
235
+ itk .UC : 'uint8 ' ,
236
+ itk .SS : 'int16 ' ,
237
+ itk .US : 'uint16 ' ,
238
+ itk .SI : 'int32 ' ,
239
+ itk .UI : 'uint32 ' ,
240
+ itk .F : 'float32 ' ,
241
+ itk .D : 'float64 ' ,
242
+ itk .B : 'uint8 ' ,
250
243
itk .SL : _long_type (),
251
244
itk .UL : 'u' + _long_type (),
252
- itk .SLL : 'int64_t ' ,
253
- itk .ULL : 'uint64_t ' ,
245
+ itk .SLL : 'int64 ' ,
246
+ itk .ULL : 'uint64 ' ,
254
247
}
255
248
imageType = dict (
256
249
dimension = itkimage .GetImageDimension (),
@@ -265,19 +258,19 @@ def image_type_from_wasm_type(jstype):
265
258
import itk
266
259
267
260
_pixelType_to_prefix = {
268
- 1 : '' ,
269
- 2 : 'RGB' ,
270
- 3 : 'RGBA' ,
271
- 4 : 'O' ,
272
- 5 : 'V' ,
273
- 7 : 'CV' ,
274
- 8 : 'SSRT' ,
275
- 11 : 'FA'
261
+ 'Scalar' : '' ,
262
+ 'RGB' : 'RGB' ,
263
+ 'RGBA' : 'RGBA' ,
264
+ 'Offset' : 'O' ,
265
+ 'Vector' : 'V' ,
266
+ 'CovariantVector' : 'CV' ,
267
+ 'SymmetricSecondRankTensor' : 'SSRT' ,
268
+ 'FixedArray' : 'FA'
276
269
}
277
270
pixelType = jstype ['pixelType' ]
278
271
dimension = jstype ['dimension' ]
279
- if pixelType == 10 :
280
- if jstype ['componentType' ] == 'float ' :
272
+ if pixelType == 'Complex' :
273
+ if jstype ['componentType' ] == 'float32 ' :
281
274
return itk .Image [itk .complex , itk .F ], np .float32
282
275
else :
283
276
return itk .Image [itk .complex , itk .D ], np .float64
@@ -289,20 +282,20 @@ def _long_type():
289
282
return 'L'
290
283
prefix = _pixelType_to_prefix [pixelType ]
291
284
_js_to_python = {
292
- 'int8_t ' : 'SC' ,
293
- 'uint8_t ' : 'UC' ,
294
- 'int16_t ' : 'SS' ,
295
- 'uint16_t ' : 'US' ,
296
- 'int32_t ' : 'SI' ,
297
- 'uint32_t ' : 'UI' ,
298
- 'int64_t ' : 'S' + _long_type (),
299
- 'uint64_t ' : 'U' + _long_type (),
300
- 'float ' : 'F' ,
301
- 'double ' : 'D'
285
+ 'int8 ' : 'SC' ,
286
+ 'uint8 ' : 'UC' ,
287
+ 'int16 ' : 'SS' ,
288
+ 'uint16 ' : 'US' ,
289
+ 'int32 ' : 'SI' ,
290
+ 'uint32 ' : 'UI' ,
291
+ 'int64 ' : 'S' + _long_type (),
292
+ 'uint64 ' : 'U' + _long_type (),
293
+ 'float32 ' : 'F' ,
294
+ 'float64 ' : 'D'
302
295
}
303
- if pixelType != 4 :
296
+ if pixelType != 'Offset' :
304
297
prefix += _js_to_python [jstype ['componentType' ]]
305
- if pixelType not in (1 , 2 , 3 , 10 ):
298
+ if pixelType not in ('Scalar' , 'RGB' , 'RGBA' , 'Complex' ):
306
299
prefix += str (dimension )
307
300
prefix += str (dimension )
308
301
return getattr (itk .Image , prefix )
0 commit comments