svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / LinearEnhancementFilter.java @ 2167
History | View | Annotate | Download (3.75 KB)
1 |
/*
|
---|---|
2 |
* Created on 17-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package org.cresques.io.raster; |
48 |
|
49 |
|
50 |
/**
|
51 |
* Clase base para los filtros de realzado lineal. Lee el m?nimo y m?xmo de la clase
|
52 |
* RasterStats que ser?n calculados por PercentTailTrimFilter o ComputeMinMaxFilter dependiendo
|
53 |
* de si est? activado el recorte de colas o no. En RasterStats tambi?n est?n los segundos
|
54 |
* valores despu?s del m?nimo y m?ximo que son los que se utilizan con la opci?n eliminar
|
55 |
* extremos activada. Estos se usaran en vez del m?nimo y m?ximo cuando la variable
|
56 |
* removeExtrema est? a true.
|
57 |
*/
|
58 |
public abstract class LinearEnhancementFilter extends RasterFilter { |
59 |
protected double [] scale = new double[3]; |
60 |
protected double [] offset = new double[3]; |
61 |
protected int [] minBandValue = null; |
62 |
protected int [] maxBandValue = null; |
63 |
protected boolean removeExtrema = false; |
64 |
protected String filename = null; |
65 |
|
66 |
public LinearEnhancementFilter(){
|
67 |
super();
|
68 |
} |
69 |
|
70 |
public void pre(){ |
71 |
if(removeExtrema){ //Si est? activado eliminar extremos gastamos el 2? m?ximo/m?nimo |
72 |
if(filename!=null && !filename.equals("")){ |
73 |
for(int i=0;i<stats.history.size();i++){ |
74 |
RasterStats.History history = (RasterStats.History)stats.history.get(i); |
75 |
if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){ |
76 |
this.minBandValue = history.secMin;
|
77 |
this.maxBandValue = history.secMax;
|
78 |
} |
79 |
} |
80 |
} |
81 |
if(this.minBandValue == null || this.maxBandValue == null){ |
82 |
this.minBandValue = stats.secondMinBandValue;
|
83 |
this.maxBandValue = stats.secondMaxBandValue;
|
84 |
} |
85 |
}else{ //Si no est? activado eliminar extremos |
86 |
if(filename!=null && !filename.equals("")){ |
87 |
for(int i=0;i<stats.history.size();i++){ |
88 |
RasterStats.History history = (RasterStats.History)stats.history.get(i); |
89 |
if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){ |
90 |
this.minBandValue = history.min;
|
91 |
this.maxBandValue = history.max;
|
92 |
} |
93 |
} |
94 |
} |
95 |
if(this.minBandValue == null || this.maxBandValue == null){ |
96 |
this.minBandValue = stats.minBandValue;
|
97 |
this.maxBandValue = stats.maxBandValue;
|
98 |
} |
99 |
} |
100 |
for (int i=0; i<3; i++) { |
101 |
scale[i] = 255D/(maxBandValue[i]-minBandValue[i]);
|
102 |
offset[i] = (255D*minBandValue[i])/(minBandValue[i]-maxBandValue[i]);
|
103 |
} |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Obtiene true si est? activado el flag de eliminar extremos y false si no lo est?
|
108 |
*/
|
109 |
public Boolean getRemoveExtrema(){ |
110 |
return new Boolean(removeExtrema); |
111 |
} |
112 |
} |
113 |
|