Statistics
| Revision:

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

History | View | Annotate | Download (2.99 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
/**
24
 * Proceso del filtro de recorte de colas aplicado al tipo de datos byte
25
 * @author Nacho Brodin (nachobrodin@gmail.com)
26
 *
27
 */
28
public class TailTrimByteFilter extends TailTrimFilter {
29
        
30
        /**
31
         * Array con el resultado. La primera dimensi?n es el n?mero de bandas y la segunda son dos elementos 
32
         * el m?ximo y el m?nimo para esa banda.
33
         */
34
        private double[][]                        result = null;
35
        
36
    public TailTrimByteFilter() {
37
    }
38

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

    
49
    /**
50
     * Carga sobre el vector de muestras los valores de estas cogidos
51
     * de la imagen
52
     */
53
    public void process(int col, int line) {
54
            for(int iBand = 0 ; iBand < raster.getBandCount() ; iBand ++)
55
                        sample[iBand][count] = raster.getElemByte(line, col, iBand); 
56
        count++;
57
    }
58
    
59
    /* (non-Javadoc)
60
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
61
     */
62
    public int getInRasterDataType() {
63
        return IBuffer.TYPE_BYTE;
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
68
     */
69
    public int getOutRasterDataType() {
70
        return IBuffer.TYPE_BYTE;
71
    }
72

    
73
    /* (non-Javadoc)
74
     * @see org.cresques.io.raster.IRasterFilter#post()
75
     */
76
    public void post() {
77
        super.post();
78

    
79
        //Ordenamos los elementos y cogemos el minimo y m?ximo para cada banda
80
        for (int i = 0; i < raster.getBandCount(); i++) {
81
                result[i][0] = sample[i][posInit + tailSize];
82
                result[i][1] = sample[i][(posInit + nSamples) - tailSize - 1];
83
        }
84
        stats.setTailTrimValue(tailPercent, result);
85
    }
86
    
87
    /**
88
     * Obtiene el objeto con el m?ximo y m?nimo calculado
89
     */
90
    public Object getResult(String name) {
91
            if (name.equals("raster"))
92
            return (Object) this.raster;
93
        else
94
            return result;
95
    }
96
}