tf.keras.ops.image.elastic_transform
Stay organized with collections
Save and categorize content based on your preferences.
Applies elastic deformation to the image(s).
tf.keras.ops.image.elastic_transform(
images,
alpha=20.0,
sigma=5.0,
interpolation='bilinear',
fill_mode='reflect',
fill_value=0.0,
seed=None,
data_format=None
)
Args |
images
|
Input image or batch of images. Must be 3D or 4D.
|
alpha
|
Scaling factor that controls the intensity of the deformation.
|
sigma
|
Standard deviation of the Gaussian filter used for
smoothing the displacement fields.
|
interpolation
|
Interpolation method. Available methods are "nearest",
and "bilinear". Defaults to "bilinear".
|
fill_mode
|
Points outside the boundaries of the input are filled
according to the given mode. Available methods are "constant",
"nearest", "wrap" and "reflect". Defaults to "constant".
"reflect": (d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last
pixel.
"constant": (k k k k | a b c d | k k k k)
The input is extended by filling all values beyond
the edge with the same constant value k specified by
fill_value.
"wrap": (a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge.
"nearest": (a a a a | a b c d | d d d d)
The input is extended by the nearest pixel.
|
fill_value
|
Value used for points outside the boundaries of the input if
fill_mode="constant". Defaults to 0.
|
data_format
|
A string specifying the data format of the input tensor.
It can be either "channels_last" or "channels_first".
"channels_last" corresponds to inputs with shape
(batch, height, width, channels), while "channels_first"
corresponds to inputs with shape (batch, channels, height, width).
If not specified, the value will default to
keras.config.image_data_format.
|
Returns |
|
Transformed image or batch of images with elastic deformation.
|
Examples:
x = np.random.random((2, 64, 80, 3)) # batch of 2 RGB images
y = keras.ops.image.elastic_transform(x)
y.shape
(2, 64, 80, 3)
x = np.random.random((64, 80, 3)) # single RGB image
y = keras.ops.image.elastic_transform(x)
y.shape
(64, 80, 3)
x = np.random.random((2, 3, 64, 80)) # batch of 2 RGB images
y = keras.ops.image.elastic_transform(
x, data_format="channels_first")
y.shape
(2, 3, 64, 80)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2026-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]