Returns the mean pixel intensity value.

@param img Input image.  Not modified.
@return Mean pixel intensity value
557214
public static double mean( InterleavedS32 img ) {
		return sum(img)/(double)(img.width*img.height*img.numBands);
	}
22547
public static double mean( InterleavedU8 img ) {
		return sum(img)/(double)(img.width*img.height*img.numBands);
	}
296362
public static float sum( GrayF32 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
721798
private static int getTrimmedYStart(BufferedImage img) {
    int width = img.getWidth();
    int height = img.getHeight();
    int yStart = height;

    for (int i = 0; i < width; i++) {
      for (int j = 0; j < height; j++) {
        if (img.getRGB(i, j) != Color.WHITE.getRGB() && j < yStart) {
          yStart = j;
          break;
        }
      }
    }

    return yStart;
  }
1307283
@Override
    public ImageSource apply(ImageSource input) {
        final int[][] pixelMatrix = new int[3][3];

        int w = input.getWidth();
        int h = input.getHeight();

        int[][] output = new int[h][w];

        for (int j = 1; j < h - 1; j++) {
            for (int i = 1; i < w - 1; i++) {
                pixelMatrix[0][0] = input.getR(i - 1, j - 1);
                pixelMatrix[0][1] = input.getRGB(i - 1, j);
                pixelMatrix[0][2] = input.getRGB(i - 1, j + 1);
                pixelMatrix[1][0] = input.getRGB(i, j - 1);
                pixelMatrix[1][2] = input.getRGB(i, j + 1);
                pixelMatrix[2][0] = input.getRGB(i + 1, j - 1);
                pixelMatrix[2][1] = input.getRGB(i + 1, j);
                pixelMatrix[2][2] = input.getRGB(i + 1, j + 1);

                int edge = (int) convolution(pixelMatrix);
                int rgb = (edge << 16 | edge << 8 | edge);
                output[j][i] = rgb;
            }
        }

        MatrixSource source = new MatrixSource(output);
        return source;
    }
885174
public static void boundImage( GrayU8 img , int min , int max ) {
		ImplPixelMath.boundImage(img,min,max);
	}
272738
public void setBufferedImage(BufferedImage img) {
        image = img;
        width = img.getWidth();
        height = img.getHeight();
        updateColorArray();
    }
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);
		}
	}
114267
protected static int getBytesPerPixel(Bitmap.Config config) {
        if (config == Bitmap.Config.ARGB_8888) {
            return 4;
        } else if (config == Bitmap.Config.RGB_565) {
            return 2;
        } else if (config == Bitmap.Config.ARGB_4444) {
            return 2;
        } else if (config == Bitmap.Config.ALPHA_8) {
            return 1;
        }
        return 1;
    }
820239
public static float Variance(ImageSource fastBitmap, float mean, int startX, int startY, int width, int height) {

        float sum = 0;
        if (fastBitmap.isGrayscale()) {
            for (int i = startX; i < height; i++) {
                for (int j = startY; j < width; j++) {
                    sum += Math.pow(fastBitmap.getRGB(j, i) - mean, 2);
                }
            }
            return sum / (float) ((width * height) - 1);
        } else {
            throw new IllegalArgumentException("ImageStatistics: Only compute variance in grayscale images.");
        }
    }
169542
public static boolean getF(GrayU8 image, int x, int y) {
		if (image.isInBounds(x, y)) {
			return image.get(x, y) != 0;
		} else {
			return false;
		}
	}
126246
public static void boundImage( GrayF32 img , float min , float max ) {
		ImplPixelMath.boundImage(img,min,max);
	}
444116
public int getUnsignedPixelValue(BufferedImage image, int x, int y) {
		short pixelValue = getPixelValue(image, x, y);
		int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
		return unsignedPixelValue;
	}
143097
public static BufferedImage trim(BufferedImage img) {
    int width = getTrimmedWidth(img);
    int height = getTrimmedHeight(img);
    int xStart = getTrimmedXStart(img);
    int yStart = getTrimmedYStart(img);

    BufferedImage newImg = new BufferedImage(width - xStart, height - yStart, BufferedImage.TYPE_INT_ARGB);
    Graphics g = newImg.createGraphics();
    g.drawImage(img, 0 - xStart, 0 - yStart, null);

    return newImg;
  }
1152311
public static BufferedImage convertToBufferedImage(Image img) {
        BufferedImage buff = createCompatibleTranslucentImage(
                img.getWidth(null), img.getHeight(null));
        Graphics2D g2 = buff.createGraphics();

        try {
            g2.drawImage(img, 0, 0, null);
        } finally {
            g2.dispose();
        }

        return buff;
    }
484513
public static long sum( InterleavedS64 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
226297
private function GetPixelColor(&$img, $x, $y)
		# Author:     James Heinrich
		# Purpose:
		# Param in:
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ( ! is_resource($img))
		{
			return false;
		}

		return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
	}