root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / statistics / TailTrimShortFilter.java @ 19355
History | View | Annotate | Download (3.01 KB)
1 | 10740 | nacho | /* 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 | 10939 | nacho | import org.gvsig.raster.dataset.IBuffer; |
22 | 10740 | nacho | /**
|
23 | * Proceso del filtro de recorte de colas aplicado a im?genes 16 bits
|
||
24 | 11915 | bsanchez | * @version 31/05/2007
|
25 | 10756 | nacho | * @author Nacho Brodin (nachobrodin@gmail.com)
|
26 | 10740 | nacho | */
|
27 | public class TailTrimShortFilter extends TailTrimFilter { |
||
28 | |||
29 | 11915 | bsanchez | public TailTrimShortFilter() {
|
30 | } |
||
31 | 10740 | nacho | |
32 | 11921 | bsanchez | /*
|
33 | * (non-Javadoc)
|
||
34 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#pre()
|
||
35 | 11915 | bsanchez | */
|
36 | public void pre() { |
||
37 | super.pre();
|
||
38 | sample = new int[raster.getBandCount()][nSamples]; |
||
39 | result = new double[raster.getBandCount()][2]; |
||
40 | } |
||
41 | 10740 | nacho | |
42 | 11921 | bsanchez | /*
|
43 | * (non-Javadoc)
|
||
44 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#process(int, int)
|
||
45 | 11915 | bsanchez | */
|
46 | public void process(int col, int line) { |
||
47 | for (int iBand = 0; iBand < raster.getBandCount(); iBand++) |
||
48 | sample[iBand][count] = raster.getElemShort(line, col, iBand); |
||
49 | count++; |
||
50 | } |
||
51 | 10740 | nacho | |
52 | 11921 | bsanchez | /*
|
53 | * (non-Javadoc)
|
||
54 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getInRasterDataType()
|
||
55 | 11915 | bsanchez | */
|
56 | public int getInRasterDataType() { |
||
57 | return IBuffer.TYPE_SHORT;
|
||
58 | } |
||
59 | 10740 | nacho | |
60 | 11921 | bsanchez | /*
|
61 | * (non-Javadoc)
|
||
62 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getOutRasterDataType()
|
||
63 | 11915 | bsanchez | */
|
64 | public int getOutRasterDataType() { |
||
65 | return IBuffer.TYPE_SHORT;
|
||
66 | } |
||
67 | 10740 | nacho | |
68 | 11915 | bsanchez | /*
|
69 | 11921 | bsanchez | * (non-Javadoc)
|
70 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getResult(java.lang.String)
|
||
71 | 11915 | bsanchez | */
|
72 | public Object getResult(String name) { |
||
73 | if (name.equals("raster")) |
||
74 | return raster;
|
||
75 | return result;
|
||
76 | } |
||
77 | |||
78 | /*
|
||
79 | 11921 | bsanchez | * (non-Javadoc)
|
80 | * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#post()
|
||
81 | 11915 | bsanchez | */
|
82 | public void post() { |
||
83 | super.post();
|
||
84 | |||
85 | //Cogemos el minimo y m?ximo para cada banda
|
||
86 | for (int i = 0; i < raster.getBandCount(); i++) { |
||
87 | result[i][0] = sample[i][posInit + tailSize];
|
||
88 | result[i][1] = sample[i][(posInit + nSamples) - tailSize];
|
||
89 | } |
||
90 | stats.setTailTrimValue(tailPercent, result); |
||
91 | 19355 | nbrodin | |
92 | //Cogemos el minimo y m?ximo para cada banda
|
||
93 | for (int iValue = 0; iValue < tailSizeList.length; iValue++) { |
||
94 | for (int i = 0; i < raster.getBandCount(); i++) { |
||
95 | result[i][0] = sample[i][posInit + tailSizeList[iValue]];
|
||
96 | result[i][1] = sample[i][(posInit + nSamples) - tailSizeList[iValue]];
|
||
97 | } |
||
98 | stats.setTailTrimValue(tailPercent, result); |
||
99 | } |
||
100 | 11915 | bsanchez | } |
101 | } |