svn-gvsig-desktop / tags / Root_v061 / libraries / libCq CMS for java.old / src / org / cresques / io / raster / ComputeMinMaxShortFilter.java @ 4812
History | View | Annotate | Download (3.58 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 |
* Calcula el m?ximo y el m?nimo de un raster.
|
29 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
30 |
*/
|
31 |
public class ComputeMinMaxShortFilter extends ComputeMinMaxFilter { |
32 |
/**
|
33 |
* Constructor
|
34 |
*
|
35 |
*/
|
36 |
public ComputeMinMaxShortFilter() {
|
37 |
super();
|
38 |
} |
39 |
|
40 |
/* (non-Javadoc)
|
41 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
42 |
*/
|
43 |
public void pre() { |
44 |
//Obtenci?n de par?metros
|
45 |
this.raster = (RasterBuf) params.get("raster"); |
46 |
|
47 |
height = raster.getHeight(); |
48 |
width = raster.getWidth(); |
49 |
super.pre();
|
50 |
} |
51 |
|
52 |
/* (non-Javadoc)
|
53 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int)
|
54 |
*/
|
55 |
public void process(int x, int y) { |
56 |
raster.getElemInt(x, y, px); |
57 |
|
58 |
int pxBand = px[0]; |
59 |
|
60 |
if (pxBand < min[0]) { |
61 |
secondMin[0] = min[0]; |
62 |
min[0] = pxBand;
|
63 |
} else if ((pxBand < secondMin[0]) && (pxBand != min[0])) { |
64 |
secondMin[0] = pxBand;
|
65 |
} |
66 |
|
67 |
if (pxBand > max[0]) { |
68 |
secondMax[0] = max[0]; |
69 |
max[0] = pxBand;
|
70 |
} else if ((pxBand > secondMax[0]) && (pxBand != max[0])) { |
71 |
secondMax[0] = pxBand;
|
72 |
} |
73 |
|
74 |
pxBand = px[1];
|
75 |
|
76 |
if (pxBand < min[1]) { |
77 |
secondMin[1] = min[1]; |
78 |
min[1] = pxBand;
|
79 |
} else if ((pxBand < secondMin[1]) && (pxBand != min[1])) { |
80 |
secondMin[1] = pxBand;
|
81 |
} |
82 |
|
83 |
if (pxBand > max[1]) { |
84 |
secondMax[1] = max[1]; |
85 |
max[1] = pxBand;
|
86 |
} else if ((pxBand > secondMax[1]) && (pxBand != max[1])) { |
87 |
secondMax[1] = pxBand;
|
88 |
} |
89 |
|
90 |
pxBand = px[2];
|
91 |
|
92 |
if (pxBand < min[2]) { |
93 |
secondMin[2] = min[2]; |
94 |
min[2] = pxBand;
|
95 |
} else if ((pxBand < secondMin[2]) && (pxBand != min[2])) { |
96 |
secondMin[2] = pxBand;
|
97 |
} |
98 |
|
99 |
if (pxBand > max[2]) { |
100 |
secondMax[2] = max[2]; |
101 |
max[2] = pxBand;
|
102 |
} else if ((pxBand > secondMax[2]) && (pxBand != max[2])) { |
103 |
secondMax[2] = pxBand;
|
104 |
} |
105 |
} |
106 |
|
107 |
/* (non-Javadoc)
|
108 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
109 |
*/
|
110 |
public int getInRasterDataType() { |
111 |
return RasterBuf.TYPE_SHORT;
|
112 |
} |
113 |
|
114 |
/* (non-Javadoc)
|
115 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
116 |
*/
|
117 |
public int getOutRasterDataType() { |
118 |
return RasterBuf.TYPE_SHORT;
|
119 |
} |
120 |
|
121 |
/* (non-Javadoc)
|
122 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
123 |
*/
|
124 |
public void post() { |
125 |
super.post();
|
126 |
} |
127 |
|
128 |
/* (non-Javadoc)
|
129 |
* @see org.cresques.io.raster.RasterFilter#processLine(int)
|
130 |
*/
|
131 |
public void processLine(int y) { |
132 |
} |
133 |
} |