/** Gaussian Filtering of an ImageProcessor * @param ip The ImageProcessor to be filtered. * @param sigma Standard deviation of the Gaussian (pixels) * * @see ij.process.ImageProcessor#blurGaussian(double) */ public void blurGaussian(ImageProcessor ip, double sigma) { double accuracy = (ip instanceof ByteProcessor||ip instanceof ColorProcessor)?0.002:0.0002; blurGaussian(ip, sigma, sigma, accuracy); }
/** Gaussian Filtering of an ImageProcessor * @param ip The ImageProcessor to be filtered. * @param sigma Standard deviation of the Gaussian (pixels) * * @see ij.process.ImageProcessor#blurGaussian(double) */ public void blurGaussian(ImageProcessor ip, double sigma) { double accuracy = (ip instanceof ByteProcessor||ip instanceof ColorProcessor)?0.002:0.0002; blurGaussian(ip, sigma, sigma, accuracy); }
@Override public ImageProcessor process(ImageProcessor ip) { ij.plugin.filter.GaussianBlur g = new ij.plugin.filter.GaussianBlur(); g.blurGaussian(ip, sigmaX, sigmaY, accuracy); return ip; }
/** * Smooth with a Gaussian kernel that represents downsampling at a given * scale factor and sourceSigma. */ final static public void smoothForScale( final ImageProcessor source, final double scale, final float sourceSigma, final float targetSigma ) { final double s = targetSigma / scale; final double v = s * s - sourceSigma * sourceSigma; if ( v <= 0 ) return; final double sigma = Math.sqrt( v ); new GaussianBlur().blurGaussian( source, sigma, sigma, 0.01 ); }
/** * Smooth with a Gaussian kernel that represents downsampling at a given * scale factor and sourceSigma. */ final static public void smoothForScale( final ImageProcessor source, final float scale, final float sourceSigma, final float targetSigma ) { if ( scale >= 1.0f ) return; float s = targetSigma / scale; float sigma = ( float )Math.sqrt( s * s - sourceSigma * sourceSigma ); new GaussianBlur().blurGaussian( source, sigma, sigma, 0.01 ); }
/** * Smooth with a Gaussian kernel that represents downsampling at a given * scale factor and sourceSigma. */ final static public void smoothForScale( final ImageProcessor source, final double scale, final float sourceSigma, final float targetSigma ) { final double s = targetSigma / scale; final double v = s * s - sourceSigma * sourceSigma; if ( v <= 0 ) return; final double sigma = Math.sqrt( v ); new GaussianBlur().blurGaussian( source, sigma, sigma, 0.01 ); }
/** Blurs the image by convolving with a Gaussian function. */ public void blurGaussian(double sigma) { resetRoi(); GaussianBlur gb = new GaussianBlur(); gb.showProgress(false); gb.blurGaussian(this, sigma); }
/** This method is invoked for each slice during execution * @param ip The image subject to filtering. It must have a valid snapshot if * the height of the roi is less than the full image height. */ public void run(ImageProcessor ip) { double sigmaX = sigmaScaled ? sigma/imp.getCalibration().pixelWidth : sigma; double sigmaY = sigmaScaled ? sigma/imp.getCalibration().pixelHeight : sigma; double accuracy = (ip instanceof ByteProcessor || ip instanceof ColorProcessor) ? 0.002 : 0.0002; Rectangle roi = ip.getRoi(); blurGaussian(ip, sigmaX, sigmaY, accuracy); }
/** Unsharp Mask filtering of a float image. 'fp' must have a valid snapshot. */ public void sharpenFloat(FloatProcessor fp, double sigma, float weight) { if (gb == null) gb = new GaussianBlur(); gb.blurGaussian(fp, sigma, sigma, 0.01); if (Thread.currentThread().isInterrupted()) return; float[] pixels = (float[])fp.getPixels(); float[] snapshotPixels = (float[])fp.getSnapshotPixels(); int width = fp.getWidth(); Rectangle roi = fp.getRoi(); for (int y=roi.y; y<roi.y+roi.height; y++) for (int x=roi.x, p=width*y+x; x<roi.x+roi.width; x++,p++) pixels[p] = (snapshotPixels[p] - weight*pixels[p])/(1f - weight); }
/** This method is invoked for each slice during execution * @param ip The image subject to filtering. It must have a valid snapshot if * the height of the roi is less than the full image height. */ public void run(ImageProcessor ip) { double sigmaX = sigmaScaled ? sigma/imp.getCalibration().pixelWidth : sigma; double sigmaY = sigmaScaled ? sigma/imp.getCalibration().pixelHeight : sigma; double accuracy = (ip instanceof ByteProcessor || ip instanceof ColorProcessor) ? 0.002 : 0.0002; Rectangle roi = ip.getRoi(); blurGaussian(ip, sigmaX, sigmaY, accuracy); }
/** Blurs the image by convolving with a Gaussian function. */ public void blurGaussian(double sigma) { resetRoi(); GaussianBlur gb = new GaussianBlur(); gb.showProgress(false); gb.blurGaussian(this, sigma); }
/** Unsharp Mask filtering of a float image. 'fp' must have a valid snapshot. */ public void sharpenFloat(FloatProcessor fp, double sigma, float weight) { if (gb == null) gb = new GaussianBlur(); gb.blurGaussian(fp, sigma, sigma, 0.01); if (Thread.currentThread().isInterrupted()) return; float[] pixels = (float[])fp.getPixels(); float[] snapshotPixels = (float[])fp.getSnapshotPixels(); int width = fp.getWidth(); Rectangle roi = fp.getRoi(); for (int y=roi.y; y<roi.y+roi.height; y++) for (int x=roi.x, p=width*y+x; x<roi.x+roi.width; x++,p++) pixels[p] = (snapshotPixels[p] - weight*pixels[p])/(1f - weight); }
/** Gaussian Filtering of an ImageProcessor. This method is for compatibility with the * previous code (before 1.38r) and uses a low-accuracy kernel, only slightly better * than the previous ImageJ code. * The 'radius' in this call is different from the one used in ImageJ 1.38r and later. * Therefore, use blurGaussian(ip, sigma, sigma, accuracy), where 'sigma' is equivalent * to the 'sigma (radius)' of the Menu, and accuracy should be 0.02 unless better * accuracy is desired. */ @Deprecated public boolean blur(ImageProcessor ip, double radius) { Rectangle roi = ip.getRoi(); if (roi.height!=ip.getHeight() && ip.getMask()==null) ip.snapshot(); // a snapshot is needed for out-of-Rectangle pixels blurGaussian(ip, 0.4*radius, 0.4*radius, 0.01); return true; }
/** Gaussian Filtering of an ImageProcessor. This method is for compatibility with the * previous code (before 1.38r) and uses a low-accuracy kernel, only slightly better * than the previous ImageJ code. * The 'radius' in this call is different from the one used in ImageJ 1.38r and later. * Therefore, use blurGaussian(ip, sigma, sigma, accuracy), where 'sigma' is equivalent * to the 'sigma (radius)' of the Menu, and accuracy should be 0.02 unless better * accuracy is desired. */ @Deprecated public boolean blur(ImageProcessor ip, double radius) { Rectangle roi = ip.getRoi(); if (roi.height!=ip.getHeight() && ip.getMask()==null) ip.snapshot(); // a snapshot is needed for out-of-Rectangle pixels blurGaussian(ip, 0.4*radius, 0.4*radius, 0.01); return true; }
public ImagePlus call(){ ImageProcessor ip = originalImage.getProcessor().duplicate(); GaussianBlur gs = new GaussianBlur(); //gs.blur(ip, sigma); gs.blurGaussian(ip, 0.4 * sigma, 0.4 * sigma, 0.0002); return new ImagePlus (availableFeatures[GAUSSIAN] + "_" + sigma, ip); } };
public ImagePlus call(){ ImageProcessor ip = originalImage.getProcessor().duplicate(); GaussianBlur gs = new GaussianBlur(); //gs.blur(ip, sigma); gs.blurGaussian(ip, 0.4 * sigma, 0.4 * sigma, 0.0002); return new ImagePlus (availableFeatures[GAUSSIAN] + "_" + sigma, ip); } };
/** * Add Gaussian blur slice to current stack * @param sigma Gaussian radius */ public void addGaussianBlur(float sigma) { ImageProcessor ip = originalImage.getProcessor().duplicate(); GaussianBlur gs = new GaussianBlur(); //gs.blur(ip, sigma); gs.blurGaussian(ip, 0.4 * sigma, 0.4 * sigma, 0.0002); wholeStack.addSlice(availableFeatures[GAUSSIAN] + "_" + sigma, ip); } /**
/** * Add Gaussian blur slice to current stack * @param sigma Gaussian radius */ public void addGaussianBlur(float sigma) { ImageProcessor ip = originalImage.getProcessor().duplicate(); GaussianBlur gs = new GaussianBlur(); //gs.blur(ip, sigma); gs.blurGaussian(ip, 0.4 * sigma, 0.4 * sigma, 0.0002); wholeStack.addSlice(availableFeatures[GAUSSIAN] + "_" + sigma, ip); } /**
public Pair<ColorProcessor, ByteProcessor> makeFlatColorImage() { if ( canUseAWTImage() ) { // less than 0.5 GB array size final ColorProcessor cp = new ColorProcessor( createAWTImage( ImagePlus.COLOR_RGB ) ); final ByteProcessor alpha = new ByteProcessor( cp.getWidth(), cp.getHeight(), cp.getChannel( 4 ) ); return new Pair<ColorProcessor, ByteProcessor>( cp, alpha ); } if ( !isSmallerThan2GB() ) { Utils.log("Cannot create an image larger than 2 GB."); return null; } if ( loader.isMipMapsRegenerationEnabled() ) { return ExportARGB.makeFlatImageARGBFromMipMaps( patches, finalBox, 0, scale ); } // No mipmaps: create an image as large as possible, then downsample it final Pair<ColorProcessor, ByteProcessor> pair = ExportARGB.makeFlatImageARGBFromOriginals( patches, finalBox, 0, scaleUP ); final double sigma = computeSigma( pair.a.getWidth(), pair.a.getHeight()); new GaussianBlur().blurGaussian( pair.a, sigma, sigma, 0.0002 ); new GaussianBlur().blurGaussian( pair.b, sigma, sigma, 0.0002 ); return pair; }
public static void blur(ImagePlus imp, double sigmaX, double sigmaY, double sigmaZ) { imp.deleteRoi(); ImageStack stack = imp.getStack(); if (sigmaX>0.0 || sigmaY>0.0) { GaussianBlur gb = new GaussianBlur(); int channels = stack.getProcessor(1).getNChannels(); gb.setNPasses(channels*imp.getStackSize()); for (int i=1; i<=imp.getStackSize(); i++) { ImageProcessor ip = stack.getProcessor(i); double accuracy = (imp.getBitDepth()==8||imp.getBitDepth()==24)?0.002:0.0002; gb.blurGaussian(ip, sigmaX, sigmaY, accuracy); } } if (sigmaZ>0.0) { if (imp.isHyperStack()) blurHyperStackZ(imp, sigmaZ); else blurZ(stack, sigmaZ); imp.updateAndDraw(); } }