code: def invert(self, invert=True):
          
          if(isinstance(invert, (tuple, list)) and
             len(self.channels) != len(invert)):
              raise ValueError(
                  "Number of channels and invert components differ.")
  
          logger.debug("Applying invert with parameters %s", str(invert))
          if isinstance(invert, (tuple, list)):
              for i, chn in enumerate(self.channels):
                  if invert[i]:
                      self.channels[i] = 1 - chn
          elif invert:
              for i, chn in enumerate(self.channels):
                  self.channels[i] = 1 - chn
docs: Inverts all the channels of a image according to *invert*. If invert is a tuple or a list, elementwise
          invertion is performed, otherwise all channels are inverted if *invert* is true (default).
  
          Note: 'Inverting' means that black becomes white, and vice-versa, not that the values are negated !