changes: now Inference engine works fine with the EyeTracking benchmark.
[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
27 public class IntegralImageData {
28
29   
30   private long[][] integral;
31   
32   private int width;
33   
34   private int hegith;
35
36   // private Dimension dimension;
37
38   public IntegralImageData(Image bufferedImage) {
39     this.integral = new long[bufferedImage.getWidth()][bufferedImage.getHeight()];
40     this.width = bufferedImage.getWidth();
41     this.hegith = bufferedImage.getHeight();
42
43     long[][] s = new long[bufferedImage.getWidth()][bufferedImage.getHeight()];
44     for (int y = 0; y < bufferedImage.getHeight(); ++y) {
45       for (int x = 0; x < bufferedImage.getWidth(); ++x) {
46         s[x][y] = (y - 1 < 0 ? 0 : s[x][y - 1]) + (bufferedImage.getBlue(x, y) & 0xff);
47         this.integral[x][y] = (x - 1 < 0 ? 0 : this.integral[x - 1][y]) + s[x][y];
48         // System.out.println("integral ("+x+","+y+")="+integral[x][y]);
49       }
50     }
51
52   }
53
54   public long getIntegralAt( int x,  int y) {
55     return this.integral[x][y];
56   }
57
58   public int getWidth() {
59     return width;
60   }
61
62   public int getHeight() {
63     return hegith;
64   }
65
66 }