public static void convert(Frame input , ImageBase output , boolean swapRgb, GrowQueue_I8 work) { if( work == null ) work = new GrowQueue_I8(); Buffer data = input.image[0]; if( !(data instanceof ByteBuffer) ) { return; } ByteBuffer bb = (ByteBuffer)data; output.reshape(input.imageWidth,input.imageHeight); if( output instanceof Planar ) { ((Planar)output).setNumberOfBands(input.imageChannels); ConvertByteBufferImage.from_3BU8_to_3PU8(bb,0,input.imageStride,(Planar)output,work); if( swapRgb ) { BGR_to_RGB((Planar)output); } } else if( output instanceof ImageGray ) { ConvertByteBufferImage.from_3BU8_to_U8(bb,0,input.imageStride,(GrayU8)output,work); } else if( output instanceof ImageInterleaved) { ConvertByteBufferImage.from_3BU8_to_3IU8(bb,0,input.imageStride,(InterleavedU8)output); } else { throw new IllegalArgumentException("Unsupported output type"); } }
/** * Sets the values of each pixel equal to the pixels in the specified matrix. * Automatically resized to match the input image. * * @param orig The original image whose value is to be copied into this one */ @Override public void setTo( Planar<T> orig) { if (orig.width != width || orig.height != height) reshape(orig.width,orig.height); if( orig.getBandType() != getBandType() ) throw new IllegalArgumentException("The band type must be the same"); int N = orig.getNumBands(); if( N != getNumBands() ) { setNumberOfBands(orig.getNumBands()); } for( int i = 0; i < N; i++ ) { bands[i].setTo(orig.getBand(i)); } }
private void undoRadialDistortion(BufferedImage image) { if( undoRadial == null ) return; ConvertBufferedImage.convertFrom(image,origMS,true); if( correctedMS.getNumBands() != origMS.getNumBands() ) correctedMS.setNumberOfBands(origMS.getNumBands()); correctedMS.reshape(origMS.width,origMS.height); for( int i = 0; i < origMS.getNumBands(); i++ ) { GrayF32 in = origMS.getBand(i); GrayF32 out = correctedMS.getBand(i); undoRadial.apply(in,out); } undistorted = ConvertBufferedImage.checkDeclare(origMS.width,origMS.height,undistorted,image.getType()); ConvertBufferedImage.convertTo(correctedMS,undistorted,true); }