Statistics
| Revision:

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

History | View | Annotate | Download (2.75 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 java.util.Arrays;
22

    
23
import org.gvsig.raster.dataset.IBuffer;
24

    
25

    
26

    
27
/**
28
 * Proceso del filtro de recorte de colas aplicado a im?genes 16 bits
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 *
31
 */
32
public class TailTrimShortFilter extends TailTrimFilter {
33

    
34
    public TailTrimShortFilter() {
35
    }
36

    
37
    /* (non-Javadoc)
38
     * @see org.cresques.io.raster.IRasterFilter#pre()
39
     */
40
    public void pre() {
41
        super.pre();
42
        sample = new int[raster.getBandCount()][nSamples];
43
        result = new double[raster.getBandCount()][2];
44
    }
45

    
46
    /* (non-Javadoc)
47
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
48
     */
49
    public void process(int col, int line) {
50
            for(int iBand = 0 ; iBand < raster.getBandCount() ; iBand ++)
51
                        sample[iBand][count] = raster.getElemShort(line, col, iBand); 
52
        count++;
53
    }
54
    
55
    /* (non-Javadoc)
56
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
57
     */
58
    public int getInRasterDataType() {
59
        return IBuffer.TYPE_SHORT;
60
    }
61

    
62
    /* (non-Javadoc)
63
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
64
     */
65
    public int getOutRasterDataType() {
66
        return IBuffer.TYPE_SHORT;
67
    }
68

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

    
79
    /*
80
     *  (non-Javadoc)
81
     * @see org.gvsig.fmap.grid.filter.IRasterFilter#post()
82
     */
83
    public void post() {
84
             super.post();
85
             
86
             //Cogemos el minimo y m?ximo para cada banda
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 - 1];
90
         }
91
         stats.setTailTrimValue(tailPercent, result);
92
    }
93
}