tf.image.adjust_saturation
Stay organized with collections
Save and categorize content based on your preferences.
Adjust saturation of RGB images.
tf.image.adjust_saturation(
image, saturation_factor, name=None
)
Used in the notebooks
This is a convenience method that converts RGB images to float
representation, converts them to HSV, adds an offset to the
saturation 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 or images. The image saturation is adjusted by
converting the images to HSV and multiplying the saturation (S) channel by
saturation_factor
and clipping. The images are then converted back to RGB.
saturation_factor
must be in the interval [0, inf)
.
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_saturation(x, 0.5)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 2. , 2.5, 3. ],
[ 5. , 5.5, 6. ]],
[[ 8. , 8.5, 9. ],
[11. , 11.5, 12. ]]], dtype=float32)>
Args |
image
|
RGB image or images. The size of the last dimension must be 3.
|
saturation_factor
|
float. Factor to multiply the saturation by.
|
name
|
A name for this operation (optional).
|
Returns |
Adjusted image(s), same shape and DType as image .
|
Raises |
InvalidArgumentError
|
input must have 3 channels
|
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 2024-04-26 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 2024-04-26 UTC."],[],[],null,["# tf.image.adjust_saturation\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/image_ops_impl.py#L3108-L3160) |\n\nAdjust saturation 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_saturation`](https://www.tensorflow.org/api_docs/python/tf/image/adjust_saturation)\n\n\u003cbr /\u003e\n\n tf.image.adjust_saturation(\n image, saturation_factor, name=None\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|--------------------------------------------------------------------------------------|\n| - [Data augmentation](https://www.tensorflow.org/tutorials/images/data_augmentation) |\n\nThis is a convenience method that converts RGB images to float\nrepresentation, converts them to HSV, adds an offset to the\nsaturation 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 or images. The image saturation is adjusted by\nconverting the images to HSV and multiplying the saturation (S) channel by\n`saturation_factor` and clipping. The images are then converted back to RGB.\n\n`saturation_factor` must be in the interval `[0, inf)`.\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_saturation(x, 0.5)\n \u003ctf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=\n array([[[ 2. , 2.5, 3. ],\n [ 5. , 5.5, 6. ]],\n [[ 8. , 8.5, 9. ],\n [11. , 11.5, 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| `saturation_factor` | float. Factor to multiply the saturation by. |\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` | input must have 3 channels |\n\n\u003cbr /\u003e"]]