code: def gamma(self, gamma=1.0):
          
  
          if(isinstance(gamma, (list, tuple, set)) and
             len(gamma) != len(self.channels)):
              raise ValueError("Number of channels and gamma components differ.")
          if isinstance(gamma, (tuple, list)):
              gamma_list = list(gamma)
          else:
              gamma_list = [gamma] * len(self.channels)
          for i in range(len(self.channels)):
              gamma = float(gamma_list[i])
              if gamma < 0:
                  raise ValueError("Gamma correction must be a positive number.")
              logger.debug("Applying gamma %f", gamma)
              if gamma == 1.0:
                  continue
  
              if isinstance(self.channels[i], np.ma.core.MaskedArray):
                  if ne:
                      self.channels[i] = np.ma.array(
                          ne.evaluate("data ** (1.0 / gamma)",
                                      local_dict={"data": self.channels[i].data,
                                                  'gamma': gamma}),
                          mask=self.channels[i].mask,
                          copy=False)
                  else:
                      self.channels[i] = np.ma.array(self.channels[i].data **
                                                     (1.0 / gamma),
                                                     mask=self.channels[i].mask,
                                                     copy=False)
              else:
                  self.channels[i] = np.where(self.channels[i] >= 0,
                                              self.channels[i] **
                                              (1.0 / gamma),
                                              self.channels[i])
docs: Apply gamma correction to the channels of the image. If *gamma* is a
          tuple, then it should have as many elements as the channels of the
          image, and the gamma correction is applied elementwise. If *gamma* is a
          number, the same gamma correction is applied on every channel, if there
          are several channels in the image. The behaviour of :func:`gamma` is
          undefined outside the normal [0,1] range of the channels.