Revision 11181
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/cache/PageBuffer.java | ||
---|---|---|
412 | 412 |
public void switchBands(int[] bands) { |
413 | 413 |
} |
414 | 414 |
|
415 |
/* |
|
416 |
* (non-Javadoc) |
|
417 |
* @see org.gvsig.raster.driver.datasetproperties.IHistogramable#getHistogram() |
|
418 |
*/ |
|
415 |
/** |
|
416 |
* Calcula el m?nimo y el m?ximo del histograma previamente. |
|
417 |
* @return double[] con el m?nimo y el m?ximo. |
|
418 |
*/ |
|
419 |
private double[] getLimits() { |
|
420 |
double max = Double.MIN_VALUE; |
|
421 |
double min = Double.MAX_VALUE; |
|
422 |
double value = 0; |
|
423 |
|
|
424 |
switch (getDataType()) { |
|
425 |
case IBuffer.TYPE_BYTE: |
|
426 |
for (int i = 0; i < getBandCount(); i++) |
|
427 |
for (int r = 0; r < getHeight(); r++) |
|
428 |
for (int c = 0; c < getWidth(); c++) { |
|
429 |
value = (double) (getElemByte(r, c, i) & 0xff); |
|
430 |
if (value > max) max = value; |
|
431 |
if (value < min) min = value; |
|
432 |
} |
|
433 |
break; |
|
434 |
case IBuffer.TYPE_SHORT: |
|
435 |
for (int i = 0; i < getBandCount(); i++) |
|
436 |
for (int r = 0; r < getHeight(); r++) |
|
437 |
for (int c = 0; c < getWidth(); c++) { |
|
438 |
value = (double) (getElemShort(r, c, i) & 0xffff); |
|
439 |
if (value > max) max = value; |
|
440 |
if (value < min) min = value; |
|
441 |
} |
|
442 |
break; |
|
443 |
case IBuffer.TYPE_INT: |
|
444 |
for (int i = 0; i < getBandCount(); i++) |
|
445 |
for (int r = 0; r < getHeight(); r++) |
|
446 |
for (int c = 0; c < getWidth(); c++) { |
|
447 |
value = (double) (getElemInt(r, c, i) & 0xffffffff); |
|
448 |
if (value > max) max = value; |
|
449 |
if (value < min) min = value; |
|
450 |
} |
|
451 |
break; |
|
452 |
case IBuffer.TYPE_FLOAT: |
|
453 |
for (int i = 0; i < getBandCount(); i++) |
|
454 |
for (int r = 0; r < getHeight(); r++) |
|
455 |
for (int c = 0; c < getWidth(); c++) { |
|
456 |
value = (double) getElemFloat(r, c, i); |
|
457 |
if (value > max) max = value; |
|
458 |
if (value < min) min = value; |
|
459 |
} |
|
460 |
break; |
|
461 |
case IBuffer.TYPE_DOUBLE: |
|
462 |
for (int i = 0; i < getBandCount(); i++) |
|
463 |
for (int r = 0; r < getHeight(); r++) |
|
464 |
for (int c = 0; c < getWidth(); c++) { |
|
465 |
value = getElemDouble(r, c, i); |
|
466 |
if (value > max) max = value; |
|
467 |
if (value < min) min = value; |
|
468 |
} |
|
469 |
break; |
|
470 |
} |
|
471 |
double[] values = new double[2]; |
|
472 |
values[0] = min; |
|
473 |
values[1] = max; |
|
474 |
return values; |
|
475 |
} |
|
476 |
|
|
477 |
/* |
|
478 |
* (non-Javadoc) |
|
479 |
* @see org.gvsig.raster.driver.datasetproperties.IHistogramable#getHistogram() |
|
480 |
*/ |
|
419 | 481 |
public Histogram getHistogram() throws HistogramException { |
420 | 482 |
percent = 0; |
421 | 483 |
Histogram hist = null; |
484 |
double[] limits = getLimits(); |
|
485 |
|
|
422 | 486 |
if (getDataType() == IBuffer.TYPE_BYTE) |
423 |
hist = new Histogram(getBandCount(), 255); |
|
487 |
hist = new Histogram(getBandCount(), 255, limits[0], limits[1]);
|
|
424 | 488 |
else |
425 |
hist = new Histogram(getBandCount(), RasterLibrary.defaultNumberOfClasses); |
|
489 |
hist = new Histogram(getBandCount(), RasterLibrary.defaultNumberOfClasses, limits[0], limits[1]);
|
|
426 | 490 |
|
427 | 491 |
for (int iBand = 0; iBand < getBandCount(); iBand++) { |
428 | 492 |
for (int row = 0; row < getHeight(); row++) { |
Also available in: Unified diff