Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRaster / src / org / gvsig / raster / grid / filter / enhancement / EqualizationByteFilter.java @ 29786

History | View | Annotate | Download (2.34 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.
24
 *
25
 * @version 11/05/2007
26
 * @author Nacho Brodin (nachobrodin@gmail.com)
27
 */
28
public class EqualizationByteFilter 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
                        int p = (int)(raster.getElemByte(line, col, iBand) & 0xff);
37
                        if(!equalizationActive(iBand)) {
38
                                rasterResult.setElem(line, col, iBand, (byte)p);
39
                                continue;
40
                        }
41
                        
42
                        //Las estad?sticas est?n calculadas para todas las bandas por lo que hay que seleccionar solo las que se renderiza
43
                        if (p > maxBandValue[renderBands[iBand]])
44
                                p = (int) maxBandValue[renderBands[iBand]];
45
                        else if (p < minBandValue[renderBands[iBand]])
46
                                p = (int) minBandValue[renderBands[iBand]];
47

    
48
                        //M?todo lahe
49
                        int ecualizationPositive = (int)lahe[iBand][p % histogram.getNumValues()];
50
                        int ecualizationNegative = (int)laheNegative[iBand][nElements - (p % histogram.getNumValues())];
51
                        
52
                        int value = ((nElements - ecualizationNegative) + ecualizationPositive) / 2;
53
                        rasterResult.setElem(line, col, iBand, (byte)(value & 0x000000ff));
54
                }
55
        }
56

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