View source on GitHub
|
Convert RGB images to HSV.
tf.keras.ops.image.rgb_to_hsv(
images, data_format=None
)
images must be of float dtype, and the output is only well defined if the
values in images are in [0, 1].
All HSV values are in [0, 1]. A hue of 0 corresponds to pure red, 1/3
is pure green, and 2/3 is pure blue.
Args | |
|---|---|
images
|
Input image or batch of images. Must be 3D or 4D. |
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 | |
|---|---|
| HSV image or batch of HSV images. |
Examples:
import numpy as npfrom keras import opsx = np.random.random((2, 4, 4, 3))y = ops.image.rgb_to_hsv(x)y.shape(2, 4, 4, 3)
x = np.random.random((4, 4, 3)) # Single RGB imagey = ops.image.rgb_to_hsv(x)y.shape(4, 4, 3)
x = np.random.random((2, 3, 4, 4))y = ops.image.rgb_to_hsv(x, data_format="channels_first")y.shape(2, 3, 4, 4)
View source on GitHub