svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / LinearEnhancementFilter.java @ 2312
History | View | Annotate | Download (3.42 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 |
|
27 |
/**
|
28 |
* Clase base para los filtros de realzado lineal. Lee el m?nimo y m?xmo de la clase
|
29 |
* RasterStats que ser?n calculados por PercentTailTrimFilter o ComputeMinMaxFilter dependiendo
|
30 |
* de si est? activado el recorte de colas o no. En RasterStats tambi?n est?n los segundos
|
31 |
* valores despu?s del m?nimo y m?ximo que son los que se utilizan con la opci?n eliminar
|
32 |
* extremos activada. Estos se usaran en vez del m?nimo y m?ximo cuando la variable
|
33 |
* removeExtrema est? a true.
|
34 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
35 |
*/
|
36 |
public abstract class LinearEnhancementFilter extends RasterFilter { |
37 |
protected double [] scale = new double[3]; |
38 |
protected double [] offset = new double[3]; |
39 |
protected int [] minBandValue = null; |
40 |
protected int [] maxBandValue = null; |
41 |
protected boolean removeExtrema = false; |
42 |
protected String filename = null; |
43 |
|
44 |
/**
|
45 |
* Constructor
|
46 |
*
|
47 |
*/
|
48 |
public LinearEnhancementFilter(){
|
49 |
super();
|
50 |
} |
51 |
|
52 |
/* (non-Javadoc)
|
53 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
54 |
*/
|
55 |
public void pre(){ |
56 |
if(removeExtrema){ //Si est? activado eliminar extremos gastamos el 2? m?ximo/m?nimo |
57 |
if(filename!=null && !filename.equals("")){ |
58 |
for(int i=0;i<stats.history.size();i++){ |
59 |
RasterStats.History history = (RasterStats.History)stats.history.get(i); |
60 |
if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){ |
61 |
this.minBandValue = history.secMin;
|
62 |
this.maxBandValue = history.secMax;
|
63 |
} |
64 |
} |
65 |
} |
66 |
if(this.minBandValue == null || this.maxBandValue == null){ |
67 |
this.minBandValue = stats.secondMinBandValue;
|
68 |
this.maxBandValue = stats.secondMaxBandValue;
|
69 |
} |
70 |
}else{ //Si no est? activado eliminar extremos |
71 |
if(filename!=null && !filename.equals("")){ |
72 |
for(int i=0;i<stats.history.size();i++){ |
73 |
RasterStats.History history = (RasterStats.History)stats.history.get(i); |
74 |
if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){ |
75 |
this.minBandValue = history.min;
|
76 |
this.maxBandValue = history.max;
|
77 |
} |
78 |
} |
79 |
} |
80 |
if(this.minBandValue == null || this.maxBandValue == null){ |
81 |
this.minBandValue = stats.minBandValue;
|
82 |
this.maxBandValue = stats.maxBandValue;
|
83 |
} |
84 |
} |
85 |
for (int i=0; i<3; i++) { |
86 |
scale[i] = 255D/(maxBandValue[i]-minBandValue[i]);
|
87 |
offset[i] = (255D*minBandValue[i])/(minBandValue[i]-maxBandValue[i]);
|
88 |
} |
89 |
} |
90 |
|
91 |
/**
|
92 |
* Obtiene true si est? activado el flag de eliminar extremos y false si no lo est?
|
93 |
*/
|
94 |
public Boolean getRemoveExtrema(){ |
95 |
return new Boolean(removeExtrema); |
96 |
} |
97 |
} |
98 |
|