changes: generated annotated code but it still causes type errors + re-formatting...
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTrackingInfer / IntegralImageData.java
1 /*
2  * Copyright 2009 (c) Florian Frankenberger (darkblue.de)
3  * 
4  * This file is part of LEA.
5  * 
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
9  * later version.
10  * 
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
14  * details.
15  * 
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/>.
18  */
19
20 /**
21  * No description given.
22  * 
23  * @author Florian Frankenberger
24  */
25
26 public class IntegralImageData {
27
28   private long[][] integral;
29
30   private int width;
31
32   private int hegith;
33
34   // private Dimension dimension;
35
36   public IntegralImageData(Image bufferedImage) {
37     this.integral = new long[bufferedImage.getWidth()][bufferedImage.getHeight()];
38     this.width = bufferedImage.getWidth();
39     this.hegith = bufferedImage.getHeight();
40
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]);
47       }
48     }
49
50   }
51
52   public long getIntegralAt(int x, int y) {
53     return this.integral[x][y];
54   }
55
56   public int getWidth() {
57     return width;
58   }
59
60   public int getHeight() {
61     return hegith;
62   }
63
64   public String toString() {
65     super.toString();
66   }
67
68 }