public static void convolve( Kernel2D_F64 kernel , InterleavedF64 src , InterleavedF64 dst ) { final double[] dataKernel = kernel.data; final double[] dataSrc = src.data; final double[] dataDst = dst.data; final int width = src.getWidth(); final int height = src.getHeight(); final int numBands = src.getNumBands(); int offsetL = kernel.offset; int offsetR = kernel.width-kernel.offset-1; for( int y = offsetL; y < height-offsetR; y++ ) { int indexDst = dst.startIndex + y*dst.stride+offsetL*numBands; for( int x = offsetL; x < width-offsetR; x++ ) { int indexSrcStart = src.startIndex + (y-offsetL)*src.stride + (x-offsetL)*numBands; for (int band = 0; band < numBands; band++) { double total = 0; int indexKer = 0; for( int ki = 0; ki < kernel.width; ki++ ) { int indexSrc = indexSrcStart+ki*src.stride + band; for( int kj = 0; kj < kernel.width; kj++ ) { total += (dataSrc[indexSrc] )* dataKernel[indexKer++]; indexSrc += numBands; } } dataDst[indexDst++] = total; } } } }
final int height = src.getHeight(); final int numBands = src.getNumBands(); final double[] total = new double[ numBands ];
final int height = src.getHeight(); final int numBands = dst.getNumBands(); final double total[] = new double[ numBands ];
final int imgHeight = output.getHeight(); final int numBands = output.getNumBands(); final double total[] = new double[ numBands ];
public static void vertical( Kernel1D_F64 kernel, InterleavedF64 src, InterleavedF64 dst ) { final double[] dataSrc = src.data; final double[] dataDst = dst.data; final double[] dataKer = kernel.data; final int offset = kernel.getOffset(); final int kernelWidth = kernel.getWidth(); final int numBands = src.getNumBands(); final int imgWidth = dst.getWidth(); final int imgHeight = dst.getHeight(); final int yEnd = imgHeight-(kernelWidth-offset-1); for( int y = offset; y < yEnd; y++ ) { int indexDst = dst.startIndex+y*dst.stride; int indexSrcStart = src.startIndex+(y-offset)*src.stride; for (int x = 0; x < imgWidth; x++) { for (int band = 0; band < numBands; band++) { int indexSrc = indexSrcStart + band; double total = 0; for (int k = 0; k < kernelWidth; k++) { total += (dataSrc[indexSrc] )* dataKer[k]; indexSrc += src.stride; } dataDst[indexDst++] = total; } indexSrcStart += numBands; } } }
final int height = input.getHeight(); final int numBands = input.getNumBands();
public static void vertical(Kernel1D_F64 kernel, InterleavedF64 input, InterleavedF64 output ) { final int offset = kernel.getOffset(); final int width = input.getWidth(); final int height = input.getHeight(); final int numBands = input.getNumBands(); final double[] pixel = new double[ numBands ]; final double[] total = new double[ numBands ]; for (int y = 0; y < height; y++) { for( int x = 0; x < width; x++ ) { Arrays.fill(total,0); double weight = 0; int startY = y - offset; int endY = startY + kernel.getWidth(); if( startY < 0 ) startY = 0; if( endY > height ) endY = height; for( int i = startY; i < endY; i++ ) { double v = kernel.get(i-y+offset); input.get(x,i, pixel); for (int band = 0; band < numBands; band++) { total[band] += pixel[band]*v; } weight += v; } for (int band = 0; band < numBands; band++) { total[band] /= weight; } output.set(x,y, total); } } }
final int height = input.getHeight(); final int numBands = input.getNumBands();