@@ -40,6 +40,9 @@ def resample_image(image, resample_params, use_voxels=False, interp_type=1):
40
40
>>> fi = ants.image_read( ants.get_ants_data("r16"))
41
41
>>> finn = ants.resample_image(fi,(50,60),True,0)
42
42
>>> filin = ants.resample_image(fi,(1.5,1.5),False,1)
43
+ >>> img = ants.image_read( ants.get_ants_data("r16"))
44
+ >>> img = ants.merge_channels([img, img])
45
+ >>> outimg = ants.resample_image(img, (128,128), True)
43
46
"""
44
47
if image .components == 1 :
45
48
inimage = image .clone ('float' )
@@ -53,7 +56,21 @@ def resample_image(image, resample_params, use_voxels=False, interp_type=1):
53
56
outimage = outimage .clone (image .pixeltype )
54
57
return outimage
55
58
else :
56
- raise ValueError ('images with more than 1 component not currently supported' )
59
+ images = utils .split_channels (image )
60
+ new_images = []
61
+ for image in images :
62
+ inimage = image .clone ('float' )
63
+ outimage = image .clone ('float' )
64
+ rsampar = 'x' .join ([str (rp ) for rp in resample_params ])
65
+
66
+ args = [image .dimension , inimage , outimage , rsampar , int (use_voxels ), interp_type ]
67
+ processed_args = utils ._int_antsProcessArguments (args )
68
+ libfn = utils .get_lib_fn ('ResampleImage' )
69
+ libfn (processed_args )
70
+ outimage = outimage .clone (image .pixeltype )
71
+ new_images .append (outimage )
72
+ outimage = utils .merge_channels (new_images )
73
+ return outimage
57
74
58
75
59
76
def resample_image_to_target (image , target , interp_type = 'linear' , imagetype = 0 , verbose = False , ** kwargs ):
0 commit comments