Revision 12176 trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/convolution/ConvolutionIntegerFilter.java
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 |
/** |
Also available in: Unified diff