Statistics
| Revision:

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

History | View | Annotate | Download (2.21 KB)

1 19409 nbrodin
/* 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 EcualizationByteFilter extends EcualizationFilter {
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 19491 nbrodin
                        int p = (int)(raster.getElemByte(line, col, iBand) & 0xff);
37
                        if(!ecualizationActive(iBand)) {
38
                                rasterResult.setElem(line, col, iBand, (byte)p);
39
                                continue;
40
                        }
41
42 19409 nbrodin
                        if (p > maxBandValue[renderBands[iBand]])
43
                                p = (int) maxBandValue[renderBands[iBand]];
44
                        else if (p < minBandValue[renderBands[iBand]])
45
                                p = (int) minBandValue[renderBands[iBand]];
46 19491 nbrodin
47
                        long ecualizationPositive = lahe[renderBands[iBand]][p % histogram.getNumValues()];
48
                        long ecualizationNegative = laheNegative[renderBands[iBand]][nElements - (p % histogram.getNumValues())];
49 19453 nbrodin
                        double value = ((nElements - ecualizationNegative) + ecualizationPositive) / 2;
50
                        rasterResult.setElem(line, col, iBand, (byte)value);
51 19409 nbrodin
                }
52
        }
53
54
        /*
55
         * (non-Javadoc)
56
         * @see org.gvsig.raster.grid.filter.enhancement.LinearEnhancementFilter#getInRasterDataType()
57
         */
58
        public int getInRasterDataType() {
59
                return IBuffer.TYPE_BYTE;
60
        }
61
}