svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / statistics / TailTrimShortFilter.java @ 11183
History | View | Annotate | Download (2.73 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.grid.filter.statistics; |
20 |
|
21 |
import org.gvsig.raster.dataset.IBuffer; |
22 |
|
23 |
|
24 |
|
25 |
/**
|
26 |
* Proceso del filtro de recorte de colas aplicado a im?genes 16 bits
|
27 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
28 |
*
|
29 |
*/
|
30 |
public class TailTrimShortFilter extends TailTrimFilter { |
31 |
|
32 |
public TailTrimShortFilter() {
|
33 |
} |
34 |
|
35 |
/* (non-Javadoc)
|
36 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
37 |
*/
|
38 |
public void pre() { |
39 |
super.pre();
|
40 |
sample = new int[raster.getBandCount()][nSamples]; |
41 |
result = new double[raster.getBandCount()][2]; |
42 |
} |
43 |
|
44 |
/* (non-Javadoc)
|
45 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int)
|
46 |
*/
|
47 |
public void process(int col, int line) { |
48 |
for(int iBand = 0 ; iBand < raster.getBandCount() ; iBand ++) |
49 |
sample[iBand][count] = raster.getElemShort(line, col, iBand); |
50 |
count++; |
51 |
} |
52 |
|
53 |
/* (non-Javadoc)
|
54 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
55 |
*/
|
56 |
public int getInRasterDataType() { |
57 |
return IBuffer.TYPE_SHORT;
|
58 |
} |
59 |
|
60 |
/* (non-Javadoc)
|
61 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
62 |
*/
|
63 |
public int getOutRasterDataType() { |
64 |
return IBuffer.TYPE_SHORT;
|
65 |
} |
66 |
|
67 |
/*
|
68 |
* (non-Javadoc)
|
69 |
* @see org.gvsig.fmap.grid.filter.IRasterFilter#getResult(java.lang.String)
|
70 |
*/
|
71 |
public Object getResult(String name) { |
72 |
if(name.equals("raster")) |
73 |
return raster;
|
74 |
return result;
|
75 |
} |
76 |
|
77 |
/*
|
78 |
* (non-Javadoc)
|
79 |
* @see org.gvsig.fmap.grid.filter.IRasterFilter#post()
|
80 |
*/
|
81 |
public void post() { |
82 |
super.post();
|
83 |
|
84 |
//Cogemos el minimo y m?ximo para cada banda
|
85 |
for (int i = 0; i < raster.getBandCount(); i++) { |
86 |
result[i][0] = sample[i][posInit + tailSize];
|
87 |
result[i][1] = sample[i][(posInit + nSamples) - tailSize - 1]; |
88 |
} |
89 |
stats.setTailTrimValue(tailPercent, result); |
90 |
} |
91 |
} |