root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / enhancement / BrightnessFilter.java @ 12333
History | View | Annotate | Download (3.81 KB)
1 | 10740 | nacho | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 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.enhancement; |
||
20 | |||
21 | 12008 | bsanchez | import org.gvsig.raster.buffer.RasterBuffer; |
22 | import org.gvsig.raster.dataset.IBuffer; |
||
23 | 11652 | bsanchez | import org.gvsig.raster.dataset.Params; |
24 | 10740 | nacho | import org.gvsig.raster.grid.filter.RasterFilter; |
25 | /**
|
||
26 | * Clase basa para los filtros de brillo.
|
||
27 | 12333 | bsanchez | *
|
28 | 11942 | bsanchez | * @version 31/05/2007
|
29 | 11574 | nacho | * @author Miguel ?ngel Querol Carratal? (miguelangel.querol@iver.es)
|
30 | 10740 | nacho | */
|
31 | 11714 | bsanchez | public class BrightnessFilter extends RasterFilter { |
32 | 12008 | bsanchez | protected IBuffer rasterResult = null; |
33 | public static String[] names = new String[] {"brightness"}; |
||
34 | 10740 | nacho | |
35 | /**
|
||
36 | * Variable para guardar el incremento de brillo que se va a aplicar
|
||
37 | */
|
||
38 | int incrBrillo = 0; |
||
39 | 11942 | bsanchez | |
40 | 11574 | nacho | /**
|
41 | 12333 | bsanchez | * Constructor. Llama al constructor de la clase base y asigna el
|
42 | 11574 | nacho | * nombre del filtro.
|
43 | */
|
||
44 | 11942 | bsanchez | public BrightnessFilter() {
|
45 | 11986 | bsanchez | setName(names[0]);
|
46 | 10740 | nacho | } |
47 | 11942 | bsanchez | |
48 | 11899 | bsanchez | /*
|
49 | * (non-Javadoc)
|
||
50 | * @see org.gvsig.raster.grid.filter.RasterFilter#pre()
|
||
51 | */
|
||
52 | 10740 | nacho | public void pre() { |
53 | 12008 | bsanchez | exec = true;
|
54 | 12138 | bsanchez | raster = (RasterBuffer) params.get("raster");
|
55 | 12008 | bsanchez | height = raster.getHeight(); |
56 | width = raster.getWidth(); |
||
57 | 12138 | bsanchez | incrBrillo = ((Integer) params.get("incrBrillo")).intValue(); |
58 | 10740 | nacho | } |
59 | |||
60 | 11899 | bsanchez | /*
|
61 | * (non-Javadoc)
|
||
62 | * @see org.gvsig.raster.grid.filter.RasterFilter#post()
|
||
63 | */
|
||
64 | 10740 | nacho | public void post() { |
65 | 11899 | bsanchez | // En caso de que nadie apunte a raster, se liberar? su memoria.
|
66 | raster = null;
|
||
67 | 10740 | nacho | } |
68 | 11942 | bsanchez | |
69 | 10740 | nacho | /**
|
70 | * Obtiene el incremento de brillo que se est? aplicando
|
||
71 | * @return entero que representa el incremento de brillo aplicado.
|
||
72 | */
|
||
73 | 11942 | bsanchez | public int getBrightnessIncrease() { |
74 | 10740 | nacho | return this.incrBrillo; |
75 | } |
||
76 | |||
77 | 11652 | bsanchez | /*
|
78 | * (non-Javadoc)
|
||
79 | * @see org.gvsig.raster.grid.filter.IRasterFilter#getGroup()
|
||
80 | */
|
||
81 | public String getGroup() { |
||
82 | return "basics"; |
||
83 | } |
||
84 | |||
85 | /*
|
||
86 | * (non-Javadoc)
|
||
87 | * @see org.gvsig.raster.grid.filter.IRasterFilter#getParams()
|
||
88 | */
|
||
89 | 12030 | bsanchez | public Params getUIParams(String nameFilter) { |
90 | 11652 | bsanchez | Params params = new Params();
|
91 | 11672 | bsanchez | params.setParam("Brightness",
|
92 | 11652 | bsanchez | incrBrillo + "",
|
93 | Params.SLIDER, |
||
94 | 11706 | bsanchez | new String[]{ "-255", "255", "50", "1", "25" }); //min, max, valor defecto, intervalo peque?o, intervalo grande; |
95 | 11652 | bsanchez | return params;
|
96 | } |
||
97 | |||
98 | /*
|
||
99 | * (non-Javadoc)
|
||
100 | 11714 | bsanchez | * @see org.gvsig.raster.grid.filter.RasterFilter#getInRasterDataType()
|
101 | */
|
||
102 | public int getInRasterDataType() { |
||
103 | return 0; |
||
104 | } |
||
105 | |||
106 | /*
|
||
107 | * (non-Javadoc)
|
||
108 | * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
|
||
109 | */
|
||
110 | public int getOutRasterDataType() { |
||
111 | return 0; |
||
112 | } |
||
113 | |||
114 | /*
|
||
115 | * (non-Javadoc)
|
||
116 | 12008 | bsanchez | * @see org.gvsig.raster.grid.filter.enhancement.BrightnessFilter#getResult(java.lang.String)
|
117 | 11714 | bsanchez | */
|
118 | public Object getResult(String name) { |
||
119 | 12008 | bsanchez | if (name.equals("raster")) |
120 | return (Object) this.rasterResult; |
||
121 | 11714 | bsanchez | return null; |
122 | } |
||
123 | |||
124 | /*
|
||
125 | * (non-Javadoc)
|
||
126 | * @see org.gvsig.raster.grid.filter.RasterFilter#process(int, int)
|
||
127 | */
|
||
128 | public void process(int x, int y) { |
||
129 | } |
||
130 | 11942 | bsanchez | |
131 | /**
|
||
132 | * Calcula el brillo para un pixel
|
||
133 | * @param px
|
||
134 | * @return
|
||
135 | */
|
||
136 | protected int calcBrightness(int px) { |
||
137 | px += incrBrillo; |
||
138 | if (px > 255) |
||
139 | px = 255;
|
||
140 | else if (px < 0) |
||
141 | px = 0;
|
||
142 | return px;
|
||
143 | } |
||
144 | 12138 | bsanchez | |
145 | /*
|
||
146 | * (non-Javadoc)
|
||
147 | * @see org.gvsig.raster.grid.filter.RasterFilter#getName()
|
||
148 | */
|
||
149 | public String[] getNames() { |
||
150 | return names;
|
||
151 | } |
||
152 | 11652 | bsanchez | } |