gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / enhancement / LinearEnhancementFloatFilter.java @ 2308
History | View | Annotate | Download (1.99 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.enhancement; |
23 |
|
24 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
25 |
/**
|
26 |
* Filtro de realce para tipos de datos float. En el m?todo de proceso procesa
|
27 |
* un solo pixel float. Asigna su valor en relaci?n a los datos calculados en el
|
28 |
* m?todo pre() del padre.
|
29 |
*
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
31 |
*/
|
32 |
public class LinearEnhancementFloatFilter extends LinearEnhancementFilter { |
33 |
|
34 |
public void process(int col, int line) { |
35 |
for (int iBand = 0; iBand < numberOfBandsToProcess(); iBand++) { |
36 |
float p = raster.getElemFloat(line, col, iBand);
|
37 |
if(renderBands[iBand] < 0) { |
38 |
rasterResult.setElem(line, col, iBand, (byte)p);
|
39 |
continue;
|
40 |
} |
41 |
/*if (p > maxBandValue[renderBands[iBand]])
|
42 |
p = (float) maxBandValue[renderBands[iBand]];
|
43 |
else if (p < minBandValue[renderBands[iBand]])
|
44 |
p = (float) minBandValue[renderBands[iBand]];*/
|
45 |
|
46 |
int value = (int) (((int) ((p * scale[renderBands[iBand]]) + offset[renderBands[iBand]])) & 0xff); |
47 |
rasterResult.setElem(line, col, iBand, (byte) value);
|
48 |
} |
49 |
} |
50 |
|
51 |
public int getInRasterDataType() { |
52 |
return Buffer.TYPE_FLOAT; |
53 |
} |
54 |
} |