Revision 11182
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetListHistogram.java | ||
---|---|---|
54 | 54 |
* @return histograma |
55 | 55 |
*/ |
56 | 56 |
public Histogram getHistogram()throws FileNotOpenException, RasterDriverException{ |
57 |
if(multiDataset != null) { |
|
57 |
if (multiDataset != null) {
|
|
58 | 58 |
//Obtenemos los histogramas de cada dataset |
59 | 59 |
Histogram[] hList = new Histogram[multiDataset.getDatasetCount()]; |
60 |
double max = Double.MIN_VALUE; |
|
61 |
double min = Double.MAX_VALUE; |
|
60 | 62 |
for (int i = 0; i < hList.length; i++) { |
61 | 63 |
hList[i] = multiDataset.getDataset(i).getHistogram().getHistogram(); |
64 |
if (max < multiDataset.getDataset(i).getHistogram().getMaximum()) |
|
65 |
max = multiDataset.getDataset(i).getHistogram().getMaximum(); |
|
66 |
if (min > multiDataset.getDataset(i).getHistogram().getMinimum()) |
|
67 |
min = multiDataset.getDataset(i).getHistogram().getMinimum(); |
|
62 | 68 |
if (isCanceled() || (hList[i] == null)) |
63 | 69 |
return null; |
64 | 70 |
} |
65 |
|
|
66 |
if(hList[0].getNumBands() == 0) |
|
71 |
|
|
72 |
if (hList[0].getNumBands() == 0)
|
|
67 | 73 |
return null; |
68 | 74 |
|
75 |
histogram = new Histogram(multiDataset.getBandCount(), hList[0].getNumValues(), min, max); |
|
69 | 76 |
|
70 |
histogram = new Histogram(multiDataset.getBandCount(), hList[0].getNumValues()); |
|
71 |
|
|
72 | 77 |
int band = 0; |
73 | 78 |
for (int iDataset = 0; iDataset < hList.length; iDataset++) { |
74 | 79 |
for (int iBand = 0; iBand < hList[iDataset].getNumBands(); iBand++) { |
75 | 80 |
for (int iPxValue = 0; iPxValue < hList[iDataset].getBandLenght(iBand); iPxValue ++) { |
76 | 81 |
if (isCanceled()) |
77 | 82 |
return null; |
78 |
histogram.setHistogramValue(band, iPxValue, hList[iDataset].getHistogramValue(iBand, iPxValue));
|
|
83 |
histogram.setHistogramValueByPos(band, iPxValue, (long) hList[iDataset].getHistogramValueByPos(iBand, iPxValue));
|
|
79 | 84 |
} |
80 | 85 |
band ++; |
81 | 86 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetStatistics.java | ||
---|---|---|
193 | 193 |
*/ |
194 | 194 |
public void calcFullStatistics() throws FileNotOpenException, RasterDriverException{ |
195 | 195 |
long t2; |
196 |
long t1 = new Date().getTime();
|
|
196 |
long t1 = new Date().getTime();
|
|
197 | 197 |
int type = grf.getDataType(); |
198 | 198 |
max = new double[grf.getBandCount()]; |
199 | 199 |
min = new double[grf.getBandCount()]; |
... | ... | |
227 | 227 |
case IBuffer.TYPE_DOUBLE: d = (double[])buf;break; |
228 | 228 |
} |
229 | 229 |
|
230 |
for(int col = 0; col < grf.getWidth(); col ++){ |
|
230 |
for (int col = 0; col < grf.getWidth(); col ++){
|
|
231 | 231 |
double z = (b != null) ? (b[col] & 0xff) : ((s != null) ? (s[col] & 0xffff) : ((i != null) ? (i[col] & 0xffffff) : (f != null) ? f[col] : d[col])); |
232 |
if(line == 0 && col == 0){ |
|
232 |
if (line == 0 && col == 0){
|
|
233 | 233 |
min[iBand] = z; |
234 | 234 |
secondMin[iBand] = z; |
235 | 235 |
max[iBand] = z; |
236 | 236 |
secondMax[iBand] = z; |
237 | 237 |
continue; |
238 | 238 |
} |
239 |
if( min[iBand] > z ){ |
|
239 |
if ( min[iBand] > z ){
|
|
240 | 240 |
secondMin[iBand] = min[iBand]; |
241 | 241 |
min[iBand] = z; |
242 | 242 |
} |
243 | 243 |
|
244 |
if( secondMin[iBand] == min[iBand] && min[iBand] < z) |
|
244 |
if ( secondMin[iBand] == min[iBand] && min[iBand] < z)
|
|
245 | 245 |
secondMin[iBand] = z; |
246 | 246 |
|
247 |
if( max[iBand] < z ){ |
|
247 |
if ( max[iBand] < z ){
|
|
248 | 248 |
secondMax[iBand] = max[iBand]; |
249 | 249 |
max[iBand] = z; |
250 | 250 |
} |
251 | 251 |
|
252 |
if( secondMax[iBand] == max[iBand] && max[iBand] > z) |
|
252 |
if ( secondMax[iBand] == max[iBand] && max[iBand] > z)
|
|
253 | 253 |
secondMax[iBand] = z; |
254 | 254 |
|
255 | 255 |
mean[iBand] += z; |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetHistogram.java | ||
---|---|---|
55 | 55 |
public DatasetHistogram(RasterDataset dataset){ |
56 | 56 |
this.dataset = dataset; |
57 | 57 |
} |
58 |
|
|
58 |
|
|
59 | 59 |
/** |
60 |
* Obtiene el minimo valor de las estadisticas de un histograma. |
|
61 |
* @return double |
|
62 |
*/ |
|
63 |
public double getMinimum() { |
|
64 |
return dataset.getStatistics().getMinimun(); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Obtiene el maximo valor de las estadisticas de un histograma. |
|
69 |
* @return double |
|
70 |
*/ |
|
71 |
public double getMaximum() { |
|
72 |
return dataset.getStatistics().getMaximun(); |
|
73 |
} |
|
74 |
/** |
|
60 | 75 |
* Obtiene el histograma. Si puede conseguirlo del fichero rmf ir? all? a |
61 | 76 |
* buscarlo sino lo calcular?. |
62 | 77 |
* @return histograma |
63 | 78 |
*/ |
64 | 79 |
public Histogram getHistogram() throws FileNotOpenException, RasterDriverException { |
65 | 80 |
try { |
66 |
if (dataset != null) { |
|
81 |
if (dataset != null) { |
|
82 |
|
|
83 |
dataset.getStatistics().calcFullStatistics(); |
|
84 |
|
|
67 | 85 |
if (dataset.getDataType() == IBuffer.TYPE_BYTE) |
68 |
histogram = new Histogram(dataset.getBandCount(), 255); |
|
86 |
histogram = new Histogram(dataset.getBandCount(), 255, dataset.getStatistics().getMinimun(), dataset.getStatistics().getMaximun());
|
|
69 | 87 |
else |
70 |
histogram = new Histogram(dataset.getBandCount(), RasterLibrary.defaultNumberOfClasses); |
|
88 |
histogram = new Histogram(dataset.getBandCount(), RasterLibrary.defaultNumberOfClasses, dataset.getStatistics().getMinimun(), dataset.getStatistics().getMaximun());
|
|
71 | 89 |
|
72 | 90 |
return getHistogramByDataType(); |
73 | 91 |
} |
Also available in: Unified diff