@Override public int getHeight() {return image.getHeight();}
@Override public void setImage(T image) { if( border != null ) border.setImage(image); this.orig = image; this.stride = orig.getStride(); this.width = orig.getWidth(); this.height = orig.getHeight(); }
public static <T extends ImageInterleaved<T>> void interleavedYuvToBitmap(T input, Bitmap output, byte[] storage) { if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) { throw new IllegalArgumentException("Image shapes are not the same"); } if( storage == null ) storage = declareStorage(output,null); if( input.getImageType().getDataType() == ImageDataType.U8 ) { switch( output.getConfig() ) { case ARGB_8888: ImplConvertBitmap.interleavedYuvToArgb8888((InterleavedU8) input, storage); output.copyPixelsFromBuffer(ByteBuffer.wrap(storage)); return; case RGB_565: ImplConvertBitmap.interleavedYuvToRGB565((InterleavedU8) input, storage); output.copyPixelsFromBuffer(ByteBuffer.wrap(storage)); return; } } throw new IllegalArgumentException("Unsupported BoofCV Type"); }
/** * Converts {@link ImageInterleaved} image into Bitmap. * * @see #declareStorage(android.graphics.Bitmap, byte[]) * * @param input Input Planar image. * @param output Output Bitmap image. * @param storage Byte array used for internal storage. If null it will be declared internally. */ public static <T extends ImageInterleaved<T>> void interleavedToBitmap(T input, Bitmap output, byte[] storage) { if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) { throw new IllegalArgumentException("Image shapes are not the same"); } if( storage == null ) storage = declareStorage(output,null); if( input.getImageType().getDataType() == ImageDataType.U8 ) ImplConvertBitmap.interleavedToArray((InterleavedU8) input, storage, output.getConfig()); else if( input.getImageType().getDataType() == ImageDataType.F32 ) ImplConvertBitmap.interleavedToArray((InterleavedF32) input, storage, output.getConfig()); else throw new IllegalArgumentException("Unsupported BoofCV Type"); output.copyPixelsFromBuffer(ByteBuffer.wrap(storage)); }
/** * Converts {@link ImageInterleaved} image into Bitmap. * * @see #declareStorage(android.graphics.Bitmap, byte[]) * * @param input Input Planar image. * @param output Output Bitmap image. * @param storage Byte array used for internal storage. If null it will be declared internally. */ public static <T extends ImageInterleaved> void interleavedToBitmap(T input, Bitmap output, byte[] storage) { if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) { throw new IllegalArgumentException("Image shapes are not the same"); } if( storage == null ) storage = declareStorage(output,null); if( input.getImageType().getDataType() == ImageDataType.U8 ) ImplConvertBitmap.interleavedToArray((InterleavedU8) input, storage, output.getConfig()); else if( input.getImageType().getDataType() == ImageDataType.F32 ) ImplConvertBitmap.interleavedToArray((InterleavedF32) input, storage, output.getConfig()); else throw new IllegalArgumentException("Unsupported BoofCV Type"); output.copyPixelsFromBuffer(ByteBuffer.wrap(storage)); }
@Override public void applyOnlyInside() { float maxWidth = srcImg.getWidth()-1; float maxHeight = srcImg.getHeight()-1; for( int y = y0; y < y1; y++ ) { int indexDst = dstImg.startIndex + dstImg.stride*y + x0*dstImg.numBands; for( int x = x0; x < x1; x++ , indexDst += dstImg.numBands ) { dstToSrc.compute(x,y); if( dstToSrc.distX >= 0 && dstToSrc.distX <= maxWidth && dstToSrc.distY >= 0 && dstToSrc.distY <= maxHeight ) { interp.get(dstToSrc.distX, dstToSrc.distY, values); assign(indexDst,values); } } } }
throw new IllegalArgumentException("src is null!"); if (src.getWidth() != dst.getWidth() || src.getHeight() != dst.getHeight()) { throw new IllegalArgumentException("image dimension are different");
@Override public void applyAll( GrayU8 mask ) { float maxWidth = srcImg.getWidth()-1; float maxHeight = srcImg.getHeight()-1; for( int y = y0; y < y1; y++ ) { int indexDst = dstImg.startIndex + dstImg.stride*y + x0*dstImg.numBands; int indexMsk = mask.startIndex + mask.stride*y + x0; for( int x = x0; x < x1; x++ , indexDst += dstImg.numBands , indexMsk++) { dstToSrc.compute(x,y); interp.get(dstToSrc.distX, dstToSrc.distY, values); assign(indexDst,values); if( dstToSrc.distX >= 0 && dstToSrc.distX <= maxWidth && dstToSrc.distY >= 0 && dstToSrc.distY <= maxHeight ) { mask.data[indexMsk] = 1; } else { mask.data[indexMsk] = 0; } } } }
@Override public void applyOnlyInside( GrayU8 mask ) { float maxWidth = srcImg.getWidth()-1; float maxHeight = srcImg.getHeight()-1; for( int y = y0; y < y1; y++ ) { int indexDst = dstImg.startIndex + dstImg.stride*y + x0*dstImg.numBands; int indexMsk = mask.startIndex + mask.stride*y + x0; for( int x = x0; x < x1; x++ , indexDst += dstImg.numBands , indexMsk++) { dstToSrc.compute(x,y); if( dstToSrc.distX >= 0 && dstToSrc.distX <= maxWidth && dstToSrc.distY >= 0 && dstToSrc.distY <= maxHeight ) { interp.get(dstToSrc.distX, dstToSrc.distY, values); assign(indexDst,values); mask.data[indexMsk] = 1; } else { mask.data[indexMsk] = 0; } } } }