createPixel(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, equiImage.getImageType()); distorter = FactoryDistort.distort(false,interp,equiImage.getImageType());
/** * Converts an image in JCodec format into one in BoofCV format. * @param input JCodec image * @param output BoofCV image */ public static void convertToBoof(Picture input, ImageBase output) { if( input.getColor() == ColorSpace.RGB ) { ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output); } else if( input.getColor() == ColorSpace.YUV420 ) { if( output instanceof Planar) { Planar ms = (Planar)output; if( ms.getImageType().getDataType() == ImageDataType.U8 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_U8(input, ms); } else if( ms.getImageType().getDataType() == ImageDataType.F32 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_F32(input, ms); } } else if( output instanceof GrayU8) { ImplConvertJCodecPicture.yuv420_to_U8(input, (GrayU8) output); } else if( output instanceof GrayF32) { ImplConvertJCodecPicture.yuv420_to_F32(input, (GrayF32) output); } else { throw new RuntimeException("Unexpected output image type"); } } } }
public void setCalibration(CameraUniversalOmni fisheyeModel) { BoofSwingUtil.checkGuiThread(); LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel); fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel); distorter = new NarrowToWidePtoP_F32(pinholeDistort,fisheyeDistort); // Create the image distorter which will render the image InterpolatePixel<Planar<GrayF32>> interp = FactoryInterpolation. createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, imageFisheye.getImageType()); distortImage = FactoryDistort.distort(false,interp,imageFisheye.getImageType()); // Pass in the transform created above distortImage.setModel(new PointToPixelTransform_F32(distorter)); setPinholeCenter(fisheyeModel.width/2,fisheyeModel.height/2); renderPinhole(); }
/** * Converts an image in JCodec format into one in BoofCV format. * @param input JCodec image * @param output BoofCV image */ public static void convertToBoof(Picture input, ImageBase output) { if( input.getColor() == ColorSpace.RGB ) { ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output); } else if( input.getColor() == ColorSpace.YUV420 ) { if( output instanceof Planar) { Planar ms = (Planar)output; if( ms.getImageType().getDataType() == ImageDataType.U8 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_U8(input, ms); } else if( ms.getImageType().getDataType() == ImageDataType.F32 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_F32(input, ms); } } else if( output instanceof GrayU8) { ImplConvertJCodecPicture.yuv420_to_U8(input, (GrayU8) output); } else if( output instanceof GrayF32) { ImplConvertJCodecPicture.yuv420_to_F32(input, (GrayF32) output); } else { throw new RuntimeException("Unexpected output image type"); } } } }
/** * 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. Consult a chi-square table for reasonably values. * 10 to 16 for 1 to 3 bands. * @param imageType Type of input image. */ public BackgroundStationaryGaussian_PL(float learnRate, float threshold, ImageType<Planar<T>> imageType) { super(learnRate, threshold, imageType); int numBands = imageType.getNumBands(); background = new Planar<>(GrayF32.class,1,1,2*numBands); bgWrapper = FactoryGImageMultiBand.create(background.getImageType()); bgWrapper.wrap(background); inputWrapper = FactoryGImageMultiBand.create(imageType); inputPixel = new float[numBands]; }
ImageGray so = (ImageGray)output; if( mi.getImageType().getDataType() != so.getDataType() ) { int w = output.width; int h = output.height; ImageGray tmp = GeneralizedImageOps.createSingleBand(mi.getImageType().getDataType(),w,h); average(mi,tmp); convert(tmp,so);
/** * 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. Consult a chi-square table for reasonably values. * 10 to 16 for 1 to 3 bands. * @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_PL(float learnRate, float threshold, Point2Transform2Model_F32<Motion> transform, InterpolationType interpType, ImageType<Planar<T>> imageType) { super(learnRate, threshold, transform, imageType); int numBands = imageType.getNumBands(); this.interpolateInput = FactoryInterpolation.createPixelMB(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, imageType); background = new Planar<>(GrayF32.class,1,1,2*numBands); this.interpolationBG = FactoryInterpolation.createPixelMB( 0, 255, interpType, BorderType.EXTENDED, background.getImageType()); this.interpolationBG.setImage(background); inputWrapper = FactoryGImageMultiBand.create(imageType); pixelBG = new float[2*numBands]; pixelInput = new float[numBands]; }
ComputeRegionMeanColor colorize = FactorySegmentationAlg.regionMeanColor(input.getImageType());