Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/ComputeMinMaxShortFilter.java
ComputeMinMaxShortFilter.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
5 | 3 |
* |
4 |
* Copyright (C) 2004-5. |
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
... | ... | |
18 | 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
19 | 19 |
* |
20 | 20 |
* For more information, contact: |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* cresques@gmail.com |
23 | 23 |
*/ |
24 | 24 |
package org.cresques.io.raster; |
... | ... | |
29 | 29 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
30 | 30 |
*/ |
31 | 31 |
public class ComputeMinMaxShortFilter extends ComputeMinMaxFilter { |
32 |
|
|
33 |
/** |
|
34 |
* Constructor |
|
35 |
* |
|
36 |
*/ |
|
37 |
public ComputeMinMaxShortFilter(){ |
|
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 |
|
|
49 |
height = raster.getHeight(); |
|
50 |
width = raster.getWidth(); |
|
51 |
super.pre(); |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.cresques.io.raster.IRasterFilter#process(int, int) |
|
56 |
*/ |
|
57 |
public void process(int x, int y) { |
|
58 |
raster.getElemInt(x, y, px); |
|
32 |
/** |
|
33 |
* Constructor |
|
34 |
* |
|
35 |
*/ |
|
36 |
public ComputeMinMaxShortFilter() { |
|
37 |
super(); |
|
38 |
} |
|
59 | 39 |
|
60 |
int pxBand = px[0]; |
|
61 |
if(pxBand<min[0]){ |
|
62 |
secondMin[0] = min[0]; |
|
63 |
min[0] = pxBand; |
|
64 |
}else if(pxBand < secondMin[0] && pxBand!=min[0]) |
|
65 |
secondMin[0] = pxBand; |
|
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 |
pxBand = px[1]; |
|
74 |
if(pxBand<min[1]){ |
|
75 |
secondMin[1] = min[1]; |
|
76 |
min[1] = pxBand; |
|
77 |
}else if(pxBand < secondMin[1] && pxBand!=min[1]) |
|
78 |
secondMin[1] = pxBand; |
|
79 |
|
|
80 |
if(pxBand>max[1]){ |
|
81 |
secondMax[1] = max[1]; |
|
82 |
max[1] = pxBand; |
|
83 |
}else if(pxBand > secondMax[1] && pxBand!=max[1]) |
|
84 |
secondMax[1] = pxBand; |
|
85 |
|
|
86 |
pxBand = px[2]; |
|
87 |
if(pxBand<min[2]){ |
|
88 |
secondMin[2] = min[2]; |
|
89 |
min[2] = pxBand; |
|
90 |
}else if(pxBand < secondMin[2] && pxBand!=min[2]) |
|
91 |
secondMin[2] = pxBand; |
|
92 |
|
|
93 |
if(pxBand>max[2]){ |
|
94 |
secondMax[2] = max[2]; |
|
95 |
max[2] = pxBand; |
|
96 |
}else if(pxBand > secondMax[2] && pxBand!=max[2]) |
|
97 |
secondMax[2] = pxBand; |
|
98 |
} |
|
99 |
|
|
100 |
/* (non-Javadoc) |
|
101 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType() |
|
102 |
*/ |
|
103 |
public int getInRasterDataType(){ |
|
104 |
return RasterBuf.TYPE_SHORT; |
|
105 |
} |
|
106 |
|
|
107 |
/* (non-Javadoc) |
|
108 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType() |
|
109 |
*/ |
|
110 |
public int getOutRasterDataType(){ |
|
111 |
return RasterBuf.TYPE_SHORT; |
|
112 |
} |
|
113 |
|
|
114 |
/* (non-Javadoc) |
|
115 |
* @see org.cresques.io.raster.IRasterFilter#post() |
|
116 |
*/ |
|
117 |
public void post(){ |
|
118 |
super.post(); |
|
119 |
}; |
|
120 |
|
|
121 |
/* (non-Javadoc) |
|
122 |
* @see org.cresques.io.raster.RasterFilter#processLine(int) |
|
123 |
*/ |
|
124 |
public void processLine(int y){}; |
|
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"); |
|
125 | 46 |
|
47 |
height = raster.getHeight(); |
|
48 |
width = raster.getWidth(); |
|
49 |
super.pre(); |
|
50 |
} |
|
126 | 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 |
} |
|
127 | 133 |
} |
128 |
|
Also available in: Unified diff