@Override public void reset() { background.reshape(1,1); }
/** * Scales down the input by a factor of 2. Every other pixel along both axises is skipped. */ public static void scaleDown2(GrayF32 input , GrayF32 output ) { output.reshape(input.width / 2, input.height / 2); for (int y = 0; y < output.height; y++) { int indexInput = 2*y*input.stride; int indexOutput = y*output.stride; for (int x = 0; x < output.width; x++,indexInput+=2) { output.data[indexOutput++] = input.data[indexInput]; } } }
public void init( int width , int height) { if( intensity.width != width || intensity.height != height ) { intensity.reshape(width,height); // zero the image to make sure it's borders values are zero GImageMiscOps.fill(intensity, 0); } }
/** * Specifies parameters of transform. The minimum number of points specified in the extractor * is an important tuning parameter. * * @param extractor Extracts local maxima from transform space. * @param numBinsRange How many bins are be used for line range. * @param numBinsAngle How many bins are used for angle. */ public HoughTransformLinePolar(NonMaxSuppression extractor , int numBinsRange , int numBinsAngle) { this.extractor = extractor; transform.reshape(numBinsRange,numBinsAngle); tableTrig = new CachedSineCosine_F32(0,(float)Math.PI,numBinsAngle); }
/** * Computes all the scale images in an octave. This includes DoG images. */ private void computeOctaveScales() { octaveImages[0] = tempImage0; for (int i = 1; i < numScales+3; i++) { octaveImages[i].reshape(tempImage0.width, tempImage0.height); applyGaussian(octaveImages[i - 1], octaveImages[i], kernelSigmaToK[i-1]); } for (int i = 1; i < numScales+3; i++) { differenceOfGaussian[i-1].reshape(tempImage0.width, tempImage0.height); PixelMath.subtract(octaveImages[i],octaveImages[i - 1],differenceOfGaussian[i-1]); } }
/** * Provides an initial estimate for the flow by interpolating values from the previous layer. */ protected void interpolateFlowScale(int widthNew, int heightNew) { initFlowX.reshape(widthNew,heightNew); initFlowY.reshape(widthNew,heightNew); interpolateFlowScale(flowX, initFlowX); interpolateFlowScale(flowY, initFlowY); flowX.reshape(widthNew,heightNew); flowY.reshape(widthNew,heightNew); // init flow contains the initial estimate of the flow vector (if available) // flow contains the estimate for each iteration below flowX.setTo(initFlowX); flowY.setTo(initFlowY); }
@Override public GrayF32 transform(GrayF32 original, GrayF32 transformed) { if( transformed == null ) { ImageDimension d = UtilWavelet.transformDimension(original,numLevels); transformed = new GrayF32(d.width,d.height); } temp.reshape(transformed.width,transformed.height); copy.reshape(original.width,original.height); copy.setTo(original); WaveletTransformOps.transformN(desc,copy,transformed,temp,numLevels); return transformed; }
@Override public void setImage(T image) { GrayF32 input; if( image instanceof GrayF32) { input = (GrayF32)image; } else { imageFloat.reshape(image.width,image.height); GConvertImage.convert(image,imageFloat); input = imageFloat; } scaleSpace.setImage(input); }
/** * Applies the separable kernel to the input image and stores the results in the output image. */ void applyGaussian(GrayF32 input, GrayF32 output, Kernel1D kernel) { tempBlur.reshape(input.width, input.height); GConvolveImageOps.horizontalNormalized(kernel, input, tempBlur); GConvolveImageOps.verticalNormalized(kernel, tempBlur,output); }
@Override public void detect(T image) { GrayF32 input; if( image instanceof GrayF32) { input = (GrayF32)image; } else { imageFloat.reshape(image.width,image.height); GConvertImage.convert(image,imageFloat); input = imageFloat; } detector.process(input); }
@Override protected void detectFeatures(int scaleIndex) { // compute image derivative for this scale GrayF32 input = scaleSpace.getImageScale(scaleIndex); derivX.reshape(input.width,input.height); derivY.reshape(input.width,input.height); gradient.process(input,derivX,derivY); // set up the orientation and description algorithms orientation.setImageGradient(derivX,derivY); describe.setImageGradient(derivX,derivY); super.detectFeatures(scaleIndex); }
@Override public void initialize(int backgroundWidth, int backgroundHeight, Motion homeToWorld) { background.reshape(backgroundWidth,backgroundHeight); ImageMiscOps.fill(background,Float.MAX_VALUE); this.homeToWorld.set(homeToWorld); this.homeToWorld.invert(worldToHome); this.backgroundWidth = backgroundWidth; this.backgroundHeight = backgroundHeight; }
@Override public void setInputImage(GrayF32 image) { enlargedTemplate.reshape(image.width,image.height); fftImage.reshape(image.width,image.height); fftTemplate.reshape(image.width,image.height); fftMult.reshape(image.width,image.height); correlation.reshape(image.width,image.height); normalizedImage.reshape(image.width,image.height); maxValue = ImageStatistics.max(image)+0.0001f;// avoid divide by zero errors mean = ImageStatistics.mean(image); PixelMath.divide(image,maxValue,normalizedImage); PixelMath.minus(normalizedImage,mean/maxValue,normalizedImage); dft.forward(normalizedImage, fftImage); }
/** * Specifies input image. Gradient is computed immediately * @param input input image */ @Override public void setInput( Input input ) { super.setInput(input); orientation.reshape(input.width,input.height); magnitude.reshape(input.width,input.height); computePixelFeatures(); }
@Override public void detect(In input) { if( input instanceof GrayF32) alg.process((GrayF32)input); else { imageFloat.reshape(input.width,input.height); GConvertImage.convert(input,imageFloat); alg.process(imageFloat); } }
@Override public void setImage(T image) { GrayF32 input; if( image instanceof GrayF32) { input = (GrayF32)image; } else { imageFloat.reshape(image.width,image.height); GConvertImage.convert(image,imageFloat); input = imageFloat; } scaleSpace.setImage(input); setObjectRadius(sigma*BoofDefaults.SIFT_SCALE_TO_RADIUS); }
/** * Sets the gradient and precomputes pixel orientation and magnitude * * @param derivX image derivative x-axis * @param derivY image derivative y-axis */ public void setImageGradient(D derivX , D derivY ) { InputSanityCheck.checkSameShape(derivX,derivY); if( derivX.stride != derivY.stride || derivX.startIndex != derivY.startIndex ) throw new IllegalArgumentException("stride and start index must be the same"); savedAngle.reshape(derivX.width,derivX.height); savedMagnitude.reshape(derivX.width,derivX.height); imageDerivX.wrap(derivX); imageDerivY.wrap(derivY); precomputeAngles(derivX); }
public boolean process(GrayF32 left, GrayF32 right, OverheadView<Planar<GrayF32>> overhead) { Planar<GrayF32> overheadRGB = overhead.getImage(); gray.reshape(overheadRGB.getWidth(),overheadRGB.getHeight()); ConvertImage.average(overheadRGB,gray); if( !motion2D.process(gray) ) { return false; } // take in account map units Se2_F64 a = motion2D.getFirstToCurrent(); motion.set(a); motion.T.x = a.T.x*overhead.cellSize; motion.T.y = a.T.y*overhead.cellSize; return true; }