gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / statistics / TailTrimShortFilter.java @ 2308
History | View | Annotate | Download (2.54 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.grid.filter.statistics; |
23 |
|
24 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
25 |
import org.gvsig.fmap.dal.coverage.exception.FilterAddException; |
26 |
/**
|
27 |
* Proceso del filtro de recorte de colas aplicado a im?genes 16 bits
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
29 |
*/
|
30 |
public class TailTrimShortFilter extends TailTrimFilter { |
31 |
|
32 |
public TailTrimShortFilter() {
|
33 |
} |
34 |
|
35 |
public void pre() throws FilterAddException { |
36 |
super.pre();
|
37 |
sample = new int[raster.getBandCount()][nSamples]; |
38 |
result = new double[raster.getBandCount()][2]; |
39 |
} |
40 |
|
41 |
public void process(int col, int line) { |
42 |
for (int iBand = 0; iBand < raster.getBandCount(); iBand++) |
43 |
sample[iBand][count] = raster.getElemShort(line, col, iBand); |
44 |
count++; |
45 |
} |
46 |
|
47 |
public int getInRasterDataType() { |
48 |
return Buffer.TYPE_SHORT; |
49 |
} |
50 |
|
51 |
public int getOutRasterDataType() { |
52 |
return Buffer.TYPE_SHORT; |
53 |
} |
54 |
|
55 |
public void post() { |
56 |
super.post();
|
57 |
|
58 |
//Cogemos el minimo y m?ximo para cada banda
|
59 |
if(tailPercentList == null) { |
60 |
for (int i = 0; i < raster.getBandCount(); i++) { |
61 |
result[i][0] = sample[i][posInit + tailSize];
|
62 |
result[i][1] = sample[i][(posInit + nSamples) - tailSize];
|
63 |
} |
64 |
stats.setTailTrimValue(tailPercent, result); |
65 |
} |
66 |
|
67 |
if(tailPercentList == null) |
68 |
return;
|
69 |
|
70 |
//Cogemos el minimo y m?ximo para cada banda
|
71 |
for (int iValue = 0; iValue < tailSizeList.length; iValue++) { |
72 |
double [][] res = new double[raster.getBandCount()][2]; |
73 |
for (int i = 0; i < raster.getBandCount(); i++) { |
74 |
res[i][0] = sample[i][posInit + tailSizeList[iValue]];
|
75 |
res[i][1] = sample[i][(posInit + nSamples) - tailSizeList[iValue]];
|
76 |
} |
77 |
stats.setTailTrimValue(tailPercentList[iValue], res); |
78 |
} |
79 |
} |
80 |
} |