Revision 5486 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/statistics/DefaultStatisticsBand.java
DefaultStatisticsBand.java | ||
---|---|---|
11 | 11 |
*/ |
12 | 12 |
public class DefaultStatisticsBand implements StatisticsBand{ |
13 | 13 |
|
14 |
Band band; |
|
14 |
private Band band;
|
|
15 | 15 |
|
16 |
boolean calculated; |
|
16 |
private boolean calculated;
|
|
17 | 17 |
|
18 | 18 |
private double mean; |
19 | 19 |
private double max; |
... | ... | |
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
@Override |
42 |
public void calculate(double scale, SimpleTaskStatus status) {
|
|
42 |
public void calculate(SimpleTaskStatus status) { |
|
43 | 43 |
calculated = false; |
44 | 44 |
|
45 | 45 |
MeanOperation meanOperation = new MeanOperation(); |
... | ... | |
173 | 173 |
} |
174 | 174 |
|
175 | 175 |
|
176 |
@Override |
|
177 |
public double getCovariance(StatisticsBand statisticBand) { |
|
178 |
Band otherBand = ((DefaultStatisticsBand)statisticBand).getBand(); //FIXME: OJO |
|
179 |
long otherBandLenght = statisticBand.getBandLenght(); |
|
176 | 180 |
|
181 |
if(getBandLenght()!=otherBandLenght){ |
|
182 |
return 0; |
|
183 |
} |
|
184 |
|
|
185 |
MeanOperation productMeanOperation = new MeanOperation(); |
|
186 |
|
|
187 |
productMeanOperation.pre(); |
|
188 |
|
|
189 |
for(int row=0; row<band.getRows(); row++){ |
|
190 |
for(int column=0; column<band.getColumns(); column++){ |
|
191 |
Object obj = band.get(row, column); |
|
192 |
Object obj2 = otherBand.get(row, column); |
|
193 |
if(obj instanceof Number && obj2 instanceof Number){ |
|
194 |
double value = ((Number)obj).doubleValue() * ((Number)obj2).doubleValue(); |
|
195 |
productMeanOperation.addValue(value); |
|
196 |
} |
|
197 |
} |
|
198 |
} |
|
199 |
productMeanOperation.post(); |
|
200 |
|
|
201 |
return ((Number)productMeanOperation.getResult()).doubleValue()-(this.getMean()*statisticBand.getMean()); |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
@Override |
|
206 |
public double getMedian() { |
|
207 |
return getHistogramBand().getMedian(); |
|
208 |
} |
|
209 |
|
|
210 |
protected Band getBand() { |
|
211 |
return this.band; |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
|
|
177 | 216 |
} |
Also available in: Unified diff