Statistics
| Revision:

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

History | View | Annotate | Download (2.13 KB)

1
package org.cresques.filter.enhancement;
2

    
3
import org.cresques.io.data.RasterBuf;
4
import org.cresques.io.datastruct.Statistic;
5

    
6
public class LinearEnhancementDoubleFilter extends LinearEnhancementFilter {
7
        private double[]                 px = new double[4];
8
        private int                         bandsCnt = 3;
9
        
10
        public void post() {
11
                // TODO Auto-generated method stub
12

    
13
        }
14

    
15
        public void process(int col, int line) {
16
                raster.getElemDouble(line, col, px);
17
        px = calcLinearEnhancement(px);
18
        raster.setElemDouble(line, col, px);
19
        }
20

    
21
        public void processSuperSampling(int col, int line) {
22
                raster.getElemDouble(line, col, px);
23
        px = calcLinearEnhancement(px);
24
                for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++)
25
                        for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++)
26
                                 raster.setElemDouble(i, j, px);
27
        }
28

    
29
        public void processLine(int y) {
30
                // TODO Auto-generated method stub
31

    
32
        }
33

    
34
        public int getInRasterDataType() {
35
                return RasterBuf.TYPE_DOUBLE;
36
        }
37

    
38
        public int getOutRasterDataType() {
39
                return RasterBuf.TYPE_DOUBLE;
40
        }
41

    
42
        public Object getResult(String name) {
43
                if (name.equals("raster")) {
44
            return (Object) this.raster;
45
        } else {
46
            return null;
47
        }
48
        }
49

    
50
        public void pre() {
51
//                Obtención de parámetros
52
        this.raster = (RasterBuf) params.get("raster");
53
        this.stats = (Statistic) params.get("stats");
54
        this.removeExtrema = ((Boolean) params.get("remove")).booleanValue();
55
        this.filename = (String) params.get("filename");
56
        height = raster.getHeight();
57
        width = raster.getWidth();
58
        super.pre();
59
        }
60
        
61
        /**
62
     * Calculo del realce
63
     * @param pt pixel
64
     * @return pixel con el calculo de realce aplicado
65
     */
66
    private double[] calcLinearEnhancement(double[] px){
67
            for (int i = 0; i < bandsCnt; i++) {
68
            if (px[i] > (float)maxBandValue[i]) {
69
                px[i] = (float)maxBandValue[i];
70
            } else if (px[i] < minBandValue[i]) {
71
                px[i] = (float)minBandValue[i];
72
            }
73

    
74
            px[i] = (int)(((int) ((((double) px[i]) * scale[i]) + offset[i])) & 0xff);
75
        }
76
            return px;
77
    }
78

    
79
}