2 * Copyright 2009 (c) Florian Frankenberger (darkblue.de)
4 * This file is part of LEA.
6 * LEA is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option) any
11 * LEA is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with LEA. If not, see <http://www.gnu.org/licenses/>.
21 * No description given.
23 * @author Florian Frankenberger
26 public class IntegralImageData {
28 private long[][] integral;
34 // private Dimension dimension;
36 public IntegralImageData(Image bufferedImage) {
37 this.integral = new long[bufferedImage.getWidth()][bufferedImage.getHeight()];
38 this.width = bufferedImage.getWidth();
39 this.hegith = bufferedImage.getHeight();
41 long[][] s = new long[bufferedImage.getWidth()][bufferedImage.getHeight()];
42 for (int y = 0; y < bufferedImage.getHeight(); ++y) {
43 for (int x = 0; x < bufferedImage.getWidth(); ++x) {
44 s[x][y] = (y - 1 < 0 ? 0 : s[x][y - 1]) + (bufferedImage.getBlue(x, y) & 0xff);
45 this.integral[x][y] = (x - 1 < 0 ? 0 : this.integral[x - 1][y]) + s[x][y];
46 // System.out.println("integral ("+x+","+y+")="+integral[x][y]);
52 public long getIntegralAt(int x, int y) {
53 return this.integral[x][y];
56 public int getWidth() {
60 public int getHeight() {
64 public String toString() {