@Override public void setImage(Planar<GrayU8> image) { this.image = image; int histElements = 1; for( int i = 0; i < image.getNumBands(); i++ ) { histElements *= numBins; } if( hist.length != histElements ) { hist = new float[histElements]; } }
@Override public void apply(Planar<Input> srcImg, Planar<Output> dstImg) { if( srcImg.getNumBands() != dstImg.getNumBands() ) throw new IllegalArgumentException("Number of bands must be the same. "+srcImg.getNumBands()+" vs "+dstImg.getNumBands()); int N = srcImg.getNumBands(); for( int i = 0; i < N; i++ ) { layerDistort.apply(srcImg.getBand(i),dstImg.getBand(i)); } }
@Override public void apply(Planar<Input> srcImg, Planar<Output> dstImg, int dstX0, int dstY0, int dstX1, int dstY1) { if( srcImg.getNumBands() != dstImg.getNumBands() ) throw new IllegalArgumentException("Number of bands must be the same. "+srcImg.getNumBands()+" vs "+dstImg.getNumBands()); int N = srcImg.getNumBands(); for( int i = 0; i < N; i++ ) { layerDistort.apply(srcImg.getBand(i),dstImg.getBand(i),dstX0, dstY0, dstX1, dstY1); } }
@Override public float colorDistance(float[] color, int index) { final int numBands = input.getNumBands(); float total = 0; for( int i = 0; i < numBands; i++ ) { float diff = (input.getBand(i).data[index] & 0xFF) - color[i]; total += diff*diff; } return total; }
@Override public void addColor(float[] color, int index, float weight) { final int numBands = input.getNumBands(); for( int i = 0; i < numBands; i++ ) { color[i] += input.getBand(i).data[index]*weight; } }
@Override public void addColor(float[] color, int index, float weight) { final int numBands = input.getNumBands(); for( int i = 0; i < numBands; i++ ) { color[i] += (input.getBand(i).data[index] & 0xFF)*weight; } }
@Override public float colorDistance(float[] color, int index) { final int numBands = input.getNumBands(); float total = 0; for( int i = 0; i < numBands; i++ ) { float diff = input.getBand(i).data[index] - color[i]; total += diff*diff; } return total; }
@Override public void setF(int index, float[] value) { for( int i = 0; i < image.getNumBands(); i++ ) { bandWrappers[i].set(index, value[i]); } }
@Override public void setImage(Planar<T> image) { if( image.getNumBands() != describers.length ) { throw new IllegalArgumentException("Unexpected number of bands in input image. Found "+ image.getNumBands()+" expected "+describers.length); } for( int i = 0; i < describers.length; i++ ) { describers[i].setImage(image.getBand(i)); } }
@Override public void getF(int index, float[] value) { for( int i = 0; i < image.getNumBands(); i++ ) { value[i] = bandWrappers[i].getF(index); } }
@Override public void setColor(float[] color, int x, int y) { final int numBands = input.getNumBands(); for( int i = 0; i < numBands; i++ ) { color[i] = input.getBand(i).unsafe_get(x,y); } }
@Override public float getIntensity(int x, int y) { final int numBands = input.getNumBands(); final int index = input.getIndex(x,y); float total = 0; for( int i = 0; i < numBands; i++ ) { total += input.getBand(i).data[index] & 0xFF; } return total/numBands; } }
@Override public float getIntensity(int x, int y) { final int numBands = input.getNumBands(); final int index = input.getIndex(x,y); float total = 0; for( int i = 0; i < numBands; i++ ) { total += input.getBand(i).data[index]; } return total/numBands; } }
@Override public void process(Planar<In> in, Planar<Out> out) { for (int i = 0; i < in.getNumBands(); i++) { down.process(in.getBand(i), out.getBand(i)); } }
@Override public void get_fast(float x, float y, float[] values) { final int N = image.getNumBands(); for( int i = 0; i < N; i++ ) { alg.setImage(image.getBand(i)); values[i] = alg.get_fast(x,y); } }
public static void process(Planar input , Planar output, int radius ) { for (int i = 0; i < input.getNumBands(); i++) { process(input.getBand(i), output.getBand(i), radius); } } }
@Override public void process(Planar<T> inputImage, Planar<D> derivX, Planar<D> derivY) { for (int i = 0; i < inputImage.getNumBands(); i++) { bandGradient.process(inputImage.getBand(i), derivX.getBand(i), derivY.getBand(i)); } }
@Override public void initialize(int backgroundWidth, int backgroundHeight, Motion homeToWorld) { background.reshape(backgroundWidth,backgroundHeight); for (int i = 0; i < background.getNumBands(); i+=2) { GImageMiscOps.fill(background.getBand(i),0); GImageMiscOps.fill(background.getBand(i+1),-1); } this.homeToWorld.set(homeToWorld); this.homeToWorld.invert(worldToHome); this.backgroundWidth = backgroundWidth; this.backgroundHeight = backgroundHeight; }
@Override public void setImage(Planar<T> image) { gray.reshape(image.width,image.height); grayII.reshape(image.width,image.height); bandII.reshape(image.width,image.height); GConvertImage.average(image, gray); GIntegralImageOps.transform(gray, grayII); for( int i = 0; i < image.getNumBands(); i++) GIntegralImageOps.transform(image.getBand(i), bandII.getBand(i)); alg.setImage(grayII,bandII); }
@Override public void detect(Planar<T> input) { gray.reshape(input.width,input.height); grayII.reshape(input.width,input.height); bandII.reshape(input.width,input.height); GConvertImage.average(input,gray); GIntegralImageOps.transform(gray, grayII); for( int i = 0; i < input.getNumBands(); i++) GIntegralImageOps.transform(input.getBand(i), bandII.getBand(i)); alg.detect(grayII,bandII); }