# tf.contrib.image.matrices_to_flat_transforms

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/image/python/ops/image_ops.py#L366-L396) |

Converts affine matrices to [`tf.contrib.image`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/image) projective transforms.

    tf.contrib.image.matrices_to_flat_transforms(
        transform_matrices
    )

Note that we expect matrices that map output coordinates to input coordinates.
To convert forward transformation matrices, call [`tf.linalg.inv`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/linalg/inv) on the
matrices and use the result here.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `transform_matrices` | One or more affine transformation matrices, for the reverse transformation in homogeneous coordinates. Shape `(3, 3)` or `(N, 3, 3)`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| 2D tensor of flat transforms with shape `(N, 8)`, which may be passed into [`tf.contrib.image.transform`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/image/transform). ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `transform_matrices` have an invalid shape. |

<br />