Revision 12176
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionIntegerFilter.java | ||
---|---|---|
34 | 34 |
/** Aplicacion del filtro para el pixel de la posicion line, col */ |
35 | 35 |
public void process(int col, int line) { |
36 | 36 |
|
37 |
int lado= kernel.getLado(); |
|
38 |
double ventana[][]= new double[lado][lado]; |
|
39 |
int resultConvolution=0; |
|
40 |
for (int i = 0; i < raster.getBandCount(); i++) { |
|
41 |
if((col>lado)&& (line>lado)&& (line<raster.getHeight()-lado) && col<raster.getWidth()-lado){ |
|
42 |
for(int s=line; s< line+lado; s++) |
|
43 |
for(int r=col; r<col+lado; r++) |
|
44 |
ventana[s-line][r-col]= raster.getElemInt(s,r,i); |
|
45 |
Kernel Kventana= new Kernel(ventana); |
|
46 |
resultConvolution=(int)kernel.convolution(Kventana); |
|
47 |
rasterResult.setElem(line, col, i,(int)resultConvolution); |
|
48 |
} |
|
49 |
else rasterResult.setElem(line, col, i,(int)raster.getElemInt(line,col,i)); |
|
37 |
int lado= kernel.getLado(); |
|
38 |
int semiLado = (lado - 1) >> 1; |
|
39 |
double ventana[][]= new double[lado][lado]; |
|
40 |
int resultConvolution=0; |
|
41 |
for (int band = 0; band < raster.getBandCount(); band++) { |
|
42 |
if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)){ |
|
43 |
for (int j = -semiLado; j <= semiLado; j++) |
|
44 |
for (int i = -semiLado; i <= semiLado; i++) |
|
45 |
ventana[i + semiLado][j + semiLado] = raster.getElemInt(line + j, col + i, band)&0xff;; |
|
46 |
Kernel Kventana= new Kernel(ventana); |
|
47 |
resultConvolution=(int)kernel.convolution(Kventana); |
|
48 |
rasterResult.setElem(line, col, band,(int)resultConvolution); |
|
50 | 49 |
} |
50 |
else rasterResult.setElem(line, col,band,(int)raster.getElemInt(line,col,band)); |
|
51 |
} |
|
51 | 52 |
} |
52 | 53 |
|
53 | 54 |
/** |
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionFilter.java | ||
---|---|---|
191 | 191 |
} |
192 | 192 |
|
193 | 193 |
|
194 |
/*public Params getUIParams() {
|
|
194 |
public Params getUIParams() { |
|
195 | 195 |
Params params = new Params(); |
196 | 196 |
params.setParam("LadoVentana", |
197 | 197 |
ladoVentana + "", |
198 | 198 |
Params.CHOICE, |
199 | 199 |
new String[] {"3","3","5", "7"}); |
200 | 200 |
return params; |
201 |
}*/
|
|
201 |
} |
|
202 | 202 |
|
203 | 203 |
|
204 | 204 |
public Params getUIParams(String nameFilter) { |
... | ... | |
210 | 210 |
new String[] {"3","5","7"}); |
211 | 211 |
|
212 | 212 |
params.setParam("FilterName", |
213 |
getName(),
|
|
213 |
nameFilter,
|
|
214 | 214 |
-1, |
215 | 215 |
null); |
216 | 216 |
|
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionShortFilter.java | ||
---|---|---|
35 | 35 |
public void process(int col, int line) { |
36 | 36 |
|
37 | 37 |
int lado= kernel.getLado(); |
38 |
int semiLado = (lado - 1) >> 1; |
|
38 | 39 |
double ventana[][]= new double[lado][lado]; |
39 | 40 |
short resultConvolution=0; |
40 |
for (int i = 0; i < raster.getBandCount(); i++) {
|
|
41 |
if((col>lado)&& (line>lado)&& (line<raster.getHeight()-lado) && col<raster.getWidth()-lado){
|
|
42 |
for(int s=line; s< line+lado; s++)
|
|
43 |
for(int r=col; r<col+lado; r++)
|
|
44 |
ventana[s-line][r-col]= raster.getElemShort(s,r,i);
|
|
41 |
for (int band = 0; band < raster.getBandCount(); band++) {
|
|
42 |
if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)){
|
|
43 |
for (int j = -semiLado; j <= semiLado; j++)
|
|
44 |
for (int i = -semiLado; i <= semiLado; i++)
|
|
45 |
ventana[i + semiLado][j + semiLado] = raster.getElemShort(line + j, col + i, band)&0xff;;
|
|
45 | 46 |
Kernel Kventana= new Kernel(ventana); |
46 | 47 |
resultConvolution=(short)kernel.convolution(Kventana); |
47 |
rasterResult.setElem(line, col, i,(short)resultConvolution); |
|
48 |
|
|
48 |
rasterResult.setElem(line, col, band,(short)resultConvolution); |
|
49 | 49 |
} |
50 |
else rasterResult.setElem(line, col, i,(short)raster.getElemShort(line,col,i));
|
|
51 |
} |
|
50 |
else rasterResult.setElem(line, col,band,(short)raster.getElemShort(line,col,band));
|
|
51 |
}
|
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
/** |
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionByteFilter.java | ||
---|---|---|
83 | 83 |
if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)){ |
84 | 84 |
for (int j = -semiLado; j <= semiLado; j++) |
85 | 85 |
for (int i = -semiLado; i <= semiLado; i++) |
86 |
ventana[i + semiLado][j + semiLado] = raster.getElemByte(line + j, col + i, band); |
|
86 |
ventana[i + semiLado][j + semiLado] = raster.getElemByte(line + j, col + i, band)&0xff;;
|
|
87 | 87 |
Kernel Kventana= new Kernel(ventana); |
88 | 88 |
resultConvolution=(byte)kernel.convolution(Kventana); |
89 | 89 |
rasterResult.setElem(line, col, band,(byte)resultConvolution); |
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionFloatFilter.java | ||
---|---|---|
72 | 72 |
/** Aplicacion del filtro para el pixel de la posicion line, col */ |
73 | 73 |
public void process(int col, int line) { |
74 | 74 |
|
75 |
double ventana[][]= new double[ladoVentana][ladoVentana]; |
|
75 |
int lado= kernel.getLado(); |
|
76 |
int semiLado = (lado - 1) >> 1; |
|
77 |
double ventana[][]= new double[lado][lado]; |
|
76 | 78 |
float resultConvolution=0; |
77 |
for (int i = 0; i < raster.getBandCount(); i++) {
|
|
78 |
if((col>ladoVentana)&& (line>ladoVentana)&& (line<raster.getHeight()-ladoVentana) && col<raster.getWidth()-ladoVentana){
|
|
79 |
for(int s=line; s< line+ladoVentana; s++)
|
|
80 |
for(int r=col; r<col+ladoVentana; r++)
|
|
81 |
ventana[s-line][r-col]= raster.getElemFloat(s,r,i);
|
|
79 |
for (int band = 0; band < raster.getBandCount(); band++) {
|
|
80 |
if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)){
|
|
81 |
for (int j = -semiLado; j <= semiLado; j++)
|
|
82 |
for (int i = -semiLado; i <= semiLado; i++)
|
|
83 |
ventana[i + semiLado][j + semiLado] = raster.getElemFloat(line + j, col + i, band);;
|
|
82 | 84 |
Kernel Kventana= new Kernel(ventana); |
83 | 85 |
resultConvolution=(float)kernel.convolution(Kventana); |
84 |
rasterResult.setElem(line, col, i,(float)resultConvolution); |
|
85 |
|
|
86 |
rasterResult.setElem(line, col, band,(float)resultConvolution); |
|
86 | 87 |
} |
87 |
else rasterResult.setElem(line, col, i,(float)raster.getElemFloat(line,col,i));
|
|
88 |
} |
|
88 |
else rasterResult.setElem(line, col,band,(float)raster.getElemFloat(line,col,band));
|
|
89 |
}
|
|
89 | 90 |
|
90 | 91 |
} |
91 | 92 |
|
trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionDoubleFilter.java | ||
---|---|---|
75 | 75 |
public void process(int col, int line) { |
76 | 76 |
|
77 | 77 |
int lado= kernel.getLado(); |
78 |
int semiLado = (lado - 1) >> 1; |
|
78 | 79 |
double ventana[][]= new double[lado][lado]; |
79 | 80 |
double resultConvolution=0; |
80 |
for (int i = 0; i < raster.getBandCount(); i++) {
|
|
81 |
if((col>lado)&& (line>lado)&& (line<raster.getHeight()-lado) && col<raster.getWidth()-lado){
|
|
82 |
for(int s=line; s< line+lado; s++)
|
|
83 |
for(int r=col; r<col+lado; r++)
|
|
84 |
ventana[s-line][r-col]= raster.getElemDouble(s,r,i);
|
|
81 |
for (int band = 0; band < raster.getBandCount(); band++) {
|
|
82 |
if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)){
|
|
83 |
for (int j = -semiLado; j <= semiLado; j++)
|
|
84 |
for (int i = -semiLado; i <= semiLado; i++)
|
|
85 |
ventana[i + semiLado][j + semiLado] = raster.getElemDouble(line + j, col + i, band);
|
|
85 | 86 |
Kernel Kventana= new Kernel(ventana); |
86 | 87 |
resultConvolution=(double)kernel.convolution(Kventana); |
87 |
rasterResult.setElem(line, col, i,(double)resultConvolution);
|
|
88 |
rasterResult.setElem(line, col, band,(double)resultConvolution);
|
|
88 | 89 |
} |
89 |
else rasterResult.setElem(line, col, i,(double)raster.getElemDouble(line,col,i));
|
|
90 |
} |
|
90 |
else rasterResult.setElem(line, col,band,(double)raster.getElemDouble(line,col,band));
|
|
91 |
}
|
|
91 | 92 |
} |
92 | 93 |
/** |
93 | 94 |
* @return tipo de dato del buffer de entrada |
Also available in: Unified diff