Statistics
| Revision:

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

History | View | Annotate | Download (3.24 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.Params;
23
import org.gvsig.raster.grid.filter.RasterFilter;
24
/**
25
 * Clase base para los filtros de mediana.
26
 *
27
 * @author Diego Guerrero Sevilla  <diego.guerrero@uclm.es>
28
 */
29
public class MedianFilter extends RasterFilter {
30
        public static String[] names = new String[] {"median"};
31
        /**
32
         * Variable para guardar el lado de la ventana de filtrado
33
         */
34
        protected int                   ladoVentana                = 0;
35

    
36

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

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

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

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

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

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

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

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

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

    
121
        /*
122
         * (non-Javadoc)
123
         * @see org.gvsig.raster.grid.filter.RasterFilter#process(int, int)
124
         */
125
        public void process(int x, int y) {
126
        }
127
}