<p>
Returns the sum of all the pixels in the image.
</p>

@param img Input image. Not modified.
484513
public static long sum( InterleavedS64 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
645462
public static BufferedImage getImage(byte[] imageBytes) throws IOException {

		BufferedImage image = null;

		if (imageBytes != null) {
			ByteArrayInputStream stream = new ByteArrayInputStream(imageBytes);
			image = ImageIO.read(stream);
			stream.close();
		}

		return image;
	}
32541
public com.google.api.ads.adwords.axis.v201809.cm.Image getImage() {
        return image;
    }
1270377
public double sum() {
        double sum = 0;
        TIntDoubleIterator iter = edges.iterator();
        while (iter.hasNext()) {
            iter.advance();
            sum += iter.value();
        }
        return sum;
    }
944701
public static int sum( InterleavedS16 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
424149
public static double mean( InterleavedS16 img ) {
		return sum(img)/(double)(img.width*img.height*img.numBands);
	}
306144
public static double min( ImageBase input ) {
		if( input instanceof ImageGray) {
			if (GrayU8.class == input.getClass()) {
				return ImageStatistics.min((GrayU8) input);
			} else if (GrayS8.class == input.getClass()) {
				return ImageStatistics.min((GrayS8) input);
			} else if (GrayU16.class == input.getClass()) {
				return ImageStatistics.min((GrayU16) input);
			} else if (GrayS16.class == input.getClass()) {
				return ImageStatistics.min((GrayS16) input);
			} else if (GrayS32.class == input.getClass()) {
				return ImageStatistics.min((GrayS32) input);
			} else if (GrayS64.class == input.getClass()) {
				return ImageStatistics.min((GrayS64) input);
			} else if (GrayF32.class == input.getClass()) {
				return ImageStatistics.min((GrayF32) input);
			} else if (GrayF64.class == input.getClass()) {
				return ImageStatistics.min((GrayF64) input);
			} else {
				throw new IllegalArgumentException("Unknown Image Type: " + input.getClass().getSimpleName());
			}
		} else if( input instanceof ImageInterleaved ) {
			if (InterleavedU8.class == input.getClass()) {
				return ImageStatistics.min((InterleavedU8) input);
			} else if (InterleavedS8.class == input.getClass()) {
				return ImageStatistics.min((InterleavedS8) input);
			} else if (InterleavedU16.class == input.getClass()) {
				return ImageStatistics.min((InterleavedU16) input);
			} else if (InterleavedS16.class == input.getClass()) {
				return ImageStatistics.min((InterleavedS16) input);
			} else if (InterleavedS32.class == input.getClass()) {
				return ImageStatistics.min((InterleavedS32) input);
			} else if (InterleavedS64.class == input.getClass()) {
				return ImageStatistics.min((InterleavedS64) input);
			} else if (InterleavedF32.class == input.getClass()) {
				return ImageStatistics.min((InterleavedF32) input);
			} else if (InterleavedF64.class == input.getClass()) {
				return ImageStatistics.min((InterleavedF64) input);
			} else {
				throw new IllegalArgumentException("Unknown Image Type: " + input.getClass().getSimpleName());
			}
		} else if( input instanceof Planar ){
			Planar pl = (Planar)input;
			int N = pl.getNumBands();
			if( N == 0 )
				throw new IllegalArgumentException("Must have at least one band");
			double result = min(pl.bands[0]);
			for (int i = 1; i < N; i++) {
				result = Math.min(result,min(pl.bands[i]));
			}
			return result;
		} else {
			throw new IllegalArgumentException("Image type not yet supported "+input.getClass().getSimpleName());
		}
	}
865194
public static String toInlineImage(@javax.annotation.Nonnull final LabeledObject<BufferedImage> img) {
    @javax.annotation.Nonnull final ByteArrayOutputStream b = new ByteArrayOutputStream();
    try {
      ImageIO.write(img.data, "PNG", b);
    } catch (@javax.annotation.Nonnull final RuntimeException e) {
      throw e;
    } catch (@javax.annotation.Nonnull final Exception e) {
      throw new RuntimeException(e);
    }
    final byte[] byteArray = b.toByteArray();
    final String encode = Base64.getEncoder().encodeToString(byteArray);
    return "<img src=\"data:image/png;base64," + encode + "\" alt=\"" + img.label + "\" />";
  }
727107
public static void boundImage( GrayS16 img , int min , int max ) {
		ImplPixelMath.boundImage(img,min,max);
	}
1374216
public static float mean( InterleavedF32 img ) {
		return sum(img)/(float)(img.width*img.height*img.numBands);
	}
557214
public static double mean( InterleavedS32 img ) {
		return sum(img)/(double)(img.width*img.height*img.numBands);
	}
464274
public static double variance( GrayS32 img , double mean ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.variance(img,mean);
		} else {
			return ImplImageStatistics.variance(img,mean);
		}
	}
146240
public static int[] getImageSize(InputStream input) throws IOException
    {
        try {
            ImageInputStream imageInput = ImageIO.createImageInputStream(input);
            BufferedImage image = ImageIO.read(imageInput);
            return new int[]{image.getWidth(), image.getHeight()};
        } finally {
            input.close();
        }
    }
1191905
public static double variance( GrayU8 img , double mean ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.variance(img,mean);
		} else {
			return ImplImageStatistics.variance(img,mean);
		}
	}
1114189
public static <T extends ImageBase<T>> double meanDiffSq( T inputA , T inputB ) {

		if( inputA instanceof ImageGray) {
			if (GrayU8.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayU8) inputA, (GrayU8) inputB);
			} else if (GrayS8.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayS8) inputA, (GrayS8) inputB);
			} else if (GrayU16.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayU16) inputA, (GrayU16) inputB);
			} else if (GrayS16.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayS16) inputA, (GrayS16) inputB);
			} else if (GrayS32.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayS32) inputA, (GrayS32) inputB);
			} else if (GrayS64.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayS64) inputA, (GrayS64) inputB);
			} else if (GrayF32.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayF32) inputA, (GrayF32) inputB);
			} else if (GrayF64.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((GrayF64) inputA, (GrayF64) inputB);
			} else {
				throw new IllegalArgumentException("Unknown image Type");
			}
		} else if( inputA instanceof ImageInterleaved ) {
			if (InterleavedU8.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedU8) inputA, (InterleavedU8) inputB);
			} else if (InterleavedS8.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedS8) inputA, (InterleavedS8) inputB);
			} else if (InterleavedU16.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedU16) inputA, (InterleavedU16) inputB);
			} else if (InterleavedS16.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedS16) inputA, (InterleavedS16) inputB);
			} else if (InterleavedS32.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedS32) inputA, (InterleavedS32) inputB);
			} else if (InterleavedS64.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedS64) inputA, (InterleavedS64) inputB);
			} else if (InterleavedF32.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedF32) inputA, (InterleavedF32) inputB);
			} else if (InterleavedF64.class == inputA.getClass()) {
				return ImageStatistics.meanDiffSq((InterleavedF64) inputA, (InterleavedF64) inputB);
			} else {
				throw new IllegalArgumentException("Unknown image Type");
			}
		} else if( inputA instanceof Planar ) {
			double mean = 0;
			Planar inA = (Planar) inputA;
			Planar inB = (Planar) inputB;
			for (int i = 0; i < inA.getNumBands(); i++) {
				mean += meanDiffSq( inA.getBand(i), inB.getBand(i));
			}
			return mean/inA.getNumBands();
		} else {
			throw new IllegalArgumentException("Image type not yet supported "+inputA.getClass().getSimpleName());
		}
	}
984453
private int imageDataSize()
    {
		int size = 0;
    	for(int k = 0; k < imageData.length; k++) {
    		size += imageData[k].length;
    	}   
    	return size;
    }
348250
public static double computeError(GrayF32 imgA, GrayF32 imgB ) {
		final int h = imgA.getHeight();
		final int w = imgA.getWidth();

		double total = 0;

		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				double difference =  Math.abs(imgA.get(x,y)-imgB.get(x,y));
				total += difference;
			}
		}

		return total / (w*h);
	}