class_docstr: Apply ``x = (x - mean) * contrast_factor + mean`` to each channel.
class_docstr_tok: ["Apply","``","x","=","(","x","-","mean",")","*","contrast_factor","+","mean","``","to","each","channel","."]
code: def _augment(self, img, r):
      old_dtype = img.dtype
  
      if img.ndim == 3:
          if self.rgb is not None:
              m = cv2.COLOR_RGB2GRAY if self.rgb else cv2.COLOR_BGR2GRAY
              grey = cv2.cvtColor(img.astype("float32"), m)
              mean = np.mean(grey)
          else:
              mean = np.mean(img, axis=(0, 1), keepdims=True)
      else:
          mean = np.mean(img)
  
      img = img * r + mean * (1 - r)
      if self.clip or old_dtype == np.uint8:
          img = np.clip(img, 0, 255)
      return img.astype(old_dtype)
  
imports: import numpy
  import cv2
  from ...utils.develop import log_deprecated
  from .base import PhotometricAugmentor
label_desc: Use image node_id 3 for calling the Contrast obj's underlying member method code with example usage: obj._augment(img, r) and returns: img