/** * Creates a new image of the same type and number of bands * * @param imgWidth image width * @param imgHeight image height * @return new image */ @Override public Planar<T> createNew(int imgWidth, int imgHeight) { return new Planar<>(type, imgWidth, imgHeight, bands.length); }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { pixelToRegion = new GrayS32(imageWidth,imageHeight); background = new Planar<>(GrayU8.class, imageWidth, imageHeight, 3); }
public BaseImageClassifier( int imageSize ) { this.imageSize = imageSize; imageRgb = new Planar<>(GrayF32.class,imageSize,imageSize,3); tensorInput = new Tensor_F32(1,3,imageSize,imageSize); }
private void setupImages(BufferedImage input) { int w = input.getWidth(); int h = input.getHeight(); this.input = input; // create output images this.work = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); this.selected = new InterleavedU8(w,h,1); // Convert the input image into the HSV color model hsv = new Planar<GrayF32>(GrayF32.class,w,h,3); Planar<GrayF32> inputMS = new Planar<GrayF32>(GrayF32.class,w,h,3); ConvertBufferedImage.convertFrom(input, inputMS, true); ColorHsv.rgbToHsv_F32(inputMS, hsv); hsv = inputMS; }
/** * Converts an NV21 image into a {@link Planar} YUV image with U8 bands. * * @param data Input: NV21 image data * @param width Input: NV21 image width * @param height Input: NV21 image height * @param output Output: Optional storage for output image. Can be null. */ public static Planar<GrayU8> nv21ToPlanarYuv_U8(byte[] data , int width , int height , Planar<GrayU8> output ) { if( output == null ) { output = new Planar<>(GrayU8.class,width,height,3); } else if( output.width != width || output.height != height ) throw new IllegalArgumentException("output width and height must be "+width+" "+height); else if( output.getNumBands() != 3 ) throw new IllegalArgumentException("three bands expected"); ImplConvertNV21.nv21ToPlanarYuv_U8(data,output); return output; }
/** * The actual classification of the images by using the pre-trained model. */ private static Entry<String, Double> classifyWithModel(ImageClassifierVggCifar10 classifier, BufferedImage image) { Planar<GrayF32> planar = new Planar<>(GrayF32.class, image.getWidth(), image.getHeight(), 3); ConvertBufferedImage.convertFromPlanar(image, planar, true, GrayF32.class); classifier.classify(planar); return classifier.getAllResults().stream() .map(score -> entry(classifier.getCategories().get(score.category), score.score)) .max(Comparator.comparing(Entry::getValue)).get(); }
public BackgroundStationaryBasic_PL(float learnRate, float threshold, ImageType<Planar<T>> imageType) { super(learnRate, threshold, imageType); int numBands = imageType.getNumBands(); background = new Planar<>(GrayF32.class,1,1,numBands); inputWrapper = FactoryGImageMultiBand.create(imageType); inputPixels = new float[numBands]; }
public ShowImageBlurApp( Class<T> imageType ) { super(1); addAlgorithm(0,"Gaussian",0); addAlgorithm(0,"Mean",1); addAlgorithm(0,"Median",2); this.imageType = imageType; input = new Planar<>(imageType, 1, 1, 3); output = new Planar<>(imageType, 1, 1, 3); storage = new Planar<>(imageType, 1, 1, 3); addToToolbar(createRadialSelect()); setMainGUI(gui); }
/** * Converts a {@link InterleavedU8} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayU8> convert( InterleavedU8 input , Planar<GrayU8> output ) { if (output == null) { output = new Planar<GrayU8>(GrayU8.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link InterleavedS8} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayS8> convert( InterleavedS8 input , Planar<GrayS8> output ) { if (output == null) { output = new Planar<GrayS8>(GrayS8.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link InterleavedS16} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayS16> convert( InterleavedS16 input , Planar<GrayS16> output ) { if (output == null) { output = new Planar<GrayS16>(GrayS16.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link InterleavedF32} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayF32> convert( InterleavedF32 input , Planar<GrayF32> output ) { if (output == null) { output = new Planar<GrayF32>(GrayF32.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link InterleavedS32} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayS32> convert( InterleavedS32 input , Planar<GrayS32> output ) { if (output == null) { output = new Planar<GrayS32>(GrayS32.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link InterleavedF64} into the equivalent {@link Planar} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static Planar<GrayF64> convert( InterleavedF64 input , Planar<GrayF64> output ) { if (output == null) { output = new Planar<GrayF64>(GrayF64.class,input.width, input.height,input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input,output); return output; }
@Override public <InternalImage> InternalImage getGuiImage() { Planar<GrayU8> boofColor = new Planar<>(GrayU8.class, frameCurrent.getWidth(),frameCurrent.getHeight(),3); BufferedImage output = new BufferedImage(boofColor.width,boofColor.height,BufferedImage.TYPE_INT_RGB); UtilJCodec.convertToBoof(frameCurrent,boofColor); ConvertBufferedImage.convertTo(boofColor,output,true); return (InternalImage)output; }
@Override public <InternalImage> InternalImage getGuiImage() { Planar<GrayU8> boofColor = new Planar<>(GrayU8.class, frameCurrent.getWidth(),frameCurrent.getHeight(),3); BufferedImage output = new BufferedImage(boofColor.width,boofColor.height,BufferedImage.TYPE_INT_RGB); UtilJCodec.convertToBoof(frameCurrent,boofColor); ConvertBufferedImage.convertTo(boofColor,output,true); return (InternalImage)output; }
public SurfPlanar_to_DetectDescribePoint(DetectDescribeSurfPlanar<II> alg , Class<T> imageType, Class<II> integralType) { this.alg = alg; gray = GeneralizedImageOps.createSingleBand(imageType, 1, 1); grayII = GeneralizedImageOps.createSingleBand(integralType,1,1); bandII = new Planar<>(integralType, 1, 1, alg.getDescribe().getNumBands()); }
public static <T extends Planar> T createSubImageOf_PL(T input) { T ret = (T)new Planar(input.type,input.width,input.height,input.getNumBands()); for( int i = 0; i < input.getNumBands(); i++ ) { ret.bands[i] = createSubImageOf_S(input.getBand(i)); } ret.stride = ret.bands[0].stride; ret.startIndex = ret.bands[0].startIndex; return ret; }
public SurfPlanar_to_DescribeRegionPoint(DescribePointSurfPlanar<II> alg, Class<T> imageType, Class<II> integralType ) { this.alg = alg; gray = GeneralizedImageOps.createSingleBand(imageType, 1, 1); grayII = GeneralizedImageOps.createSingleBand(integralType,1,1); bandII = new Planar<>(integralType, 1, 1, alg.getNumBands()); this.imageType = ImageType.pl(alg.getNumBands(), imageType); }