public static GImageMultiBand wrap( ImageInterleaved image ) { switch( image.getDataType() ) { case U8: return new IL_U8((InterleavedU8)image); case S8: return new IL_S8((InterleavedS8)image); case U16: return new IL_U16((InterleavedU16)image); case S16: return new IL_S16((InterleavedS16)image); case S32: return new IL_S32((InterleavedS32)image); case S64: return new IL_S64((InterleavedS64)image); case F32: return new IL_F32((InterleavedF32)image); case F64: return new IL_F64((InterleavedF64)image); default: throw new IllegalArgumentException("Need to support more data types: "+image.getDataType()); } }
public static <T extends ImageInterleaved>T convertFrom( IplImage input , T output ) { ImageDataType dataType = depthToBoofType(input.depth()); int numBands = input.nChannels(); int width = input.width(); int height = input.height(); if( output != null ) { if( output.isSubimage() ) throw new IllegalArgumentException("Can't handle sub-images"); if( output.getDataType() != dataType ) throw new IllegalArgumentException("Expected data type of " +dataType+" found "+output.getDataType()+" instead"); output.numBands = numBands; output.reshape(width,height); } else { output = GeneralizedImageOps.createInterleaved(dataType,width,height,numBands); } switch( dataType ) { case U8: case S8: convertFrom_I(input,(InterleavedI8)output); break; case S16: convertFrom_I(input,(InterleavedS16)output); break; case S32: convertFrom_I(input,(InterleavedS32)output); break; case F32: convertFrom_I(input,(InterleavedF32)output); break; case F64: convertFrom_I(input,(InterleavedF64)output); break; default: throw new RuntimeException("Add support for type "+dataType); } return output; }
public static <T extends ImageInterleaved<T>>T convertFrom( IplImage input , T output ) { ImageDataType dataType = depthToBoofType(input.depth()); int numBands = input.nChannels(); int width = input.width(); int height = input.height(); if( output != null ) { if( output.isSubimage() ) throw new IllegalArgumentException("Can't handle sub-images"); if( output.getDataType() != dataType ) throw new IllegalArgumentException("Expected data type of " +dataType+" found "+output.getDataType()+" instead"); output.numBands = numBands; output.reshape(width,height); } else { output = (T)GeneralizedImageOps.createInterleaved(dataType,width,height,numBands); } switch( dataType ) { case U8: case S8: convertFrom_I(input,(InterleavedI8)output); break; case S16: convertFrom_I(input,(InterleavedS16)output); break; case S32: convertFrom_I(input,(InterleavedS32)output); break; case F32: convertFrom_I(input,(InterleavedF32)output); break; case F64: convertFrom_I(input,(InterleavedF64)output); break; default: throw new RuntimeException("Add support for type "+dataType); } return output; }