# tf.keras.preprocessing.image.apply_affine_transform

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/preprocessing/image.py#L2481-L2622) |

Applies an affine transformation specified by the parameters given.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

\`tf.compat.v1.keras.preprocessing.image.apply_affine_transform\`

<br />

    tf.keras.preprocessing.image.apply_affine_transform(
        x,
        theta=0,
        tx=0,
        ty=0,
        shear=0,
        zx=1,
        zy=1,
        row_axis=1,
        col_axis=2,
        channel_axis=0,
        fill_mode='nearest',
        cval=0.0,
        order=1
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | 3D numpy array - a 2D image with one or more channels. |
| `theta` | Rotation angle in degrees. |
| `tx` | Width shift. |
| `ty` | Heigh shift. |
| `shear` | Shear angle in degrees. |
| `zx` | Zoom in x direction. |
| `zy` | Zoom in y direction |
| `row_axis` | Index of axis for rows (aka Y axis) in the input image. Direction: left to right. |
| `col_axis` | Index of axis for columns (aka X axis) in the input image. Direction: top to bottom. |
| `channel_axis` | Index of axis for channels in the input image. |
| `fill_mode` | Points outside the boundaries of the input are filled according to the given mode (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). |
| `cval` | Value used for points outside the boundaries of the input if `mode='constant'`. |
| `order` | int, order of interpolation |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The transformed version of the input. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ImportError` | if SciPy is not available. |

<br />