ants.contrib.sampling.affine3d
Affine transforms
See http://www.cs.cornell.edu/courses/cs4620/2010fa/lectures/03transforms3d.pdf
Classes
|
Create a specified ANTs Affine Transform |
|
Apply a Rotate3D transform to an image, but with the zoom parameters randomly generated from a user-specified range. |
|
Apply a Shear3D transform to an image, but with the shear parameters randomly generated from a user-specified range. |
|
Apply a Translate3D transform to an image, but with the shear parameters randomly generated from a user-specified range. |
|
Apply a Zoom3D transform to an image, but with the zoom parameters randomly generated from a user-specified range. |
|
Create an ANTs Affine Transform with a specified level of rotation. |
|
Create an ANTs Affine Transform with a specified shear. |
|
Create an ANTs Affine Transform with a specified translation. |
|
Create an ANTs Affine Transform with a specified level of zoom. |
- class Affine3D(transformation, reference=None, lazy=False)[source]
Bases:
objectCreate a specified ANTs Affine Transform
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with the given translation parameters. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.Affine3D(transformation=np.array([[1, 0, 0, dx], [0, 1, 0, dy],[0, 0, 1, dz]]) >>> img2_x = tx.transform(img)# image translated by (dx, dy, dz)
- class RandomRotate3D(rotation_range, reference=None, lazy=False)[source]
Bases:
objectApply a Rotate3D transform to an image, but with the zoom parameters randomly generated from a user-specified range. The range is determined by a mean (first parameter) and standard deviation (second parameter) via calls to random.gauss.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with rotation parameters randomly generated from the user-specified range. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.RandomRotate3D(rotation_range=(-10,10)) >>> img2 = tx.transform(img)
- class RandomShear3D(shear_range, reference=None, lazy=False)[source]
Bases:
objectApply a Shear3D transform to an image, but with the shear parameters randomly generated from a user-specified range. The range is determined by a mean (first parameter) and standard deviation (second parameter) via calls to random.gauss.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with shear parameters randomly generated from the user-specified range. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.RandomShear3D(shear_range=(-10,10)) >>> img2 = tx.transform(img)
- class RandomTranslate3D(translation_range, reference=None, lazy=False)[source]
Bases:
objectApply a Translate3D transform to an image, but with the shear parameters randomly generated from a user-specified range. The range is determined by a mean (first parameter) and standard deviation (second parameter) via calls to random.gauss.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with translation parameters randomly generated from the user-specified range. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.RandomShear3D(translation_range=(-10,10)) >>> img2 = tx.transform(img)
- class RandomZoom3D(zoom_range, reference=None, lazy=False)[source]
Bases:
objectApply a Zoom3D transform to an image, but with the zoom parameters randomly generated from a user-specified range. The range is determined by a mean (first parameter) and standard deviation (second parameter) via calls to random.gauss.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with zoom parameters randomly generated from the user-specified range. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.RandomZoom3D(zoom_range=(0.8,0.9)) >>> img2 = tx.transform(img)
- class Rotate3D(rotation, reference=None, lazy=False)[source]
Bases:
objectCreate an ANTs Affine Transform with a specified level of rotation.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with the given rotation parameters. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.Rotate3D(rotation=(10,-5,12)) >>> img2 = tx.transform(img)
- class Shear3D(shear, reference=None, lazy=False)[source]
Bases:
objectCreate an ANTs Affine Transform with a specified shear.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with the given shear parameters. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.Shear3D(shear=(10,0,0)) >>> img2_x = tx.transform(img)# x axis stays same >>> tx = ants.contrib.Shear3D(shear=(-10,0,0)) # other direction >>> img2_x = tx.transform(img)# x axis stays same >>> tx = ants.contrib.Shear3D(shear=(0,10,0)) >>> img2_y = tx.transform(img) # y axis stays same >>> tx = ants.contrib.Shear3D(shear=(0,0,10)) >>> img2_z = tx.transform(img) # z axis stays same >>> tx = ants.contrib.Shear3D(shear=(10,10,10)) >>> img2 = tx.transform(img)
- class Translate3D(translation, reference=None, lazy=False)[source]
Bases:
objectCreate an ANTs Affine Transform with a specified translation.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with the given translation parameters. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.Translate3D(translation=(10,0,0)) >>> img2_x = tx.transform(img)# x axis stays same >>> tx = ants.contrib.Translate3D(translation=(-10,0,0)) # other direction >>> img2_x = tx.transform(img)# x axis stays same >>> tx = ants.contrib.Translate3D(translation=(0,10,0)) >>> img2_y = tx.transform(img) # y axis stays same >>> tx = ants.contrib.Translate3D(translation=(0,0,10)) >>> img2_z = tx.transform(img) # z axis stays same >>> tx = ants.contrib.Translate3D(translation=(10,10,10)) >>> img2 = tx.transform(img)
- class Zoom3D(zoom, reference=None, lazy=False)[source]
Bases:
objectCreate an ANTs Affine Transform with a specified level of zoom. Any value greater than 1 implies a “zoom-out” and anything less than 1 implies a “zoom-in”.
- transform(X=None, y=None)[source]
Transform an image using an Affine transform with the given zoom parameters. Return the transform if X=None.
- Parameters:
X (
ants.core.ANTsImage) – Image to transformy (
ANTsImage (optional)) – Another image to transform
- Return type:
ANTsImage if y is None,else a tupleofANTsImage types
Examples
>>> import ants >>> img = ants.image_read(ants.get_data('ch2')) >>> tx = ants.contrib.Zoom3D(zoom=(0.8,0.8,0.8)) >>> img2 = tx.transform(img)