mindspore.ops.AdjustHue

class mindspore.ops.AdjustHue[source]

Adjust hue of RGB images.

Note

A convenience method that transform an RGB image to float representation. The image is adjusted by transforming the image to HSV and shifting the intensities in the hue channel, then transform back to original data mode. It is recommended to minimize the number of redundant transformations when several adjustments are chained.

Inputs:
  • image (Tensor): RGB image or images. The size of the last dimension must be 3. the dtype is float16 or float32. At least 3-D.

  • delta (Tensor): How much to add to the hue channel, the dtype is float32. Must be 0-D.

Outputs:

Adjusted image(s), same shape and dtype as image.

Raises
  • TypeError – If neither image nor delta is a tensor.

  • TypeError – If the dtype of image is neither float16 nor float32.

  • TypeError – If the dtype of delta not float32.

  • ValueError – If the dimension of image is less than 3.

Supported Platforms:

GPU CPU

Examples

>>> class AdjustHue(nn.Cell):
...   def __init__(self):
...     super(AdjustHue, self).__init__()
...     self.adjustHue = ops.AdjustHue()
...   def construct(self, image, delta):
...     return self.adjustHue(image, delta)
...
>>> image = np.array([[[1, 2, 3], [4, 5, 6]],
...                   [[7, 8, 9], [10, 11, 12]],
...                   [[13, 14, 15], [16, 17, 18]]]).astype(np.float32)
>>> delta = 0.2
>>> adjust_hue = AdjustHue()
>>> output = adjust_hue(Tensor(image), Tensor(delta))
>>> print("output", output)
output [[[ 2.3999996  1.         3.       ]
         [ 5.3999996  4.         6.       ]]
        [[ 8.4        7.         9.       ]
         [11.4       10.        12.       ]]
        [[14.4       13.        15.       ]
         [17.4       16.        18.       ]]]