Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.alibaba.simpleimage.analyze.harissurf;
 
 
 public class IntegralImage implements Serializable {
 	private static final long serialVersionUID = 1L;
 
	private float[][] mIntImage;
	private int mWidth = -1;
	private int mHeight = -1;
	public float[][] getValues() {
		return ;
	}
	public int getWidth() {
		return ;
	}
	public int getHeight() {
		return ;
	}
	public float getValue(int columnint row) {
		return [column][row];
	}
	public IntegralImage(BufferedImage input) {
		 = new float[input.getWidth()][input.getHeight()];
		 = [0].length;
		int width = input.getWidth();
		int height = input.getHeight();
		WritableRaster raster = input.getRaster();
		int[] pixel = new int[4];
		float sum;
		for (int y = 0; y < heighty++) {
			sum = 0F;
			for (int x = 0; x < widthx++) {
				raster.getPixel(xypixel);
TODO: FIX LOSS IN PRECISION HERE, DON'T ROUND BEFORE THE DIVISION (OR AFTER, OR AT ALL) This was done to match the C++ version, can be removed after confident that it's working correctly.
				float intensity = Math.round((0.299D * pixel[0] + 0.587D
pixel[1] + 0.114D * pixel[2])) / 255F;
				sum += intensity;
				if (y == 0) {
					[x][y] = sum;
else {
					[x][y] = sum + [x][y - 1];
				}
			}
		}
	}
New to GrepCode? Check out our FAQ X