svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / LinearEnhancementShortFilter.java @ 2312
History | View | Annotate | Download (2.89 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.io.raster; |
25 |
|
26 |
|
27 |
/**
|
28 |
* Realzado Lineal (Amplitude Rescaling) para imagenes de 16 bits.
|
29 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
30 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
31 |
*/
|
32 |
public class LinearEnhancementShortFilter extends LinearEnhancementFilter { |
33 |
|
34 |
/**
|
35 |
* Constructor
|
36 |
*/
|
37 |
public LinearEnhancementShortFilter(){
|
38 |
super();
|
39 |
} |
40 |
|
41 |
/* (non-Javadoc)
|
42 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
43 |
*/
|
44 |
public void pre(){ |
45 |
//Obtenci?n de par?metros
|
46 |
|
47 |
this.raster = (RasterBuf)params.get("raster"); |
48 |
this.stats = (RasterStats)params.get("stats"); |
49 |
this.removeExtrema = ((Boolean)params.get("remove")).booleanValue(); |
50 |
this.filename = (String)params.get("filename"); |
51 |
height = raster.getHeight(); |
52 |
width = raster.getWidth(); |
53 |
super.pre();
|
54 |
} |
55 |
|
56 |
/* (non-Javadoc)
|
57 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int)
|
58 |
*/
|
59 |
public void process(int x, int y) { |
60 |
raster.getElemInt(x, y, px); |
61 |
int bandsCnt = 3; // Esto hay que sacarlo de fuera, l?gicamente. |
62 |
for (int i=0; i<bandsCnt; i++) { |
63 |
if ( px[i] > maxBandValue[i] )
|
64 |
px[i] = maxBandValue[i]; |
65 |
else if (px[i] < minBandValue[i] ) |
66 |
px[i] = minBandValue[i]; |
67 |
|
68 |
px[i] = (((int) (((double)px[i])*scale[i] + offset[i])) & 0xff); |
69 |
} |
70 |
raster.setElemInt(x, y, px); |
71 |
} |
72 |
|
73 |
/* (non-Javadoc)
|
74 |
* @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
|
75 |
*/
|
76 |
public Object getResult(String name) { |
77 |
if(name.equals("raster")) |
78 |
return (Object)this.raster; |
79 |
else
|
80 |
return null; |
81 |
} |
82 |
|
83 |
/* (non-Javadoc)
|
84 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
85 |
*/
|
86 |
public int getInRasterDataType(){ |
87 |
return RasterBuf.TYPE_SHORT;
|
88 |
} |
89 |
|
90 |
/* (non-Javadoc)
|
91 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
92 |
*/
|
93 |
public int getOutRasterDataType(){ |
94 |
return RasterBuf.TYPE_SHORT;
|
95 |
} |
96 |
|
97 |
/* (non-Javadoc)
|
98 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
99 |
*/
|
100 |
public void post(){}; |
101 |
|
102 |
/* (non-Javadoc)
|
103 |
* @see org.cresques.io.raster.RasterFilter#processLine(int)
|
104 |
*/
|
105 |
public void processLine(int y){}; |
106 |
|
107 |
} |
108 |
|