public static <K extends KernelBase, T extends ImageGray> Class<K> getKernelType(ImageDataType type , int DOF ) { if( type == ImageDataType.F32 ) { if( DOF == 1 ) return (Class)Kernel1D_F32.class; else return (Class)Kernel2D_F32.class; } else if( type.isInteger() ) { if( DOF == 1 ) return (Class)Kernel1D_S32.class; else return (Class)Kernel2D_S32.class; } throw new IllegalArgumentException("Unknown image type: "+type); }
public static <T extends KernelBase> T createKernelForImage( int width , int offset, int DOF , ImageDataType type ) { boolean isFloat = !type.isInteger(); int numBits = Math.max(32, type.getNumBits()); return createKernel(width,offset,DOF,isFloat,numBits); }
public static ImageDataType convertToGenericType(ImageDataType type) { if (type.isInteger()) { if (type.getNumBits() == 8) return ImageDataType.I8; else if (type.getNumBits() == 16) return ImageDataType.I16; } return type; }
public static Kernel2D convertToKernel( ImageGray image ) { if( image.getDataType().isInteger() ) { return KernelMath.convertToKernel((GrayI)image); } else { return KernelMath.convertToKernel((GrayF32)image); } } }
public static void process(ImageGray input , ImageGray output, int radius ) { if( input.getDataType().isInteger() ) { process((GrayI)input, (GrayI)output, radius, null); } else { process((GrayF32)input, (GrayF32)output, radius, null); } }
public static <T extends ImageGray<T>, K extends Kernel2D> K gaussian2D(ImageDataType imageType, double sigma, int radius ) { int numBits = imageType.getNumBits() <= 32 ? 32 : imageType.getNumBits(); return gaussian(2,!imageType.isInteger(), numBits, sigma,radius); }
public static void print(ImageGray a) { if( a.getDataType().isInteger() ) { print((GrayI)a); } else if( a instanceof GrayF32) { print((GrayF32)a); } else { print((GrayF64)a); } }
/** * <p> * Renders a gray scale image using color values from cold to hot. * </p> * * @param src Input single band image. * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param normalize Used to normalize the input image. * @return Rendered image. */ public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) { if (normalize < 0) normalize = GImageStatistics.maxAbs(src); dst = checkInputs(src, dst); if (src.getDataType().isInteger()) { return grayMagnitudeTemp((GrayI) src, dst, (int) normalize); } else { throw new RuntimeException("Add support"); } }
/** * <p> * Renders a gray scale image using color values from cold to hot. * </p> * * @param src Input single band image. * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param normalize Used to normalize the input image. * @return Rendered image. */ public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) { if (normalize < 0) normalize = GImageStatistics.maxAbs(src); dst = checkInputs(src, dst); if (src.getDataType().isInteger()) { return grayMagnitudeTemp((GrayI) src, dst, (int) normalize); } else { throw new RuntimeException("Add support"); } }
/** * <p> * Renders a gray scale image using color values from cold to hot. * </p> * * @param disparity Input disparity image * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param minDisparity Minimum disparity that can be computed * @param maxDisparity Maximum disparity that can be computed * @param invalidColor RGB value for invalid pixels. Try 0xFF << 8 for green * @return Rendered image. */ public static BufferedImage disparity(ImageGray disparity, BufferedImage dst, int minDisparity, int maxDisparity, int invalidColor) { if( dst == null ) dst = new BufferedImage(disparity.getWidth(),disparity.getHeight(),BufferedImage.TYPE_INT_RGB); if (disparity.getDataType().isInteger()) { return disparity((GrayI) disparity, dst, minDisparity, maxDisparity, invalidColor); } else if (disparity instanceof GrayF32) { return disparity((GrayF32) disparity, dst, minDisparity, maxDisparity, invalidColor); } else { throw new RuntimeException("Add support"); } }
/** * <p> * Renders a gray scale image using color values from cold to hot. * </p> * * @param disparity Input disparity image * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param minDisparity Minimum disparity that can be computed * @param maxDisparity Maximum disparity that can be computed * @param invalidColor RGB value for invalid pixels. Try 0xFF << 8 for green * @return Rendered image. */ public static BufferedImage disparity(ImageGray disparity, BufferedImage dst, int minDisparity, int maxDisparity, int invalidColor) { if( dst == null ) dst = new BufferedImage(disparity.getWidth(),disparity.getHeight(),BufferedImage.TYPE_INT_RGB); if (disparity.getDataType().isInteger()) { return disparity((GrayI) disparity, dst, minDisparity, maxDisparity, invalidColor); } else if (disparity instanceof GrayF32) { return disparity((GrayF32) disparity, dst, minDisparity, maxDisparity, invalidColor); } else { throw new RuntimeException("Add support"); } }
/** * <p> * Renders a gray scale image of the input image's intensity.<br> * <br> * dst(i,j) = 255*abs(src(i,j))/normalize * </p> * * @param src Input single band image. * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param normalize Used to normalize the input image. If < 0 then this value is automatically computed. * @return Rendered image. */ public static BufferedImage grayMagnitude(ImageGray src, BufferedImage dst, double normalize) { if (normalize < 0) normalize = GImageStatistics.maxAbs(src); dst = checkInputs(src, dst); if (src.getDataType().isInteger()) { return grayMagnitude((GrayI) src, dst, (int) normalize); } else if( src instanceof GrayF32){ return grayMagnitude((GrayF32) src, dst, (float) normalize); } else if( src instanceof GrayF64){ return grayMagnitude((GrayF64) src, dst, (float) normalize); } else { throw new RuntimeException("Unsupported type"); } }
/** * Default wavelet transform used for denoising images. */ private static WaveletTransform createDefaultShrinkTransform(ImageDataType imageType, int numLevels, double minPixelValue , double maxPixelValue ) { WaveletTransform descTran; if( !imageType.isInteger()) { WaveletDescription<WlCoef_F32> waveletDesc_F32 = FactoryWaveletDaub.daubJ_F32(4); descTran = FactoryWaveletTransform.create_F32(waveletDesc_F32,numLevels, (float)minPixelValue,(float)maxPixelValue); } else { WaveletDescription<WlCoef_I32> waveletDesc_I32 = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT); descTran = FactoryWaveletTransform.create_I(waveletDesc_I32,numLevels, (int)minPixelValue,(int)maxPixelValue, ImageType.getImageClass(ImageType.Family.GRAY, imageType)); } return descTran; }
/** * <p> * Renders a gray scale image of the input image's intensity.<br> * <br> * dst(i,j) = 255*abs(src(i,j))/normalize * </p> * * @param src Input single band image. * @param dst Where the image is rendered into. If null a new BufferedImage will be created and return. * @param normalize Used to normalize the input image. If < 0 then this value is automatically computed. * @return Rendered image. */ public static BufferedImage grayMagnitude(ImageGray src, BufferedImage dst, double normalize) { if (normalize < 0) normalize = GImageStatistics.maxAbs(src); dst = checkInputs(src, dst); if (src.getDataType().isInteger()) { return grayMagnitude((GrayI) src, dst, (int) normalize); } else if( src instanceof GrayF32){ return grayMagnitude((GrayF32) src, dst, (float) normalize); } else if( src instanceof GrayF64){ return grayMagnitude((GrayF64) src, dst, (float) normalize); } else { throw new RuntimeException("Unsupported type"); } }
/** * Sets the input image. Must be called before other functions/ * * @param gray input image */ public void setImage(T gray) { integral.reshape(gray.width,gray.height); integralSq.reshape(gray.width,gray.height); GIntegralImageOps.transform(gray,integral); if( gray.getDataType().isInteger()) transformSq((GrayU8)gray,(GrayS64)integralSq); else transformSq((GrayF32)gray,(GrayF64)integralSq); }
/** * Configuration constructor * @param distort Used to apply image distortion from different input images * @param equiWidth Width of output equirectangular image * @param equiHeight Height of output equirectangular image * @param imageType Type of image it processes and outputs. Must be floating point. Hmm why isn't this fixed? */ public MultiCameraToEquirectangular(ImageDistort<T,T> distort , int equiWidth , int equiHeight , ImageType<T> imageType ) { if( imageType.getDataType().isInteger() || imageType.getDataType().getNumBits() != 32 ) throw new IllegalArgumentException("Must be a 32 bit floating point image"); this.distort = distort; this.equiWidth = equiWidth; this.equHeight = equiHeight; tools.configure(equiWidth, equiHeight); weightImage = new GrayF32(equiWidth,equiHeight); averageImage = imageType.createImage(equiWidth, equiHeight); workImage = averageImage.createSameShape(); cameraRendered = averageImage.createSameShape(); }
/** * Configuration constructor * @param distort Used to apply image distortion from different input images * @param equiWidth Width of output equirectangular image * @param equiHeight Height of output equirectangular image * @param imageType Type of image it processes and outputs. Must be floating point. Hmm why isn't this fixed? */ public MultiCameraToEquirectangular(ImageDistort<T,T> distort , int equiWidth , int equiHeight , ImageType<T> imageType ) { if( imageType.getDataType().isInteger() || imageType.getDataType().getNumBits() != 32 ) throw new IllegalArgumentException("Must be a 32 bit floating point image"); this.distort = distort; this.equiWidth = equiWidth; this.equHeight = equiHeight; tools.configure(equiWidth, equiHeight); weightImage = new GrayF32(equiWidth,equiHeight); averageImage = imageType.createImage(equiWidth, equiHeight); workImage = averageImage.createSameShape(); cameraRendered = averageImage.createSameShape(); }
public static ImageBorder wrap(ImageGray image , double value ) { if( image.getDataType().isInteger() ) { if( image.getDataType().getNumBits() <= 32 ) return wrap((GrayI)image,(int)value); else return wrap((GrayS64)image,(long)value); } else if( image.getDataType().getDataType() == float.class ) { return wrap((GrayF32)image,(float)value); } else { return wrap((GrayF64)image,value); } }
public static BufferedImage standard(ImageGray<?> src, BufferedImage dst) { if (src.getDataType().isInteger()) { GrayI srcInt = (GrayI) src;
public static BufferedImage standard(ImageGray<?> src, BufferedImage dst) { if (src.getDataType().isInteger()) { GrayI srcInt = (GrayI) src;