root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / convolution / ConvolutionShortFilter.java @ 12095
History | View | Annotate | Download (1.46 KB)
1 |
package org.gvsig.raster.grid.filter.convolution; |
---|---|
2 |
|
3 |
import org.gvsig.raster.buffer.RasterBuffer; |
4 |
import org.gvsig.raster.dataset.IBuffer; |
5 |
|
6 |
public class ConvolutionShortFilter extends ConvolutionFilter { |
7 |
|
8 |
protected IBuffer rasterResult = null; |
9 |
|
10 |
|
11 |
public ConvolutionShortFilter(){
|
12 |
super();
|
13 |
|
14 |
} |
15 |
|
16 |
public void pre(){ |
17 |
super.pre();
|
18 |
rasterResult = RasterBuffer.getBuffer(IBuffer.TYPE_SHORT, raster.getWidth(), raster.getHeight(), raster.getBandCount(), true);
|
19 |
} |
20 |
|
21 |
public void process(int col, int line) { |
22 |
|
23 |
double ventana[][]= new double[ladoVentana][ladoVentana]; |
24 |
short resultConvolution=0; |
25 |
for (int i = 0; i < raster.getBandCount(); i++) { |
26 |
if((col>ladoVentana)&& (line>ladoVentana)&& (line<raster.getHeight()-ladoVentana) && col<raster.getWidth()-ladoVentana){
|
27 |
for(int s=line; s< line+ladoVentana; s++) |
28 |
for(int r=col; r<col+ladoVentana; r++) |
29 |
ventana[s-line][r-col]= raster.getElemShort(s,r,i); |
30 |
Kernel Kventana= new Kernel(ventana); |
31 |
resultConvolution=(short)kernel.convolution(Kventana);
|
32 |
rasterResult.setElem(line, col, i,(short)resultConvolution);
|
33 |
|
34 |
} |
35 |
else rasterResult.setElem(line, col, i,(short)raster.getElemShort(line,col,i)); |
36 |
} |
37 |
} |
38 |
|
39 |
public int getInRasterDataType() { |
40 |
return RasterBuffer.TYPE_SHORT;
|
41 |
} |
42 |
|
43 |
|
44 |
public int getOutRasterDataType() { |
45 |
return RasterBuffer.TYPE_SHORT;
|
46 |
} |
47 |
|
48 |
|
49 |
public Object getResult(String name) { |
50 |
if (name.equals("raster")) |
51 |
return (Object) this.rasterResult; |
52 |
return null; |
53 |
} |
54 |
|
55 |
} |