public static ImagePanel showWindow(ImageGray img , String title , boolean showMagnitude) { double max = GImageStatistics.maxAbs(img); BufferedImage buff; if( showMagnitude ) buff = VisualizeImageData.grayMagnitude(img,null,max); else buff = VisualizeImageData.colorizeSign(img,null,max); return showWindow(buff,title); } }
public static ImagePanel showWindow(ImageGray img , String title , boolean showMagnitude) { double max = GImageStatistics.maxAbs(img); BufferedImage buff; if( showMagnitude ) buff = VisualizeImageData.grayMagnitude(img,null,max); else buff = VisualizeImageData.colorizeSign(img,null,max); return showWindow(buff,title); } }
/** * <p> * Renders a colored image where the color indicates the sign and intensity its magnitude. The input is divided * by normalize to render it in the appropriate scale. * </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 the max value will be used * @return Rendered image. */ public static BufferedImage colorizeSign(ImageGray src, BufferedImage dst, double normalize) { dst = checkInputs(src, dst); if (normalize <= 0) { normalize = GImageStatistics.maxAbs(src); } if (normalize == 0) { // sets the output to black ConvertBufferedImage.convertTo(src,dst,true); return dst; } if (src.getClass().isAssignableFrom(GrayF32.class)) { return colorizeSign((GrayF32) src, dst, (float) normalize); } else { return colorizeSign((GrayI) src, dst, (int) normalize); } }
/** * <p> * Renders a colored image where the color indicates the sign and intensity its magnitude. The input is divided * by normalize to render it in the appropriate scale. * </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 the max value will be used * @return Rendered image. */ public static BufferedImage colorizeSign(ImageGray src, BufferedImage dst, double normalize) { dst = checkInputs(src, dst); if (normalize <= 0) { normalize = GImageStatistics.maxAbs(src); } if (normalize == 0) { // sets the output to black ConvertBufferedImage.convertTo(src,dst,true); return dst; } if (src.getClass().isAssignableFrom(GrayF32.class)) { return colorizeSign((GrayF32) src, dst, (float) normalize); } else { return colorizeSign((GrayI) src, dst, (int) normalize); } }
/** * <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"); } }
@Override public void setActiveAlgorithm(int indexFamily, String name, final Object cookie) { if( image == null ) return; D derivX = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height); D derivY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height); panel.reset(); Helper h = (Helper)cookie; D derivXX = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height); D derivYY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height); D derivXY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height); h.gradient.process(image,derivX,derivY); h.hessian.process(derivX,derivY,derivXX,derivYY,derivXY); double max; max = GImageStatistics.maxAbs(derivX); panel.addImage(VisualizeImageData.colorizeSign(derivX,null,max),"X-derivative"); max = GImageStatistics.maxAbs(derivY); panel.addImage(VisualizeImageData.colorizeSign(derivY,null,max),"Y-derivative"); max = GImageStatistics.maxAbs(derivXX); panel.addImage(VisualizeImageData.colorizeSign(derivXX,null,max),"XX-derivative"); max = GImageStatistics.maxAbs(derivYY); panel.addImage(VisualizeImageData.colorizeSign(derivYY,null,max),"YY-derivative"); max = GImageStatistics.maxAbs(derivXY); panel.addImage(VisualizeImageData.colorizeSign(derivXY,null,max),"XY-derivative"); processedImage = true; repaint(); }
/** * <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"); } }
/** * <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"); } }
@Override public void setActiveAlgorithm(String name, Object cookie) { DerivType type = (DerivType)cookie; panel.reset(); for( int radius = 1; radius <= 40; radius += 2 ) { int maxOrder = Math.max(type.orderX,type.orderY); double sigma = FactoryKernelGaussian.sigmaForRadius(radius,maxOrder); Class typeKer1 = FactoryKernel.getKernelType(imageType,1); Kernel1D kerX = FactoryKernelGaussian.derivativeK(typeKer1,type.orderX,sigma,radius); Kernel1D kerY = FactoryKernelGaussian.derivativeK(typeKer1,type.orderY,sigma,radius); Kernel2D kernel = GKernelMath.convolve(kerY, kerX); T smallImg = GKernelMath.convertToImage(kernel); new FDistort(smallImg,largeImg).interpNN().scaleExt().apply(); double maxValue = GImageStatistics.maxAbs(largeImg); BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue); panel.addImage(out,String.format("%5d",radius)); } }
@Override public void setActiveAlgorithm(String name, Object cookie) { DisplayGaussianKernelApp.DerivType dt = (DisplayGaussianKernelApp.DerivType)cookie; // add basis SteerableKernel<K> steerable = createKernel(dt.orderX,dt.orderY); basisPanel.reset(); for( int i = 0; i < steerable.getBasisSize(); i++ ) { T smallImg = GKernelMath.convertToImage(steerable.getBasis(i)); new FDistort(smallImg,largeImg).scaleExt().interpNN().apply(); double maxValue = GImageStatistics.maxAbs(largeImg); BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue); basisPanel.addImage(out,"Basis "+i); } // add steered kernels steerPanel.reset(); for( int i = 0; i <= 20; i++ ) { double angle = Math.PI*i/20.0; K kernel = steerable.compute(angle); T smallImg = GKernelMath.convertToImage(kernel); new FDistort(smallImg,largeImg).scaleExt().interpNN().apply(); double maxValue = GImageStatistics.maxAbs(largeImg); BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue); steerPanel.addImage(out,String.format("%5d",(int)(180.0*angle/Math.PI))); } repaint(); }