Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / statistics / TailTrimShortFilter.java @ 27361

History | View | Annotate | Download (3.17 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
 * Proceso del filtro de recorte de colas aplicado a im?genes 16 bits
24
 * @version 31/05/2007
25
 * @author Nacho Brodin (nachobrodin@gmail.com)
26
 */
27
public class TailTrimShortFilter extends TailTrimFilter {
28

    
29
        public TailTrimShortFilter() {
30
        }
31

    
32
        /*
33
         * (non-Javadoc)
34
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#pre()
35
         */
36
        public void pre() {
37
                super.pre();
38
                sample = new int[raster.getBandCount()][nSamples];
39
                result = new double[raster.getBandCount()][2];
40
        }
41

    
42
        /*
43
         * (non-Javadoc)
44
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#process(int, int)
45
         */
46
        public void process(int col, int line) throws InterruptedException {
47
                for (int iBand = 0; iBand < raster.getBandCount(); iBand++)
48
                        sample[iBand][count] = raster.getElemShort(line, col, iBand);
49
                count++;
50
        }
51

    
52
        /*
53
         * (non-Javadoc)
54
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getInRasterDataType()
55
         */
56
        public int getInRasterDataType() {
57
                return IBuffer.TYPE_SHORT;
58
        }
59

    
60
        /*
61
         * (non-Javadoc)
62
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getOutRasterDataType()
63
         */
64
        public int getOutRasterDataType() {
65
                return IBuffer.TYPE_SHORT;
66
        }
67

    
68
 /*
69
        * (non-Javadoc)
70
        * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getResult(java.lang.String)
71
        */
72
        public Object getResult(String name) {
73
                if (name.equals("raster"))
74
                        return raster;
75
                return null;
76
        }
77

    
78
        /*
79
         * (non-Javadoc)
80
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#post()
81
         */
82
        public void post() {
83
                super.post();
84

    
85
                //Cogemos el minimo y m?ximo para cada banda
86
                if(tailPercentList == null) {
87
                        for (int i = 0; i < raster.getBandCount(); i++) {
88
                                result[i][0] = sample[i][posInit + tailSize];
89
                                result[i][1] = sample[i][(posInit + nSamples) - tailSize];
90
                        }
91
                        stats.setTailTrimValue(tailPercent, result);
92
                }
93
                
94
                if(tailPercentList == null)
95
                        return;
96
                
97
                //Cogemos el minimo y m?ximo para cada banda
98
                for (int iValue = 0; iValue < tailSizeList.length; iValue++) {
99
                        double [][] res = new double[raster.getBandCount()][2];
100
                        for (int i = 0; i < raster.getBandCount(); i++) {
101
                                res[i][0] = sample[i][posInit + tailSizeList[iValue]];
102
                                res[i][1] = sample[i][(posInit + nSamples) - tailSizeList[iValue]];
103
                        }
104
                        stats.setTailTrimValue(tailPercentList[iValue], res);
105
                }
106
        }
107
}