Statistics
| Revision:

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

History | View | Annotate | Download (3.29 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 al tipo de datos byte
24
 * @version 31/05/2007
25
 * @author Nacho Brodin (nachobrodin@gmail.com)
26
 */
27
public class TailTrimByteFilter extends TailTrimFilter {
28

    
29
        /**
30
         * Array con el resultado. La primera dimensi?n es el n?mero de bandas y la segunda son dos elementos 
31
         * el m?ximo y el m?nimo para esa banda.
32
         */
33
        private double[][]        result        = null;
34

    
35
        public TailTrimByteFilter() {}
36

    
37
        /**
38
         * Obtiene par?metros para el filtro y obtiene el ancho y alto de
39
         * la imagen sobre la que se aplica el filtro
40
         */
41
        public void pre() {
42
                super.pre();
43
                sample = new int[raster.getBandCount()][nSamples];
44
                result = new double[raster.getBandCount()][2];
45
        }
46

    
47
        /**
48
         * Carga sobre el vector de muestras los valores de estas cogidos
49
         * de la imagen
50
         * @throws InterruptedException 
51
         */
52
        public void process(int col, int line) throws InterruptedException {
53
                for (int iBand = 0; iBand < raster.getBandCount(); iBand++)
54
                        sample[iBand][count] = (raster.getElemByte(line, col, iBand) & 0xff);
55
                count++;
56
        }
57

    
58
        /*
59
         * (non-Javadoc)
60
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getInRasterDataType()
61
         */
62
        public int getInRasterDataType() {
63
                return IBuffer.TYPE_BYTE;
64
        }
65

    
66
        /*
67
         * (non-Javadoc)
68
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#getOutRasterDataType()
69
         */
70
        public int getOutRasterDataType() {
71
                return IBuffer.TYPE_BYTE;
72
        }
73

    
74
        /*
75
         * (non-Javadoc)
76
         * @see org.gvsig.raster.grid.filter.statistics.TailTrimFilter#post()
77
         */
78
        public void post() {
79
                super.post();
80

    
81
                //Cogemos el minimo y m?ximo para cada banda
82
                for (int i = 0; i < raster.getBandCount(); i++) {
83
                        result[i][0] = sample[i][posInit + tailSize];
84
                        result[i][1] = sample[i][(posInit + nSamples) - tailSize];
85
                }
86
                stats.setTailTrimValue(tailPercent, result);
87
                
88
                //Cogemos el minimo y m?ximo para cada banda
89
                for (int iValue = 0; iValue < tailSizeList.length; iValue++) {
90
                        double [][] res = new double[raster.getBandCount()][2];
91
                        for (int i = 0; i < raster.getBandCount(); i++) {
92
                                res[i][0] = sample[i][posInit + tailSizeList[iValue]];
93
                                res[i][1] = sample[i][(posInit + nSamples) - tailSizeList[iValue]];
94
                        }
95
                        stats.setTailTrimValue(tailPercentList[iValue], res);
96
                }
97
        }
98

    
99
        /**
100
         * Obtiene el objeto con el m?ximo y m?nimo calculado
101
         */
102
        public Object getResult(String name) {
103
                if (name.equals("raster"))
104
                        return this.raster;
105
                return null;
106
        }
107
}