code: public static <T extends ImageGray<T>> T stretch(T input, double gamma, double beta, double max , T output) {
  		if( input instanceof GrayF32) {
  			return (T)GrayImageOps.stretch((GrayF32)input,gamma,(float)beta,(float)max,(GrayF32)output);
  		} else if( input instanceof GrayU8) {
  			return (T)GrayImageOps.stretch((GrayU8)input,gamma,(int)beta,(int)max,(GrayU8)output);
  		} else if( input instanceof GrayS16) {
  			return (T)GrayImageOps.stretch((GrayS16)input,gamma,(int)beta,(int)max,(GrayS16)output);
  		} else {
  			throw new IllegalArgumentException("Unknown image type: "+input.getClass().getSimpleName());
  		}
  	}
docs: <p>
  Stretches the image's intensity:<br>
  O<sub>x,y</sub> = I<sub>x,y</sub>&gamma; + beta<br>
  </p>
  <p>
  The image's intensity is clamped at 0 and max;
  </p>
  
  @param input  Input image. Not modified.
  @param output If not null, the output image.  If null a new image is declared and returned.  Modified.
  @return Output image.