public DescribeImageDense_Convert(DescribeImageDense<ImageBase,Desc> describer , ImageType<T> inputType ) { ImageType describerType = describer.getImageType(); if( inputType.getFamily() != describerType.getFamily() ) throw new IllegalArgumentException("Image types must have the same family"); if( inputType.getDataType() == describerType.getDataType() ) throw new IllegalArgumentException("Data types are the same. Why do you want to use this class?"); workspace = describerType.createImage(1,1); this.describer = describer; this.inputType = inputType; }
public static void down(ImageBase input , int sampleWidth , ImageBase output ) { switch( input.getImageType().getFamily() ) { case GRAY: down((ImageGray)input, sampleWidth, (ImageGray)output ); return; case PLANAR: down((Planar) input, sampleWidth, (Planar)output ); return; case INTERLEAVED: throw new IllegalArgumentException("Interleaved images are not yet supported"); } throw new IllegalArgumentException("Unknown image type"); }
public static <T extends ImageBase<T>> InterpolatePixel<T> createPixel(double min, double max, InterpolationType type, BorderType borderType, ImageType<T> imageType) { switch( imageType.getFamily() ) { case GRAY: case PLANAR: return createPixelS(min, max, type, borderType, imageType.getImageClass()); case INTERLEAVED: return createPixelMB(min,max,type,borderType,(ImageType)imageType); default: throw new IllegalArgumentException("Unknown family"); } }
public static <T extends ImageMultiBand> PixelLikelihood<T> likelihoodHueSatHistIndependent( double maxPixelValue , int numHistogramBins , ImageType<T> imageType ) { if( imageType.getFamily() != ImageType.Family.PLANAR) throw new IllegalArgumentException("Only Planar images supported currently"); if( imageType.getNumBands() != 3 ) throw new IllegalArgumentException("Input image type must have 3 bands."); if( imageType.getDataType() == ImageDataType.U8 ) { return (PixelLikelihood)new LikelihoodHueSatHistInd_PL_U8((int)maxPixelValue,numHistogramBins); } else { throw new RuntimeException("Band type not yet supported "+imageType.getDataType()); } }
public static <T extends ImageMultiBand> PixelLikelihood<T> likelihoodHueSatHistCoupled( double maxPixelValue , int numHistogramBins , ImageType<T> imageType ) { if( imageType.getFamily() != ImageType.Family.PLANAR) throw new IllegalArgumentException("Only Planar images supported currently"); if( imageType.getNumBands() != 3 ) throw new IllegalArgumentException("Input image type must have 3 bands."); if( imageType.getDataType() == ImageDataType.U8 ) { return (PixelLikelihood)new LikelihoodHueSatHistCoupled_PL_U8((int)maxPixelValue,numHistogramBins); } else { throw new RuntimeException("Band type not yet supported "+imageType.getDataType()); } }
private void createStorage() { if( inputType.getFamily() == ImageType.Family.PLANAR ) { storage = (T)GeneralizedImageOps.createSingleBand(inputType.getImageClass(),1,1); } else { storage = inputType.createImage(1,1); } }
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"); } }
public static <T extends ImageBase> PixelLikelihood<T> likelihoodHistogramCoupled( double maxPixelValue , int numHistogramBins , ImageType<T> imageType ) { switch( imageType.getFamily() ) { case GRAY: if( imageType.getDataType() != ImageDataType.U8 ) throw new IllegalArgumentException("Only U8 currently supported"); return (PixelLikelihood)new LikelihoodHistCoupled_SB_U8((int)maxPixelValue,numHistogramBins); case PLANAR: if( imageType.getDataType() == ImageDataType.U8 ) { return (PixelLikelihood)new LikelihoodHistCoupled_PL_U8((int)maxPixelValue,numHistogramBins); } else { throw new RuntimeException("Band type not yet supported "+imageType.getDataType()); } default: throw new IllegalArgumentException("Image family not yet supported. Try Planar"); } }
/** * Given different types input images it creates the correct algorithm for computing the image gradient. The * actualy calulcation is always done using {@link DerivativeType#THREE} */ static <Input extends ImageBase> ImageGradient<Input,GrayF32> createGradient( ImageType<Input> imageType ) { ImageGradient<Input,GrayF32> gradient; ImageType<GrayF32> typeF32 = ImageType.single(GrayF32.class); if( imageType.getDataType() != ImageDataType.F32 ) throw new IllegalArgumentException("Input image type must be F32"); if( imageType.getFamily() == ImageType.Family.GRAY) { gradient = FactoryDerivative.gradient(DerivativeType.THREE,imageType, typeF32); } else if( imageType.getFamily() == ImageType.Family.PLANAR ) { ImageType<Planar<GrayF32>> typePF32 = ImageType.pl(imageType.getNumBands(),GrayF32.class); ImageGradient<Planar<GrayF32>,Planar<GrayF32>> gradientMB = FactoryDerivative.gradient(DerivativeType.THREE,typePF32, typePF32); gradient = (ImageGradient)FactoryDerivative.gradientReduce(gradientMB, DerivativeReduceType.MAX_F, GrayF32.class); } else { throw new IllegalArgumentException("Unsupported image type "+imageType); } return gradient; }
public static <In extends ImageBase<In>, Out extends ImageBase<Out>> ConvolveDown<In,Out> convolve(Kernel1D kernel, BorderType border , boolean isHorizontal , int skip , ImageType<In> inputType , ImageType<Out> outputType ) { switch( inputType.getFamily() ) { case PLANAR: return convolvePL(kernel, border, isHorizontal, skip, inputType.getNumBands(), inputType.getImageClass(), outputType.getImageClass()); case GRAY: return convolveSB(kernel, border, isHorizontal, skip, inputType.getImageClass(), outputType.getImageClass()); case INTERLEAVED: throw new IllegalArgumentException("Interleaved images are not yet supported"); } throw new IllegalArgumentException("Unknown image type"); }
public static <In extends ImageBase<In>, Out extends ImageBase<Out>> ConvolveDown<In,Out> convolve(Kernel2D kernel, BorderType border , int skip , ImageType<In> inputType , ImageType<Out> outputType ) { switch( inputType.getFamily() ) { case PLANAR: return convolvePL(kernel, border, skip, inputType.getNumBands(), inputType.getImageClass(), outputType.getImageClass()); case GRAY: return convolveSB(kernel, border, skip, inputType.getImageClass(), outputType.getImageClass()); case INTERLEAVED: throw new IllegalArgumentException("Interleaved images are not yet supported"); } throw new IllegalArgumentException("Unknown image type"); }
public static <T extends ImageBase<T>> ImageBorder<T> generic( BorderType borderType, ImageType<T> imageType ) { switch( imageType.getFamily() ) { case GRAY: return single(imageType.getImageClass(),borderType); case PLANAR: return single(imageType.getImageClass(),borderType); case INTERLEAVED: return interleaved(imageType.getImageClass(),borderType); default: throw new IllegalArgumentException("Unknown family"); } }
public static <T extends ImageBase<T>> ImageBorder<T> genericValue( double value, ImageType<T> imageType ) { switch( imageType.getFamily() ) { case GRAY: return singleValue(imageType.getImageClass(), value); case PLANAR: return singleValue(imageType.getImageClass(),value); case INTERLEAVED: return interleavedValue(imageType.getImageClass(),value); default: throw new IllegalArgumentException("Unknown family"); } }
private void setDescriptorInput() { if( describe != null ) { if( describe.getImageType().getFamily() == ImageType.Family.GRAY) { T input = ConvertBufferedImage.convertFromSingle(image, null, imageType); describe.setImage(input); } else { Planar<T> input = ConvertBufferedImage.convertFromPlanar(image, null, true, imageType); describe.setImage(input); } } }
/** * Creates an instance of {@link BackgroundMovingBasic}. * * @param config Configures the background model * @param imageType Type of input image * @return new instance of the background model */ public static <T extends ImageBase> BackgroundStationaryBasic<T> stationaryBasic( ConfigBackgroundBasic config , ImageType<T> imageType ) { config.checkValidity(); switch( imageType.getFamily() ) { case GRAY: return new BackgroundStationaryBasic_SB(config.learnRate,config.threshold,imageType.getImageClass()); case PLANAR: return new BackgroundStationaryBasic_PL(config.learnRate,config.threshold,imageType); case INTERLEAVED: return new BackgroundStationaryBasic_IL(config.learnRate,config.threshold,imageType); } throw new IllegalArgumentException("Unknown image type"); }
public static <T extends ImageBase> T convertFrom(BufferedImage src , boolean orderRgb , T output ) { ImageType<T> imageType = output.getImageType(); switch( imageType.getFamily() ) { case GRAY: convertFromSingle(src, (ImageGray)output, imageType.getImageClass()); break; case PLANAR: convertFromMulti(src, (Planar) output, orderRgb, imageType.getImageClass()); break; case INTERLEAVED: convertFromInterleaved(src, (ImageInterleaved) output, orderRgb); break; default: throw new RuntimeException("Not supported yet"); } return output; }
/** * Color variant of the SURF descriptor which has been designed for speed and sacrifices some stability. * * @see DescribePointSurfPlanar * * @param config SURF configuration. Pass in null for default options. * @param imageType Type of input image. * @return SURF color description extractor */ public static <T extends ImageMultiBand, II extends ImageGray> DescribeRegionPoint<T,BrightFeature> surfColorFast(ConfigSurfDescribe.Speed config , ImageType<T> imageType) { Class bandType = imageType.getImageClass(); Class<II> integralType = GIntegralImageOps.getIntegralType(bandType); DescribePointSurf<II> alg = FactoryDescribePointAlgs.surfSpeed( config, integralType); if( imageType.getFamily() == ImageType.Family.PLANAR) { DescribePointSurfPlanar<II> color = FactoryDescribePointAlgs.surfColor( alg,imageType.getNumBands()); return new SurfPlanar_to_DescribeRegionPoint(color,bandType,integralType); } else { throw new IllegalArgumentException("Unknown image type"); } }
/** * Color variant of the SURF descriptor which has been designed for stability. * * @see DescribePointSurfPlanar * * @param config SURF configuration. Pass in null for default options. * @param imageType Type of input image. * @return SURF color description extractor */ public static <T extends ImageBase, II extends ImageGray> DescribeRegionPoint<T,BrightFeature> surfColorStable(ConfigSurfDescribe.Stability config, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); Class<II> integralType = GIntegralImageOps.getIntegralType(bandType); DescribePointSurf<II> alg = FactoryDescribePointAlgs.surfStability( config, integralType); if( imageType.getFamily() == ImageType.Family.PLANAR) { DescribePointSurfPlanar<II> color = FactoryDescribePointAlgs.surfColor( alg,imageType.getNumBands()); return new SurfPlanar_to_DescribeRegionPoint(color,bandType,integralType); } else { throw new IllegalArgumentException("Unknown image type"); } }
protected StitchingFromMotion2D createAlgorithm( PointTracker<I> tracker ) { if( imageType.getFamily() == ImageType.Family.PLANAR) { Class imageClass = this.imageType.getImageClass(); ImageMotion2D<I,IT> motion = FactoryMotion2D.createMotion2D(maxIterations,inlierThreshold,2,absoluteMinimumTracks, respawnTrackFraction,respawnCoverageFraction,false,tracker,fitModel); ImageMotion2D motion2DColor = new PlToGrayMotion2D(motion,imageClass); return FactoryMotion2D.createVideoStitch(maxJumpFraction,motion2DColor, imageType); } else { ImageMotion2D motion = FactoryMotion2D.createMotion2D(maxIterations,inlierThreshold,2,absoluteMinimumTracks, respawnTrackFraction,respawnCoverageFraction,false,tracker,fitModel); return FactoryMotion2D.createVideoStitch(maxJumpFraction,motion, imageType); } }
public static <I extends ImageBase<I>, D extends ImageBase<D>> ImageType<D> getDerivativeType( ImageType<I> imageType ) { switch( imageType.getFamily() ) { case GRAY: return ImageType.single(getDerivativeType(imageType.getImageClass())); case PLANAR: { int numBands = imageType.getNumBands(); return ImageType.pl(numBands, getDerivativeType(imageType.getImageClass())); } case INTERLEAVED: int numBands = imageType.getNumBands(); switch ( imageType.getDataType() ) { case F32: return (ImageType)ImageType.il(numBands, ImageDataType.F32); case F64: return (ImageType)ImageType.il(numBands, ImageDataType.F64); case U8: return (ImageType)ImageType.il(numBands, ImageDataType.S16); case U16: return (ImageType)ImageType.il(numBands, ImageDataType.S32); } } throw new IllegalArgumentException("Unknown image type"); }