parameters: (img, hue_factor)
return_statement: return img
docstring: Function for adjusting hue of an image.
  
      The image hue is adjusted by converting the image to HSV and
      cyclically shifting the intensities in the hue channel (H).
      The image is then converted back to original image mode.
  
      `hue_factor` is the amount of shift in H channel and must be in the
      interval `[-0.5, 0.5]`.
  
      See `Hue`_ for more details.
  
      .. _Hue: https://en.wikipedia.org/wiki/Hue
  
      Args::
  
          [in] img (PIL Image.Image): Image to be adjusted.
          [in] hue_factor (float):  How much to shift the hue channel.
               Should be in [-0.5, 0.5]. 0.5 and -0.5 give complete reversal of
               hue channel in HSV space in positive and negative direction respectively.
               0 means no shift. Therefore, both -0.5 and 0.5 will give an image
               with complementary colors while 0 gives the original image.
  
      Returns::
  
          [out] PIL Image.Image: Saturation adjusted image.
  
      Example::
          
          img = Image.open(...)
          img_ = transform.adjust_hue(img, 0.1)
docstring_summary: Function for adjusting hue of an image.
docstring_tokens: Function for adjusting hue of an image .
function: def adjust_hue(img, hue_factor):
      """
      Function for adjusting hue of an image.
  
      The image hue is adjusted by converting the image to HSV and
      cyclically shifting the intensities in the hue channel (H).
      The image is then converted back to original image mode.
  
      `hue_factor` is the amount of shift in H channel and must be in the
      interval `[-0.5, 0.5]`.
  
      See `Hue`_ for more details.
  
      .. _Hue: https://en.wikipedia.org/wiki/Hue
  
      Args::
  
          [in] img (PIL Image.Image): Image to be adjusted.
          [in] hue_factor (float):  How much to shift the hue channel.
               Should be in [-0.5, 0.5]. 0.5 and -0.5 give complete reversal of
               hue channel in HSV space in positive and negative direction respectively.
               0 means no shift. Therefore, both -0.5 and 0.5 will give an image
               with complementary colors while 0 gives the original image.
  
      Returns::
  
          [out] PIL Image.Image: Saturation adjusted image.
  
      Example::
          
          img = Image.open(...)
          img_ = transform.adjust_hue(img, 0.1)
      """
      if not(-0.5 <= hue_factor <= 0.5):
          raise ValueError(f'hue_factor ({hue_factor}) is not in [-0.5, 0.5].')
  
      if not _is_pil_image(img):
          raise TypeError(f'img should be PIL Image. Got {type(img)}')
  
      input_mode = img.mode
      if input_mode in {'L', '1', 'I', 'F'}:
          return img
  
      h, s, v = img.convert('HSV').split()
  
      np_h = np.array(h, dtype=np.uint8)
      # uint8 addition take cares of rotation across boundaries
      with np.errstate(over='ignore'):
          np_h += np.uint8(hue_factor * 255)
      h = Image.fromarray(np_h, 'L')
  
      img = Image.merge('HSV', (h, s, v)).convert(input_mode)
      return img
function_tokens: def adjust_hue ( img , hue_factor ) : if not ( - 0.5 <= hue_factor <= 0.5 ) : raise ValueError ( f'hue_factor ({hue_factor}) is not in [-0.5, 0.5].' ) if not _is_pil_image ( img ) : raise TypeError ( f'img should be PIL Image. Got {type(img)}' ) input_mode = img . mode if input_mode in { 'L' , '1' , 'I' , 'F' } : return img h , s , v = img . convert ( 'HSV' ) . split ( ) np_h = np . array ( h , dtype = np . uint8 ) # uint8 addition take cares of rotation across boundaries with np . errstate ( over = 'ignore' ) : np_h += np . uint8 ( hue_factor * 255 ) h = Image . fromarray ( np_h , 'L' ) img = Image . merge ( 'HSV' , ( h , s , v ) ) . convert ( input_mode ) return img