Statistics
| Revision:

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 / TailTrimDoubleFilter.java @ 2308

History | View | Annotate | Download (2.48 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 double
28
 *
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 */
31
public class TailTrimDoubleFilter extends TailTrimFilter {
32

    
33
        public TailTrimDoubleFilter() {}
34

    
35
        public void pre() throws FilterAddException {
36
                super.pre();
37
                sampleDec = new double[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
                        sampleDec[iBand][count] = raster.getElemDouble(line, col, iBand);
44
                count++;
45
        }
46

    
47
        public int getInRasterDataType() {
48
                return Buffer.TYPE_DOUBLE;
49
        }
50

    
51
        public int getOutRasterDataType() {
52
                return Buffer.TYPE_DOUBLE;
53
        }
54

    
55
        public void post() {
56
                super.post();
57

    
58
                //Cogemos el minimo y m?ximo para cada banda
59
                for (int i = 0; i < raster.getBandCount(); i++) {
60
                        result[i][0] = sampleDec[i][posInit + tailSize];
61
                        result[i][1] = sampleDec[i][(posInit + nSamples) - tailSize];
62
                }
63
                stats.setTailTrimValue(tailPercent, result);
64
                
65
                //Cogemos el minimo y m?ximo para cada banda
66
                for (int iValue = 0; iValue < tailSizeList.length; iValue++) {
67
                        double [][] res = new double[raster.getBandCount()][2];
68
                        for (int i = 0; i < raster.getBandCount(); i++) {
69
                                res[i][0] = sampleDec[i][posInit + tailSizeList[iValue]];
70
                                res[i][1] = sampleDec[i][(posInit + nSamples) - tailSizeList[iValue]];
71
                        }
72
                        stats.setTailTrimValue(tailPercentList[iValue], res);
73
                }
74
        }
75
}