code: def stretch(self, stretch="crude", **kwargs):
          
          logger.debug("Applying stretch %s with parameters %s",
                       stretch, str(kwargs))
  
          # FIXME: do not apply stretch to alpha channel
  
          if isinstance(stretch, (tuple, list)):
              if len(stretch) == 2:
                  self.stretch_linear(cutoffs=stretch)
              else:
                  raise ValueError(
                      "Stretch tuple must have exactly two elements")
          elif stretch == "linear":
              self.stretch_linear(**kwargs)
          elif stretch == "histogram":
              self.stretch_hist_equalize(**kwargs)
          elif stretch in ["crude", "crude-stretch"]:
              self.crude_stretch(**kwargs)
          elif stretch in ["log", "logarithmic"]:
              self.stretch_logarithmic(**kwargs)
          elif stretch == "no":
              return
          elif isinstance(stretch, str):
              raise ValueError("Stretching method %s not recognized." % stretch)
          else:
              raise TypeError("Stretch parameter must be a string or a tuple.")
docs: Apply stretching to the current image.
  
          The value of *stretch* sets the type of stretching applied. The values
          "histogram", "linear", "crude" (or "crude-stretch") perform respectively
          histogram equalization, contrast stretching (with 5% cutoff on both
          sides), and contrast stretching without cutoff. The value "logarithmic"
          or "log" will do a logarithmic enhancement towards white. If a tuple or
          a list of two values is given as input, then a contrast stretching is
          performed with the values as cutoff. These values should be normalized
          in the range [0.0,1.0].