/** * Configures the descriptor. * * @param widthSubregion Width of sub-region in samples. Try 4 * @param widthGrid Width of grid in subregions. Try 4. * @param numHistogramBins Number of bins in histogram. Try 8 * @param sigmaToPixels Conversion of sigma to pixels. Used to scale the descriptor region. Try 1.5 ?????? * @param weightingSigmaFraction Sigma for Gaussian weighting function is set to this value * region width. Try 0.5 * @param maxDescriptorElementValue Helps with non-affine changes in lighting. See paper. Try 0.2 */ public DescribePointSift(int widthSubregion, int widthGrid, int numHistogramBins, double sigmaToPixels, double weightingSigmaFraction, double maxDescriptorElementValue , Class<Deriv> derivType ) { super(widthSubregion,widthGrid,numHistogramBins,weightingSigmaFraction,maxDescriptorElementValue); this.sigmaToPixels = sigmaToPixels; imageDerivX = FactoryGImageGray.create(derivType); imageDerivY = FactoryGImageGray.create(derivType); }
@Override public void wrap(ImageBase image) { if( this.sb == null ) { this.sb = FactoryGImageGray.wrap((ImageGray)image); } else { this.sb.wrap((ImageGray)image); } }
/** * Configurations background removal. * * @param learnRate Specifies how quickly the background is updated. 0 = static 1.0 = instant. Try 0.05 * @param threshold Threshold for background. Try 10. * @param imageType Type of input image. */ public BackgroundStationaryGaussian_SB(float learnRate, float threshold, Class<T> imageType) { super(learnRate, threshold, ImageType.single(imageType)); inputWrapper = FactoryGImageGray.create(imageType); }
public static GImageMultiBand wrap( ImageGray image ) { return new GSingleToMB(FactoryGImageGray.wrap(image)); }
public BaseIntegralEdge(Class<T> imageType) { this.imageType = imageType; this.integral = new ImageLineIntegral(); this.integralImage = FactoryGImageGray.create(imageType); }
public static GImageGray wrap(ImageGray image , GImageGray output ) { if( output == null ) return wrap(image); if( image.getClass() == GrayU8.class ) ((GSingle_U8)output).image = (GrayU8)image; else if( image.getClass() == GrayS8.class ) ((GSingle_S8)output).image = (GrayS8)image; else if( image.getClass() == GrayU16.class ) ((GSingle_U16)output).image = (GrayU16)image; else if( image.getClass() == GrayS16.class ) ((GSingle_S16)output).image = (GrayS16)image; else if( image.getClass() == GrayS32.class ) ((GSingle_S32)output).image = (GrayS32)image; else if( image.getClass() == GrayS64.class ) ((GSingle_I64)output).image = (GrayS64)image; else if( image.getClass() == GrayF32.class ) ((GSingle_F32)output).image = (GrayF32)image; else if( image.getClass() == GrayF64.class ) ((GSingle_F64)output).image = (GrayF64)image; else throw new IllegalArgumentException("Unknown image type: "+image.getClass()); return output; }
public BackgroundStationaryBasic_SB(float learnRate, float threshold, Class<T> imageType) { super(learnRate, threshold, ImageType.single(imageType)); inputWrapper = FactoryGImageGray.create(imageType); }
public static void printDiff(ImageGray imgA, ImageGray imgB) { GImageGray a = FactoryGImageGray.wrap(imgA); GImageGray b = FactoryGImageGray.wrap(imgB); System.out.println("------- Difference -----------"); for (int y = 0; y < imgA.getHeight(); y++) { for (int x = 0; x < imgA.getWidth(); x++) { double diff = Math.abs(a.get(x, y).doubleValue() - b.get(x, y).doubleValue()); System.out.printf("%2d ", (int) diff); } System.out.println(); } }
/** * Configures orientation estimation * * @param histogramSize Number of elements in the histogram. Standard is 36 * @param sigmaEnlarge How much the scale is enlarged by. Standard is 1.5 */ public OrientationHistogramSift(int histogramSize , double sigmaEnlarge , Class<Deriv> derivType ) { this.histogramMag = new double[ histogramSize ]; this.histogramX = new double[ histogramSize ]; this.histogramY = new double[ histogramSize ]; this.sigmaEnlarge = sigmaEnlarge; this.histAngleBin = 2.0*Math.PI/histogramSize; // compute an approximation of a Gaussian distribution as a function of the distance squared double samples[] = new double[ (int)(4*4/approximateStep) ]; for( int i = 0; i < samples.length; i++ ) { double dx2 = i*approximateStep; samples[i] = Math.exp(-0.5*dx2 ); } approximateGauss = new InterpolateArray(samples); this.derivX = FactoryGImageGray.create(derivType); this.derivY = FactoryGImageGray.create(derivType); }
public static void checkBorderZero(ImageGray outputImage, int border) { GImageGray img = FactoryGImageGray.wrap(outputImage); for (int y = 0; y < img.getHeight(); y++) { if (y >= border && y < img.getHeight() - border) continue; for (int x = 0; x < img.getWidth(); x++) { if (x >= border && x < img.getWidth() - border) continue; if (img.get(x, y).intValue() != 0) throw new RuntimeException("The border is not zero: "+x+" "+y); } } }
/** * Specifies SIFT descriptor structure and sampling frequency. * @param widthSubregion Width of sub-region in samples. Try 4 * @param widthGrid Width of grid in subregions. Try 4. * @param numHistogramBins Number of bins in histogram. Try 8 * @param weightingSigmaFraction Sigma for Gaussian weighting function is set to this value * region width. Try 0.5 * @param maxDescriptorElementValue Helps with non-affine changes in lighting. See paper. Try 0.2 * @param periodColumns Number of pixels between samples along x-axis * @param periodRows Number of pixels between samples along y-axis * @param derivType Type of input derivative image */ public DescribeDenseSiftAlg(int widthSubregion, int widthGrid, int numHistogramBins, double weightingSigmaFraction , double maxDescriptorElementValue, double periodColumns, double periodRows , Class<D> derivType ) { super(widthSubregion,widthGrid,numHistogramBins,weightingSigmaFraction,maxDescriptorElementValue); this.periodRows = periodRows; this.periodColumns = periodColumns; final int DOF = getDescriptorLength(); imageDerivX = FactoryGImageGray.create(derivType); imageDerivY = FactoryGImageGray.create(derivType); descriptors = new FastQueue<TupleDesc_F64>(TupleDesc_F64.class,true) { @Override protected TupleDesc_F64 createInstance() { return new TupleDesc_F64(DOF); } }; }
public static void checkBorderZero(ImageGray outputImage, int borderX0 , int borderY0 , int borderX1 , int borderY1 ) { GImageGray img = FactoryGImageGray.wrap(outputImage); for (int y = 0; y < img.getHeight(); y++) { if (y >= borderY0 && y < img.getHeight() - borderY1) continue; for (int x = 0; x < img.getWidth(); x++) { if (x >= borderX0 && x < img.getWidth() - borderX1) continue; if (img.get(x, y).intValue() != 0) throw new RuntimeException("The border is not zero: "+x+" "+y); } } }
/** * Used to specify a transform that is applied to pixel coordinates to bring them back into original input * image coordinates. For example if the input image has lens distortion but the edge were found * in undistorted coordinates this code needs to know how to go from undistorted back into distorted * image coordinates in order to read the pixel's value. * * @param undistToDist Pixel transformation from undistorted pixels into the actual distorted input image.. */ public void setTransform( PixelTransform2_F32 undistToDist ) { if( undistToDist != null ) { InterpolatePixelS<T> interpolate = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); integralImage = new GImageGrayDistorted<>(undistToDist, interpolate); } else { integralImage = FactoryGImageGray.create(imageType); } }
public BackgroundMovingBasic_SB(float learnRate, float threshold, Point2Transform2Model_F32<Motion> transform, InterpolationType interpType, Class<T> imageType) { super(learnRate, threshold, transform, ImageType.single(imageType)); this.interpolateInput = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); this.interpolationBG = FactoryInterpolation.createPixelS(0, 255, interpType, BorderType.EXTENDED, GrayF32.class); this.interpolationBG.setBorder(FactoryImageBorder.single(GrayF32.class, BorderType.EXTENDED)); this.interpolationBG.setImage(background); inputWrapper = FactoryGImageGray.create(imageType); }
/** * Configurations background removal. * * @param learnRate Specifies how quickly the background is updated. 0 = static 1.0 = instant. Try 0.05 * @param threshold Threshold for background. Try 10. * @param transform Used to apply motion model * @param interpType Type of interpolation. BILINEAR recommended for accuracy. NEAREST_NEIGHBOR for speed. . * @param imageType Type of input image. */ public BackgroundMovingGaussian_SB(float learnRate, float threshold, Point2Transform2Model_F32<Motion> transform, InterpolationType interpType, Class<T> imageType) { super(learnRate, threshold, transform, ImageType.single(imageType)); this.interpolateInput = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); this.interpolationBG = FactoryInterpolation.createPixelMB( 0, 255, interpType, BorderType.EXTENDED, ImageType.pl(2, GrayF32.class)); this.interpolationBG.setImage(background); inputWrapper = FactoryGImageGray.create(imageType); }
public static GImageMultiBand create( ImageType imageType ) { if( imageType.getFamily() == ImageType.Family.GRAY ) { return new GSingleToMB(FactoryGImageGray.create(imageType.getImageClass())); } if( imageType.getFamily() == ImageType.Family.PLANAR) { return new PL(); } else if( imageType.getFamily() == ImageType.Family.INTERLEAVED ) { switch( imageType.getDataType() ) { case U8: return new IL_U8(); case S8: return new IL_S8(); case F32: return new IL_F32(); default: throw new IllegalArgumentException("Need to support more data types"); } } else { throw new RuntimeException("Add support for more families"); } }
@Override public void wrap(ImageBase image) { if( this.image == null ) { this.image = (Planar) image; bandWrappers = new GImageGray[this.image.getNumBands()]; for (int i = 0; i < bandWrappers.length; i++) { bandWrappers[i] = FactoryGImageGray.wrap(this.image.getBand(i)); } } else { this.image = (Planar) image; for (int i = 0; i < bandWrappers.length; i++) { bandWrappers[i].wrap(this.image.getBand(i)); } } }