Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / filter / statistics / ComputeMinMaxShortFilter.java @ 8026

History | View | Annotate | Download (3.87 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.statistics;
25

    
26
import org.cresques.io.data.RasterBuf;
27

    
28

    
29
/**
30
 * Calcula el m?ximo y el m?nimo de un raster.
31
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
32
 */
33
public class ComputeMinMaxShortFilter extends ComputeMinMaxFilter {
34
        private short[]                 px = new short[4];
35
    /**
36
     * Constructor
37
     *
38
     */
39
    public ComputeMinMaxShortFilter() {
40
        super();
41
    }
42

    
43
    /* (non-Javadoc)
44
     * @see org.cresques.io.raster.IRasterFilter#pre()
45
     */
46
    public void pre() {
47
        //Obtenci?n de par?metros
48
        this.raster = (RasterBuf) params.get("raster");
49

    
50
        height = raster.getHeight();
51
        width = raster.getWidth();
52
        super.pre();
53
    }
54

    
55
    /* (non-Javadoc)
56
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
57
     */
58
    public void process(int col, int line)  {
59
        raster.getElemShort(line, col, px);
60

    
61
        int pxBand = px[0];
62

    
63
        if (pxBand < min[0]) {
64
            secondMin[0] = min[0];
65
            min[0] = pxBand;
66
        } else if ((pxBand < secondMin[0]) && (pxBand != min[0])) {
67
            secondMin[0] = pxBand;
68
        }
69

    
70
        if (pxBand > max[0]) {
71
            secondMax[0] = max[0];
72
            max[0] = pxBand;
73
        } else if ((pxBand > secondMax[0]) && (pxBand != max[0])) {
74
            secondMax[0] = pxBand;
75
        }
76

    
77
        pxBand = px[1];
78

    
79
        if (pxBand < min[1]) {
80
            secondMin[1] = min[1];
81
            min[1] = pxBand;
82
        } else if ((pxBand < secondMin[1]) && (pxBand != min[1])) {
83
            secondMin[1] = pxBand;
84
        }
85

    
86
        if (pxBand > max[1]) {
87
            secondMax[1] = max[1];
88
            max[1] = pxBand;
89
        } else if ((pxBand > secondMax[1]) && (pxBand != max[1])) {
90
            secondMax[1] = pxBand;
91
        }
92

    
93
        pxBand = px[2];
94

    
95
        if (pxBand < min[2]) {
96
            secondMin[2] = min[2];
97
            min[2] = pxBand;
98
        } else if ((pxBand < secondMin[2]) && (pxBand != min[2])) {
99
            secondMin[2] = pxBand;
100
        }
101

    
102
        if (pxBand > max[2]) {
103
            secondMax[2] = max[2];
104
            max[2] = pxBand;
105
        } else if ((pxBand > secondMax[2]) && (pxBand != max[2])) {
106
            secondMax[2] = pxBand;
107
        }
108
    }
109

    
110
    /* (non-Javadoc)
111
     * @see org.cresques.io.raster.IRasterFilter#processSuperSampling(int, int)
112
     */
113
    public void processSuperSampling(int col, int line)  {
114
            process(col, line);
115
        }
116
    
117
    /* (non-Javadoc)
118
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
119
     */
120
    public int getInRasterDataType() {
121
        return RasterBuf.TYPE_SHORT;
122
    }
123

    
124
    /* (non-Javadoc)
125
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
126
     */
127
    public int getOutRasterDataType() {
128
        return RasterBuf.TYPE_SHORT;
129
    }
130

    
131
    /* (non-Javadoc)
132
     * @see org.cresques.io.raster.IRasterFilter#post()
133
     */
134
    public void post() {
135
        super.post();
136
    }
137

    
138
    /* (non-Javadoc)
139
     * @see org.cresques.io.raster.RasterFilter#processLine(int)
140
     */
141
    public void processLine(int y) {
142
    }
143
}