@Override public InterleavedU8 createNew(int imgWidth, int imgHeight) { if (imgWidth == -1 || imgHeight == -1) return new InterleavedU8(); return new InterleavedU8(imgWidth, imgHeight, numBands); } }
public ThresholdBlockMinMax_U8(double minimumSpread, ConfigLength requestedBlockWidth, double scale , boolean down, boolean thresholdFromLocalBlocks) { super(minimumSpread,requestedBlockWidth,thresholdFromLocalBlocks,GrayU8.class); stats = new InterleavedU8(1,1,2); this.scale = scale; this.down = down; }
/** * Converts an NV21 image into a {@link InterleavedU8} RGB image. * * @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 InterleavedU8 nv21ToInterleaved( byte[] data , int width , int height , InterleavedU8 output ) { if( output == null ) { output = new InterleavedU8(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.nv21ToInterleaved_U8(data, output); return output; }
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; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedF64} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedF64 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS64} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedS64 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedF32} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedF32 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS32} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedS32 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS8} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedS8 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedU16} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedU16 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS16} into a {@link boofcv.struct.image.InterleavedU8}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedU8 convert(InterleavedS16 input, InterleavedU8 output) { if (output == null) { output = new InterleavedU8(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
public static InterleavedU8 yuvToInterleavedRgbU8(ByteBuffer bufferY, ByteBuffer bufferU , ByteBuffer bufferV , int width, int height, int strideY , int strideUV , int stridePixelUV, InterleavedU8 output , byte work[] ) { if( output != null ) { output.reshape(width,height,3); } else { output = new InterleavedU8(width,height,3); } InterleavedU8 _output = output; ProcessorYuv processor = new ProcessorYuvRgb() { int indexOut = 0; @Override public void processRGB( final int r , final int g , final int b ) { _output.data[indexOut++] = (byte)r; _output.data[indexOut++] = (byte)g; _output.data[indexOut++] = (byte)b; } }; processYuv(bufferY,bufferU,bufferV,width,height,strideY,strideUV,stridePixelUV,work,processor); return output; }
public static InterleavedU8 yuvToInterleavedYuvU8(ByteBuffer bufferY, ByteBuffer bufferU , ByteBuffer bufferV , int width, int height, int strideY , int strideUV , int stridePixelUV, InterleavedU8 output , byte work[] ) { if( output != null ) { output.reshape(width,height,3); } else { output = new InterleavedU8(width,height,3); } final byte[] data = output.data; ProcessorYuv processor = new ProcessorYuv() { int indexOut = 0; @Override final public void processYUV(final int y, final int u, final int v) { data[indexOut++] = (byte)y; data[indexOut++] = (byte)u; data[indexOut++] = (byte)v; } }; processYuv(bufferY,bufferU,bufferV,width,height,strideY,strideUV,stridePixelUV,work,processor); return output; } }
/** * For BufferedImage stored as a byte array internally it extracts an * interleaved image. The input image and the returned image will both * share the same internal data array. Using this function allows unnecessary * memory copying to be avoided. * * @param img Image whose internal data is extracted and wrapped. * @return An image whose internal data is the same as the input image. */ public static InterleavedU8 extractInterleavedU8(BufferedImage img) { if (img.getRaster() instanceof ByteInterleavedRaster && img.getType() != BufferedImage.TYPE_BYTE_INDEXED ) { ByteInterleavedRaster raster = (ByteInterleavedRaster) img.getRaster(); InterleavedU8 ret = new InterleavedU8(); ret.width = img.getWidth(); ret.height = img.getHeight(); ret.stride = raster.getScanlineStride(); ret.startIndex = raster.getDataOffset(0)-raster.getPixelStride()+1; ret.setNumBands( raster.getNumBands() ); ret.data = raster.getDataStorage(); return ret; } throw new IllegalArgumentException("Buffered image does not have an interleaved byte raster"); }
/** * Converts a {@link Planar} {@link GrayF32} into the equivalent {@link InterleavedU8} * * @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 InterleavedU8 convertF32U8(Planar<GrayF32> input , InterleavedU8 output ) { if (output == null) { output = new InterleavedU8(input.width,input.height,input.getNumBands()); } else { output.reshape(input.width,input.height,input.getNumBands()); } ImplConvertImage.convertF32U8(input,output); return output; }
/** * Converts a {@link Planar} into the equivalent {@link InterleavedU8} * * @param input (Input) Planar image 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 InterleavedU8 convert( Planar<GrayU8> input , InterleavedU8 output ) { if (output == null) { output = new InterleavedU8(input.width, input.height,input.getNumBands()); } else { output.reshape(input.width,input.height,input.getNumBands()); } ImplConvertImage.convert(input,output); return output; }
public static <T extends ImageInterleaved<T>> T createInterleaved(Class<T> type, int width, int height , int numBands) { type = BoofTesting.convertGenericToSpecificType(type); if (type == InterleavedU8.class) { return (T)new InterleavedU8(width, height,numBands); } else if (type == InterleavedS8.class) { return (T)new InterleavedS8(width, height,numBands); } else if (type == InterleavedU16.class) { return (T)new InterleavedU16(width, height,numBands); } else if (type == InterleavedS16.class) { return (T)new InterleavedS16(width, height,numBands); } else if (type == InterleavedS32.class) { return (T)new InterleavedS32(width, height,numBands); } else if (type == InterleavedS64.class) { return (T)new InterleavedS64(width, height,numBands); } else if (type == InterleavedF32.class) { return (T)new InterleavedF32(width, height,numBands); } else if (type == InterleavedF64.class) { return (T)new InterleavedF64(width, height,numBands); } else if( (Class)type == ImageInterleaved.class ) { // ImageInteger is a generic type, so just create something return (T)new InterleavedS32(width,height,numBands); } throw new RuntimeException("Unknown type: "+type.getSimpleName()); }