Revision 2308 org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/convolution/ConvolutionShortFilter.java

View differences:

ConvolutionShortFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.convolution;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.fmap.dal.coverage.exception.FilterAddException;
25 26
import org.gvsig.raster.impl.DefaultRasterManager;
26 27
import org.gvsig.raster.impl.buffer.RasterBuffer;
27 28
import org.gvsig.raster.impl.datastruct.Kernel;
......
33 34
 * */
34 35
public class ConvolutionShortFilter extends ConvolutionFilter {
35 36

  
36
	public ConvolutionShortFilter(){
37
	public ConvolutionShortFilter() {
37 38
		super();
38 39
	}
39 40

  
......
41 42
	 * @param Kernel a aplicar. En caso de que no se trate de un kernel definido en ConvolutionFilter, se puede pasar como
42 43
	 * parametro el kernel se pretende aplicar.
43 44
	 * **/
44
	public ConvolutionShortFilter(Kernel k){
45
	public ConvolutionShortFilter(Kernel k) {
45 46
		super();
46
		super.kernel=k;
47
		super.kernel = k;
47 48
	}
48 49

  
49
	public void pre(){
50
	public void pre() throws FilterAddException {
50 51
		super.pre();
51 52
		rasterResult = DefaultRasterManager.getInstance().createBuffer(Buffer.TYPE_SHORT, raster.getWidth(), raster.getHeight(), raster.getBandCount(), true);
52 53
	}
......
57 58
		int semiLado = (lado - 1) >> 1;
58 59
		double ventana[][] = new double[lado][lado];
59 60
		double resultConvolution = 0;
60
		for (int band = 0; band < raster.getBandCount(); band++) {
61
		for (int band = 0; band < numberOfBandsToProcess(); band++) {
61 62
			if ((col - semiLado >= 0) && (line - semiLado >= 0) && (col + semiLado < width) && (line + semiLado < height)) {
62 63
				for (int j = -semiLado; j <= semiLado; j++)
63 64
					for (int i = -semiLado; i <= semiLado; i++)
......
89 90
		return RasterBuffer.TYPE_SHORT;
90 91
	}
91 92

  
92
	/**
93
	 * @return  buffer resultante tras aplicar el filtro
94
	 * */
95
	public Object getResult(String name) {
96
		if (name.equals("raster"))
97
			return this.rasterResult;
98
		return null;
99
	}
100

  
101 93
}

Also available in: Unified diff