Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / statistics / TailTrimShortFilter.java @ 11067

History | View | Annotate | Download (2.73 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 a im?genes 16 bits
25
 * @author Nacho Brodin (nachobrodin@gmail.com)
26
 *
27
 */
28
public class TailTrimShortFilter extends TailTrimFilter {
29

    
30
    public TailTrimShortFilter() {
31
    }
32

    
33
    /* (non-Javadoc)
34
     * @see org.cresques.io.raster.IRasterFilter#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
    /* (non-Javadoc)
43
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
44
     */
45
    public void process(int col, int line) {
46
            for(int iBand = 0 ; iBand < raster.getBandCount() ; iBand ++)
47
                        sample[iBand][count] = raster.getElemShort(line, col, iBand); 
48
        count++;
49
    }
50
    
51
    /* (non-Javadoc)
52
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
53
     */
54
    public int getInRasterDataType() {
55
        return IBuffer.TYPE_SHORT;
56
    }
57

    
58
    /* (non-Javadoc)
59
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
60
     */
61
    public int getOutRasterDataType() {
62
        return IBuffer.TYPE_SHORT;
63
    }
64

    
65
   /*
66
    *  (non-Javadoc)
67
    * @see org.gvsig.fmap.grid.filter.IRasterFilter#getResult(java.lang.String)
68
    */
69
    public Object getResult(String name) {
70
            if(name.equals("raster"))
71
                    return raster;
72
            return result;
73
    }
74

    
75
    /*
76
     *  (non-Javadoc)
77
     * @see org.gvsig.fmap.grid.filter.IRasterFilter#post()
78
     */
79
    public void post() {
80
             super.post();
81
             
82
             //Cogemos el minimo y m?ximo para cada banda
83
         for (int i = 0; i < raster.getBandCount(); i++) {
84
                 result[i][0] = sample[i][posInit + tailSize];
85
                 result[i][1] = sample[i][(posInit + nSamples) - tailSize - 1];
86
         }
87
         stats.setTailTrimValue(tailPercent, result);
88
    }
89
}