svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / LinearEnhancementImageFilter.java @ 2312
History | View | Annotate | Download (3.14 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 |
import java.awt.Image; |
27 |
import java.awt.image.BufferedImage; |
28 |
|
29 |
/**
|
30 |
* Realzado Lineal (Amplitude Rescaling) para objetos Image.
|
31 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
32 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
33 |
*/
|
34 |
public class LinearEnhancementImageFilter extends LinearEnhancementFilter { |
35 |
|
36 |
/**
|
37 |
* Constructor
|
38 |
*/
|
39 |
public LinearEnhancementImageFilter(){
|
40 |
super();
|
41 |
} |
42 |
|
43 |
/* (non-Javadoc)
|
44 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
45 |
*/
|
46 |
public void pre(){ |
47 |
//Obtenci?n de par?metros
|
48 |
this.image = (Image)params.get("raster"); |
49 |
this.stats = (RasterStats)params.get("stats"); |
50 |
this.removeExtrema = ((Boolean)params.get("remove")).booleanValue(); |
51 |
this.filename = (String)params.get("filename"); |
52 |
height = image.getHeight(null);
|
53 |
width = image.getWidth(null);
|
54 |
super.pre();
|
55 |
} |
56 |
|
57 |
/* (non-Javadoc)
|
58 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int)
|
59 |
*/
|
60 |
public void process(int x, int y) { |
61 |
int pt = ((BufferedImage) image).getRGB(x,y); |
62 |
int []px4 = { |
63 |
((pt & 0xff000000) >> 24) & 0xff, ((pt & 0xff0000) >> 16) & 0xff, |
64 |
((pt & 0xff00) >> 8) & 0xff, pt & 0xff}; |
65 |
|
66 |
for (int i=0; i<3; i++) { |
67 |
if (px4[i+1] > maxBandValue[i]) |
68 |
px4[i+1] = maxBandValue[i];
|
69 |
else if (px4[i+1] < minBandValue[i] ) |
70 |
px4[i+1] = minBandValue[i];
|
71 |
px4[i+1] = (((int) (((double)px4[i+1])*scale[i] + offset[i])) & 0xff); |
72 |
} |
73 |
((BufferedImage) image).setRGB(x,y, (
|
74 |
(px4[0] << 24) & 0xff000000 | (px4[1] << 16) & 0xff0000 | |
75 |
(px4[2] << 8) & 0xff00 | (px4[3] & 0xff) )); |
76 |
} |
77 |
|
78 |
/* (non-Javadoc)
|
79 |
* @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
|
80 |
*/
|
81 |
public Object getResult(String name) { |
82 |
if(name.equals("raster")) |
83 |
return (Object)this.image; |
84 |
else
|
85 |
return null; |
86 |
} |
87 |
|
88 |
/* (non-Javadoc)
|
89 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
90 |
*/
|
91 |
public int getInRasterDataType(){ |
92 |
return RasterBuf.TYPE_IMAGE;
|
93 |
} |
94 |
|
95 |
/* (non-Javadoc)
|
96 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
97 |
*/
|
98 |
public int getOutRasterDataType(){ |
99 |
return RasterBuf.TYPE_IMAGE;
|
100 |
} |
101 |
|
102 |
/* (non-Javadoc)
|
103 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
104 |
*/
|
105 |
public void post(){}; |
106 |
|
107 |
/* (non-Javadoc)
|
108 |
* @see org.cresques.io.raster.RasterFilter#processLine(int)
|
109 |
*/
|
110 |
public void processLine(int y){}; |
111 |
} |
112 |
|
113 |
|