Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / raster / LinearEnhancementShortFilter.java @ 4578

History | View | Annotate | Download (3.24 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io.raster;
25

    
26

    
27
/**
28
 * Realzado Lineal (Amplitude Rescaling) para imagenes de 16 bits.
29
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
30
 * @author Nacho Brodin (brodin_ign@gva.es)
31
 */
32
public class LinearEnhancementShortFilter extends LinearEnhancementFilter {
33
    /**
34
     * Constructor
35
     */
36
    public LinearEnhancementShortFilter() {
37
        super();
38
    }
39

    
40
    /* (non-Javadoc)
41
     * @see org.cresques.io.raster.IRasterFilter#pre()
42
     */
43
    public void pre() {
44
        //Obtenci?n de par?metros
45
        this.raster = (RasterBuf) params.get("raster");
46
        this.stats = (RasterStats) params.get("stats");
47
        this.removeExtrema = ((Boolean) params.get("remove")).booleanValue();
48
        this.filename = (String) params.get("filename");
49
        height = raster.getHeight();
50
        width = raster.getWidth();
51
        super.pre();
52
    }
53

    
54
    /* (non-Javadoc)
55
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
56
     */
57
    public void process(int x, int y) {
58
        raster.getElemInt(x, y, px);
59

    
60
        int bandsCnt = 3; // Esto hay que sacarlo de fuera, l?gicamente.
61

    
62
        for (int i = 0; i < bandsCnt; i++) {
63
            if (px[i] > maxBandValue[i]) {
64
                px[i] = maxBandValue[i];
65
            } else if (px[i] < minBandValue[i]) {
66
                px[i] = minBandValue[i];
67
            }
68

    
69
            px[i] = (((int) ((((double) px[i]) * scale[i]) + offset[i])) &
70
                    0xff);
71
        }
72

    
73
        raster.setElemInt(x, y, px);
74
    }
75

    
76
    /* (non-Javadoc)
77
     * @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
78
     */
79
    public Object getResult(String name) {
80
        if (name.equals("raster")) {
81
            return (Object) this.raster;
82
        } else {
83
            return null;
84
        }
85
    }
86

    
87
    /* (non-Javadoc)
88
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
89
     */
90
    public int getInRasterDataType() {
91
        return RasterBuf.TYPE_SHORT;
92
    }
93

    
94
    /* (non-Javadoc)
95
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
96
     */
97
    public int getOutRasterDataType() {
98
        return RasterBuf.TYPE_SHORT;
99
    }
100

    
101
    /* (non-Javadoc)
102
     * @see org.cresques.io.raster.IRasterFilter#post()
103
     */
104
    public void post() {
105
    }
106

    
107
    /* (non-Javadoc)
108
     * @see org.cresques.io.raster.RasterFilter#processLine(int)
109
     */
110
    public void processLine(int y) {
111
    }
112
}