code: def stretch_hist_equalize(self, ch_nb):
          
          logger.info("Perform a histogram equalized contrast stretch.")
  
          if(self.channels[ch_nb].size ==
             np.ma.count_masked(self.channels[ch_nb])):
              logger.warning("Nothing to stretch !")
              return
  
          arr = self.channels[ch_nb]
  
          nwidth = 2048.0
  
          carr = arr.compressed()
  
          cdf = np.arange(0.0, 1.0, 1 / nwidth)
          logger.debug("Make histogram bins having equal amount of data, " +
                       "using numpy percentile function:")
          bins = np.percentile(carr, list(cdf * 100))
  
          res = np.ma.empty_like(arr)
          res.mask = np.ma.getmaskarray(arr)
          res[~res.mask] = np.interp(carr, bins, cdf)
  
          self.channels[ch_nb] = res
docs: Stretch the current image's colors by performing histogram
          equalization on channel *ch_nb*.