Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / correction / MedianFilter.java @ 17108

History | View | Annotate | Download (3.37 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.correction;
20

    
21
import org.gvsig.raster.buffer.RasterBuffer;
22
import org.gvsig.raster.dataset.IBuffer;
23
import org.gvsig.raster.dataset.Params;
24
import org.gvsig.raster.grid.filter.RasterFilter;
25
/**
26
 * Clase base para los filtros de mediana.
27
 *
28
 * @author Diego Guerrero Sevilla  <diego.guerrero@uclm.es>
29
 */
30
public class MedianFilter extends RasterFilter {
31
        public static String[] names = new String[] {"median"};
32
        /**
33
         * Variable para guardar el lado de la ventana de filtrado
34
         */
35
        protected int                   ladoVentana                = 0;
36
        protected IBuffer               rasterResult = null;
37

    
38

    
39
        public MedianFilter() {
40
                super();
41
                setName(names[0]);
42
        }
43

    
44
        /*
45
         * (non-Javadoc)
46
         * @see org.gvsig.raster.grid.filter.RasterFilter#pre()
47
         */
48
        public void pre() {
49
                exec = true;
50
                raster = (RasterBuffer) params.get("raster");
51
                height = raster.getHeight();
52
                width = raster.getWidth();
53
                ladoVentana = ((Integer) params.get("ladoVentana")).intValue();
54
        }
55

    
56
        /*
57
         * (non-Javadoc)
58
         * @see org.gvsig.raster.grid.filter.RasterFilter#post()
59
         */
60
        public void post() {
61
                // En caso de que nadie apunte a raster, se liberar? su memoria.
62
                raster = null;
63
        }
64

    
65
        /*
66
         * (non-Javadoc)
67
         * @see org.gvsig.raster.grid.filter.RasterFilter#getGroup()
68
         */
69
        public String getGroup() {
70
                return "espaciales";
71
        }
72

    
73
        /*
74
         * (non-Javadoc)
75
         * @see org.gvsig.raster.grid.filter.RasterFilter#getInRasterDataType()
76
         */
77
        public int getInRasterDataType() {
78
                return 0;
79
        }
80

    
81
        /*
82
         * (non-Javadoc)
83
         * @see org.gvsig.raster.grid.filter.RasterFilter#getNames()
84
         */
85
        public String[] getNames() {
86
                return names;
87
        }
88

    
89
        /*
90
         * (non-Javadoc)
91
         * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
92
         */
93
        public int getOutRasterDataType() {
94
                return 0;
95
        }
96

    
97
        /*
98
         * (non-Javadoc)
99
         * @see org.gvsig.raster.grid.filter.RasterFilter#getResult(java.lang.String)
100
         */
101
        public Object getResult(String name) {
102
                if (name.equals("raster")) {
103
                        if(!exec)
104
                                return (Object) this.raster;
105
                        else
106
                                return (Object) this.rasterResult;
107
                } else {
108
                        return null;
109
                }
110
        }
111

    
112
        /*
113
         * (non-Javadoc)
114
         * @see org.gvsig.raster.grid.filter.RasterFilter#getUIParams()
115
         */
116
        public Params getUIParams(String nameFilter) {
117
                Params params = new Params();
118
                params.setParam("LadoVentana",
119
                                new Integer(ladoVentana),
120
                                Params.SLIDER,
121
                                new String[] {"1", "7", "0", "1", "25" }); //min, max, valor defecto, intervalo peque?o, intervalo grande;
122
                return params;
123
        }
124

    
125
        /*
126
         * (non-Javadoc)
127
         * @see org.gvsig.raster.grid.filter.RasterFilter#process(int, int)
128
         */
129
        public void process(int x, int y) {
130
        }
131
}