svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / ComputeMinMaxFilter.java @ 2312
History | View | Annotate | Download (3.28 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.io.raster; |
25 |
|
26 |
import java.awt.Image; |
27 |
|
28 |
/**
|
29 |
* Calcula el m?ximo y el m?nimo de un raster, As? como el segundo menor valor y
|
30 |
* el segundo mayor valor.
|
31 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
32 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
33 |
*/
|
34 |
public abstract class ComputeMinMaxFilter extends RasterFilter { |
35 |
protected int [] min = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE}; |
36 |
protected int [] max = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE}; |
37 |
protected int [] secondMin = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE}; |
38 |
protected int [] secondMax = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE}; |
39 |
protected int [] tmpMin = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE}; |
40 |
protected int [] tmpMax = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE}; |
41 |
|
42 |
/**
|
43 |
* Constructor
|
44 |
*
|
45 |
*/
|
46 |
public ComputeMinMaxFilter(){
|
47 |
super();
|
48 |
} |
49 |
|
50 |
/**
|
51 |
* Operaciones que se realizan antes de la ejecuci?n del filtro
|
52 |
*/
|
53 |
public void pre(){ |
54 |
//Obtenci?n de par?metros comunes a todos
|
55 |
this.stats = (RasterStats)params.get("stats"); |
56 |
this.stats.tailPercent = 0D; |
57 |
|
58 |
//Operaciones del filtro concreto
|
59 |
this.min = new int[stats.minBandValue.length]; |
60 |
this.max = new int[stats.maxBandValue.length]; |
61 |
this.secondMin = new int[stats.minBandValue.length]; |
62 |
this.secondMax = new int[stats.maxBandValue.length]; |
63 |
this.tmpMin = new int[stats.minBandValue.length]; |
64 |
this.tmpMax = new int[stats.maxBandValue.length]; |
65 |
for (int i=0; i<min.length; i++) { |
66 |
secondMin[i] = tmpMin[i] = min[i] = Integer.MAX_VALUE;
|
67 |
secondMax[i] = tmpMax[i] = max[i] = Integer.MIN_VALUE;
|
68 |
} |
69 |
} |
70 |
|
71 |
/**
|
72 |
* Operaciones que se realizan despu?s de la ejecuci?n del filtro
|
73 |
*/
|
74 |
public void post(){ |
75 |
|
76 |
for (int i=0; i<3; i++) { |
77 |
stats.minBandValue[i] = min[i]; |
78 |
stats.maxBandValue[i] = max[i]; |
79 |
stats.secondMinBandValue[i] = secondMin[i]; |
80 |
stats.secondMaxBandValue[i] = secondMax[i]; |
81 |
} |
82 |
} |
83 |
|
84 |
/**
|
85 |
* Obtiene le m?nimo para una banda dada
|
86 |
* @param bandNr banda
|
87 |
* @return valor m?nimo
|
88 |
*/
|
89 |
public int getMin(int bandNr) { |
90 |
return min[bandNr];
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* Obtiene el m?ximo para una banda dada
|
95 |
* @param bandNr banda
|
96 |
* @return valor m?ximo
|
97 |
*/
|
98 |
public int getMax(int bandNr) { |
99 |
return max[bandNr];
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* Obtiene el objeto stats con el calculo de m?ximos y m?nimos
|
104 |
*/
|
105 |
public Object getResult(String name){ |
106 |
if(name.equals("stats")) |
107 |
return stats;
|
108 |
else return null; |
109 |
} |
110 |
|
111 |
} |
112 |
|