Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / filter / enhancement / LinearEnhancementIntegerFilter.java @ 8026

History | View | Annotate | Download (3.14 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.filter.enhancement;
25

    
26
import org.cresques.io.data.RasterBuf;
27
import org.cresques.io.datastruct.Statistic;
28

    
29
/**
30
 * Realzado Lineal (Amplitude Rescaling) para imagenes de 32 bits.
31
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
32
 * @author Nacho Brodin (brodin_ign@gva.es)
33
 */
34
public class LinearEnhancementIntegerFilter extends LinearEnhancementFilter {
35
        private int[]                 px = new int[4];
36
        private int                         bandsCnt = 3;
37
        
38
        public void post() {
39
                // TODO Auto-generated method stub
40

    
41
        }
42

    
43
        public void process(int col, int line) {
44
        raster.getElemInt(line, col, px);
45
        px = calcLinearEnhancement(px);
46
        raster.setElemInt(line, col, px);
47

    
48
        }
49

    
50
        public void processSuperSampling(int col, int line) {
51
                raster.getElemInt(line, col, px);
52
        px = calcLinearEnhancement(px);
53
                for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++)
54
                        for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++)
55
                                 raster.setElemInt(i, j, px);
56
        }
57

    
58
        public void processLine(int y) {
59
                // TODO Auto-generated method stub
60

    
61
        }
62

    
63
        public int getInRasterDataType() {
64
                return RasterBuf.TYPE_INT;
65
        }
66

    
67
        public int getOutRasterDataType() {
68
                return RasterBuf.TYPE_INT;
69
        }
70

    
71
        public Object getResult(String name) {
72
                 if (name.equals("raster")) {
73
                    return (Object) this.raster;
74
                } else {
75
                    return null;
76
                }
77
        }
78

    
79
        public void pre() {
80
//                Obtenci?n de par?metros
81
        this.raster = (RasterBuf) params.get("raster");
82
        this.stats = (Statistic) params.get("stats");
83
        this.removeExtrema = ((Boolean) params.get("remove")).booleanValue();
84
        this.filename = (String) params.get("filename");
85
        height = raster.getHeight();
86
        width = raster.getWidth();
87
        super.pre();
88
        }
89
        
90
        /**
91
     * Calculo del realce
92
     * @param pt pixel
93
     * @return pixel con el calculo de realce aplicado
94
     */
95
    private int[] calcLinearEnhancement(int[] px){
96
            for (int i = 0; i < bandsCnt; i++) {
97
            if (px[i] > maxBandValue[i]) {
98
                px[i] = (int)maxBandValue[i];
99
            } else if (px[i] < minBandValue[i]) {
100
                px[i] = (int)minBandValue[i];
101
            }
102

    
103
            px[i] = (int)(((int) ((((double) px[i]) * scale[i]) + offset[i])) & 0xff);
104
        }
105
            return px;
106
    }
107

    
108

    
109
}