Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / band / ColorBalanceCMYFilter.java @ 2438

History | View | Annotate | Download (4.34 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.impl.grid.filter.band;
23

    
24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.fmap.dal.coverage.datastruct.Params;
26
import org.gvsig.fmap.dal.coverage.exception.FilterAddException;
27
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter;
28
import org.gvsig.fmap.dal.coverage.util.ColorConversion;
29
import org.gvsig.raster.impl.store.ParamsImpl;
30
import org.gvsig.raster.util.DefaultColorConversion;
31
/**
32
 * <P>
33
 * Clase base para el balance de color CMY
34
 * </P>
35
 *
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class ColorBalanceCMYFilter extends BaseRasterFilter {
39
        public static String[]            names            = new String[] { "colorbalancecmy" };
40
        protected ColorConversion         colorConversion  = null;
41
        protected int                     out              = Buffer.TYPE_BYTE;
42
        protected double                  cyan             = 0;
43
        protected double                  magenta          = 0;
44
        protected double                  yellow           = 0;
45
        protected boolean                 luminosity       = false;
46
        
47
        protected int                     redBandNumber    = -1;
48
        protected int                     greenBandNumber  = -1;
49
        protected int                     blueBandNumber   = -1;
50

    
51
        /**
52
         * Constructor
53
         */
54
        public ColorBalanceCMYFilter() {
55
                super();
56
                setName(names[0]);
57
        }
58

    
59
        public void pre() throws FilterAddException {
60
                super.pre();
61
                
62
                //A este filtro ya llega una imagen RGB con el orden de las bandas correcto 
63
                //ColorInterpretation colorInterpretation = getColorInterpretation();
64
                redBandNumber = 0;//colorInterpretation.getBand(ColorInterpretation.RED_BAND);
65
                greenBandNumber = 1;//colorInterpretation.getBand(ColorInterpretation.GREEN_BAND);
66
                blueBandNumber = 2;//colorInterpretation.getBand(ColorInterpretation.BLUE_BAND);
67
                
68
                if(getInputBuffer().getDataType() != Buffer.TYPE_BYTE) {
69
                        exec = false;
70
                        raster = rasterResult;
71
                        return;
72
                }
73
                if(params.get("cyan") != null)
74
                        cyan = ((Double) params.get("cyan")).doubleValue();
75
                if(params.get("magenta") != null)
76
                        magenta = ((Double) params.get("magenta")).doubleValue();
77
                if(params.get("yellow") != null)
78
                        yellow = ((Double) params.get("yellow")).doubleValue();
79
                if(params.get("luminosity") != null)
80
                        luminosity = ((Boolean) params.get("luminosity")).booleanValue();
81
                
82
                createARGBBufferResult();
83
                
84
                if(colorConversion == null)
85
                        colorConversion = new DefaultColorConversion();
86
        }
87
        
88
        public String getGroup() {
89
                return "colores";
90
        }
91

    
92
        public String[] getNames() {
93
                return names;
94
        }
95

    
96
        public Params getUIParams(String nameFilter) {
97
                Params params = new ParamsImpl();
98
                params.setParam("cyan",
99
                                new Double(cyan),
100
                                Params.SLIDER,
101
                                new String[]{ "0", "100", "0", "5", "25"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
102
                params.setParam("magenta",
103
                                new Double(magenta),
104
                                Params.SLIDER,
105
                                new String[]{ "0", "100", "0", "5", "25"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
106
                params.setParam("yellow",
107
                                new Double(yellow),
108
                                Params.SLIDER,
109
                                new String[]{ "0", "100", "0", "5", "25"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
110
                params.setParam("luminosity",
111
                                new Boolean(luminosity),
112
                                Params.CHECK,
113
                                null);
114

    
115
                return params;
116
        }
117

    
118
        public void post() {
119
        
120
        }
121

    
122
        public void process(int x, int y) {
123
        }
124

    
125
        public int getOutRasterDataType() {
126
                return Buffer.TYPE_BYTE;
127
        }
128

    
129
        public boolean isVisible() {
130
                return true;
131
        }
132

    
133
        public int getInRasterDataType() {
134
                return Buffer.TYPE_BYTE;
135
        }
136
}