@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 FloatProcessor source, final double scale, final float sourceSigma, final float targetSigma ) { assert scale <= 1.0f : "Downsampling requires a scale factor < 1.0"; final double s = targetSigma / scale; final double v = s * s - sourceSigma * sourceSigma; if ( v <= 0 ) return; final float sigma = ( float )Math.sqrt( v ); // final float[] kernel = createNormalizedGaussianKernel( sigma ); // convolveSeparable( source, kernel, kernel ); new GaussianBlur().blurFloat( source, sigma, sigma, 0.01 ); }
/** Since most computing time is spent in GaussianBlur, forward the * information about the number of passes to Gaussian Blur. The * ProgressBar will be handled by GaussianBlur. */ public void setNPasses(int nPasses) { if (gb == null) gb = new GaussianBlur(); gb.setNPasses(nPasses); } }
/** 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); }
protected void applySmoothingFilter(double rad) { float[] pixels = new float[gridHeight*gridWidth]; for (int i=0; i < gridHeight*gridWidth; i++) { pixels[i] = (float) plotList[i].lum; } ImageProcessor ip = new FloatProcessor(gridWidth, gridHeight, pixels, null); new GaussianBlur().blur(ip, rad); // reset progress bar (which was set by gaussian blur) IJ.showProgress( 1.); // ImagePlus imp2 = new ImagePlus("test", ip); // imp2.show(); // imp2.updateAndDraw(); pixels = (float[] )ip.getPixels(); for (int i=0; i < gridHeight*gridWidth; i++) { plotList[i].z = plotList[i].zf = pixels[i]; } applyMinMax(); }
importClass(Packages.ij.plugin.filter.GaussianBlur); var imp = IJ.openImage("http://imagej.nih.gov/ij/images/clown.jpg"); IJ.run(imp, "8-bit", ""); var ip = imp.getProcessor(); var gs = new GaussianBlur(); gs.blurGaussian(ip,20,20,0.01); imp.show();
int[] smooth(int[] a, int n) { FloatProcessor fp = new FloatProcessor(n, 1); for (int i=0; i<n; i++) fp.putPixelValue(i, 0, a[i]); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); for (int i=0; i<n; i++) a[i] = (int)Math.round(fp.getPixelValue(i, 0)); return a; }
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(); } }
private static void blurZ(ImageStack stack, double sigmaZ) { GaussianBlur gb = new GaussianBlur(); double accuracy = (stack.getBitDepth()==8||stack.getBitDepth()==24)?0.002:0.0002; int w=stack.getWidth(), h=stack.getHeight(), d=stack.getSize(); float[] zpixels = null; FloatProcessor fp =null; IJ.showStatus("Z blurring"); gb.showProgress(false); int channels = stack.getProcessor(1).getNChannels(); for (int y=0; y<h; y++) { IJ.showProgress(y, h-1); for (int channel=0; channel<channels; channel++) { zpixels = stack.getVoxels(0, y, 0, w, 1, d, zpixels, channel); if (fp==null) fp = new FloatProcessor(w, d, zpixels); //if (y==h/2) new ImagePlus("before-"+h/2, fp.duplicate()).show(); gb.blur1Direction(fp, sigmaZ, accuracy, false, 0); stack.setVoxels(0, y, 0, w, 1, d, zpixels, channel); } } IJ.showStatus(""); }
GaussianBlur gaussianBlur = new GaussianBlur(); gaussianBlur.load(); gaussianBlur.attributes.set("radius",15); gaussianBlur.process(image.clone(), image, mask1); gaussianBlur.process(image.clone(), image, mask2); gaussianBlur.process(image.clone(), image, mask3); gaussianBlur.process(image.clone(), image, mask4);
/** 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 sigmaX Standard deviation of the Gaussian in x direction (pixels) * @param sigmaY Standard deviation of the Gaussian in y direction (pixels) * @param accuracy Accuracy of kernel, should not be above 0.02. Better (lower) * accuracy needs slightly more computing time. */ public void blurGaussian(ImageProcessor ip, double sigmaX, double sigmaY, double accuracy) { boolean hasRoi = ip.getRoi().height!=ip.getHeight() && sigmaX>0 && sigmaY>0; if (hasRoi && !calledAsPlugin) ip.snapshot(); if (nPasses<=1) nPasses = ip.getNChannels() * (sigmaX>0 && sigmaY>0 ? 2 : 1); FloatProcessor fp = null; for (int i=0; i<ip.getNChannels(); i++) { fp = ip.toFloat(i, fp); if (Thread.currentThread().isInterrupted()) return; // interruption for new parameters during preview? blurFloat(fp, sigmaX, sigmaY, accuracy); if (Thread.currentThread().isInterrupted()) return; ip.setPixels(i, fp); } if (hasRoi) resetOutOfRoi(ip, (int)Math.ceil(5*sigmaY)); // reset out-of-Rectangle pixels above and below roi return; }
filter.blurFloat( ipD, sigma, sigma, 0.002 );
GaussianBlur blurImage= new GaussianBlur(); pos = 0; for(channel = 0; channel < 3; channel++){ blurImage= new GaussianBlur(); blurImage.blur(imProcBGR[channel],(double)RetinexScales[scale]*2.5); //2.5 is the difference between IJ blur and photoshop's see ImageJ API out=(float[]) imProcBGR[channel].getPixelsCopy();
GaussianBlur blurEffect = new GaussianBlur(5); root.setEffect(blurEffect);
float[] smooth(float[] a, int n) { FloatProcessor fp = new FloatProcessor(n, 1); for (int i=0; i<n; i++) fp.setf(i, 0, a[i]); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); for (int i=0; i<n; i++) a[i] = fp.getf(i, 0); return a; }
/** 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); }
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(); } }
private static void blurZ(ImageStack stack, double sigmaZ) { GaussianBlur gb = new GaussianBlur(); double accuracy = (stack.getBitDepth()==8||stack.getBitDepth()==24)?0.002:0.0002; int w=stack.getWidth(), h=stack.getHeight(), d=stack.getSize(); float[] zpixels = null; FloatProcessor fp =null; IJ.showStatus("Z blurring"); gb.showProgress(false); int channels = stack.getProcessor(1).getNChannels(); for (int y=0; y<h; y++) { IJ.showProgress(y, h-1); for (int channel=0; channel<channels; channel++) { zpixels = stack.getVoxels(0, y, 0, w, 1, d, zpixels, channel); if (fp==null) fp = new FloatProcessor(w, d, zpixels); //if (y==h/2) new ImagePlus("before-"+h/2, fp.duplicate()).show(); gb.blur1Direction(fp, sigmaZ, accuracy, false, 0); stack.setVoxels(0, y, 0, w, 1, d, zpixels, channel); } } IJ.showStatus(""); }
/** Since most computing time is spent in GaussianBlur, forward the * information about the number of passes to Gaussian Blur. The * ProgressBar will be handled by GaussianBlur. */ public void setNPasses(int nPasses) { if (gb == null) gb = new GaussianBlur(); gb.setNPasses(nPasses); } }