Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / enhancement / EcualizationShortFilter.java @ 20652

History | View | Annotate | Download (2.41 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.enhancement;
20

    
21
import org.gvsig.raster.dataset.IBuffer;
22
/**
23
 * Filtro de ecualizaci?n de histograma para tipo de datos short.
24
 *
25
 * @version 11/05/2007
26
 * @author Nacho Brodin (nachobrodin@gmail.com)
27
 */
28
public class EcualizationShortFilter extends EqualizationFilter {
29

    
30
        /*
31
         * (non-Javadoc)
32
         * @see org.gvsig.raster.grid.filter.enhancement.LinearEnhancementFilter#process(int, int)
33
         */
34
        public void process(int col, int line) {
35
                for (int iBand = 0; iBand < raster.getBandCount(); iBand++) {
36
                        short p = raster.getElemShort(line, col, iBand);
37
                        if(!equalizationActive(iBand)) {
38
                                rasterResult.setElem(line, col, iBand, p);
39
                                continue;
40
                        }
41
                        
42
                        if (p > maxBandValue[renderBands[iBand]])
43
                                p = (short) maxBandValue[renderBands[iBand]];
44
                        else if (p < minBandValue[renderBands[iBand]])
45
                                p = (short) minBandValue[renderBands[iBand]];
46
                
47
                        int ecualizationPositive = (int)(aproximation[renderBands[iBand]][p % nClasses] * nClasses);
48
                        int ecualizationNegative = (int)(aproximationNeg[renderBands[iBand]][nElements - (p  % nClasses)] * nClasses);
49
                        double value = ((nElements - ecualizationNegative) + ecualizationPositive) / 2;
50
                        
51
                        rasterResult.setElem(line, col, iBand, (short)value);
52
                }
53
        }
54

    
55
        /*
56
         * (non-Javadoc)
57
         * @see org.gvsig.raster.grid.filter.enhancement.LinearEnhancementFilter#getInRasterDataType()
58
         */
59
        public int getInRasterDataType() {
60
                return IBuffer.TYPE_SHORT;
61
        }
62
        
63
        /*
64
         * (non-Javadoc)
65
         * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
66
         */
67
        public int getOutRasterDataType() {
68
                return IBuffer.TYPE_SHORT;
69
        }
70
}