/** Gaussian Filtering of a FloatProcessor. This method does NOT include * resetOutOfRoi(ip), i.e., pixels above and below the roi rectangle will * be also subject to filtering in x direction and must be restored * afterwards (unless the full image height is processed). * @param ip The FloatProcessor 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 blurFloat(FloatProcessor ip, double sigmaX, double sigmaY, double accuracy) { if (sigmaX > 0) blur1Direction(ip, sigmaX, accuracy, true, (int)Math.ceil(5*sigmaY)); if (Thread.currentThread().isInterrupted()) return; // interruption for new parameters during preview? if (sigmaY > 0) blur1Direction(ip, sigmaY, accuracy, false, 0); return; }
/** Gaussian Filtering of a FloatProcessor. This method does NOT include * resetOutOfRoi(ip), i.e., pixels above and below the roi rectangle will * be also subject to filtering in x direction and must be restored * afterwards (unless the full image height is processed). * @param ip The FloatProcessor 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 blurFloat(FloatProcessor ip, double sigmaX, double sigmaY, double accuracy) { if (sigmaX > 0) blur1Direction(ip, sigmaX, accuracy, true, (int)Math.ceil(5*sigmaY)); if (Thread.currentThread().isInterrupted()) return; // interruption for new parameters during preview? if (sigmaY > 0) blur1Direction(ip, sigmaY, accuracy, false, 0); return; }
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; }
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; }
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; }
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; }
FloatProcessor fp = new FloatProcessor(256, 1, hist, null); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); float maxCount=0f, sum=0f, mean, count; int mode = 0;
FloatProcessor fp = new FloatProcessor(256, 1, hist, null); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); float maxCount=0f, sum=0f, mean, count; int mode = 0;
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(""); }
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(""); }