code: def stretch_linear(self, ch_nb, cutoffs=(0.005, 0.005)):
          
          logger.debug("Perform a linear contrast stretch.")
  
          if((self.channels[ch_nb].size ==
              np.ma.count_masked(self.channels[ch_nb])) or
             self.channels[ch_nb].min() == self.channels[ch_nb].max()):
              logger.warning("Nothing to stretch !")
              return
  
          arr = self.channels[ch_nb]
          carr = arr.compressed()
  
          logger.debug("Calculate the histogram percentiles: ")
          logger.debug("Left and right percentiles: " +
                       str(cutoffs[0] * 100) + " " + str(cutoffs[1] * 100))
  
          left, right = np.percentile(
              carr, [cutoffs[0] * 100, 100. - cutoffs[1] * 100])
  
          delta_x = (right - left)
          logger.debug("Interval: left=%f, right=%f width=%f",
                       left, right, delta_x)
  
          if delta_x > 0.0:
              self.channels[ch_nb] = np.ma.array((arr - left) / delta_x,
                                                 mask=arr.mask)
          else:
              logger.warning("Unable to make a contrast stretch!")
docs: Stretch linearly the contrast of the current image on channel
          *ch_nb*, using *cutoffs* for left and right trimming.