code: public static <T extends ImageGray<T>>T average(Planar<T> input , T output ) {
  		Class type = input.getBandType();
  		if( type == GrayU8.class ) {
  			return (T)ConvertImage.average((Planar<GrayU8>)input,(GrayU8)output);
  		} else if( type == GrayS8.class ) {
  			return (T)ConvertImage.average((Planar<GrayS8>)input,(GrayS8)output);
  		} else if( type == GrayU16.class ) {
  			return (T)ConvertImage.average((Planar<GrayU16>)input,(GrayU16)output);
  		} else if( type == GrayS16.class ) {
  			return (T)ConvertImage.average((Planar<GrayS16>)input,(GrayS16)output);
  		} else if( type == GrayS32.class ) {
  			return (T)ConvertImage.average((Planar<GrayS32>)input,(GrayS32)output);
  		} else if( type == GrayS64.class ) {
  			return (T)ConvertImage.average((Planar<GrayS64>)input,(GrayS64)output);
  		} else if( type == GrayF32.class ) {
  			return (T)ConvertImage.average((Planar<GrayF32>)input,(GrayF32)output);
  		} else if( type == GrayF64.class ) {
  			return (T)ConvertImage.average((Planar<GrayF64>)input,(GrayF64)output);
  		} else {
  			throw new IllegalArgumentException("Unknown image type: "+type.getSimpleName());
  		}
  	}
docs: Converts a {@link Planar} into a {@link ImageGray} by computing the average value of each pixel
  across all the bands.
  
  @param input Input Planar image that is being converted. Not modified.
  @param output (Optional) The single band output image.  If null a new image is created. Modified.
  @return Converted image.