tf.image.adjust_hue
Stay organized with collections
Save and categorize content based on your preferences.
Adjust hue of RGB images.
tf.image.adjust_hue(
image, delta, name=None
)
This is a convenience method that converts an RGB image to float
representation, converts it to HSV, adds an offset to the
hue channel, converts back to RGB and then back to the original
data type. If several adjustments are chained it is advisable to minimize
the number of redundant conversions.
image
is an RGB image. The image hue is adjusted by converting the
image(s) to HSV and rotating the hue channel (H) by
delta
. The image is then converted back to RGB.
delta
must be in the interval [-1, 1]
.
Usage Example:
x = [[[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0]],
[[7.0, 8.0, 9.0],
[10.0, 11.0, 12.0]]]
tf.image.adjust_hue(x, 0.2)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 2.3999996, 1. , 3. ],
[ 5.3999996, 4. , 6. ]],
[[ 8.4 , 7. , 9. ],
[11.4 , 10. , 12. ]]], dtype=float32)>
Args |
image
|
RGB image or images. The size of the last dimension must be 3.
|
delta
|
float. How much to add to the hue channel.
|
name
|
A name for this operation (optional).
|
Returns |
Adjusted image(s), same shape and DType as image .
|
Raises |
InvalidArgumentError
|
image must have at least 3 dimensions.
|
InvalidArgumentError
|
The size of the last dimension must be 3.
|
ValueError
|
if delta is not in the interval of [-1, 1] .
|
Usage Example:
image = [[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]],
[[13, 14, 15], [16, 17, 18]]]
image = tf.constant(image)
tf.image.adjust_hue(image, 0.2)
<tf.Tensor: shape=(3, 2, 3), dtype=int32, numpy=
array([[[ 2, 1, 3],
[ 5, 4, 6]],
[[ 8, 7, 9],
[11, 10, 12]],
[[14, 13, 15],
[17, 16, 18]]], dtype=int32)>
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 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.image.adjust_hue\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.12.1/tensorflow/python/ops/image_ops_impl.py#L2715-L2787) |\n\nAdjust hue of RGB images.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.image.adjust_hue`](https://www.tensorflow.org/api_docs/python/tf/image/adjust_hue)\n\n\u003cbr /\u003e\n\n tf.image.adjust_hue(\n image, delta, name=None\n )\n\nThis is a convenience method that converts an RGB image to float\nrepresentation, converts it to HSV, adds an offset to the\nhue channel, converts back to RGB and then back to the original\ndata type. If several adjustments are chained it is advisable to minimize\nthe number of redundant conversions.\n\n`image` is an RGB image. The image hue is adjusted by converting the\nimage(s) to HSV and rotating the hue channel (H) by\n`delta`. The image is then converted back to RGB.\n\n`delta` must be in the interval `[-1, 1]`.\n\n#### Usage Example:\n\n x = [[[1.0, 2.0, 3.0],\n [4.0, 5.0, 6.0]],\n [[7.0, 8.0, 9.0],\n [10.0, 11.0, 12.0]]]\n tf.image.adjust_hue(x, 0.2)\n \u003ctf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=\n array([[[ 2.3999996, 1. , 3. ],\n [ 5.3999996, 4. , 6. ]],\n [[ 8.4 , 7. , 9. ],\n [11.4 , 10. , 12. ]]], dtype=float32)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|----------------------------------------------------------------|\n| `image` | RGB image or images. The size of the last dimension must be 3. |\n| `delta` | float. How much to add to the hue channel. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Adjusted image(s), same shape and DType as `image`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------------------|-------------------------------------------------|\n| `InvalidArgumentError` | image must have at least 3 dimensions. |\n| `InvalidArgumentError` | The size of the last dimension must be 3. |\n| `ValueError` | if `delta` is not in the interval of `[-1, 1]`. |\n\n\u003cbr /\u003e\n\n#### Usage Example:\n\n image = [[[1, 2, 3], [4, 5, 6]],\n [[7, 8, 9], [10, 11, 12]],\n [[13, 14, 15], [16, 17, 18]]]\n image = tf.constant(image)\n tf.image.adjust_hue(image, 0.2)\n \u003ctf.Tensor: shape=(3, 2, 3), dtype=int32, numpy=\n array([[[ 2, 1, 3],\n [ 5, 4, 6]],\n [[ 8, 7, 9],\n [11, 10, 12]],\n [[14, 13, 15],\n [17, 16, 18]]], dtype=int32)\u003e"]]