@Override public int getNChannels() { record("getNChannels"); return proc.getNChannels(); }
@Override public int getNChannels() { record("getNChannels"); return proc.getNChannels(); }
/** 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; }
/** 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; }
private void processImageUsingThreads(ImageProcessor ip, FloatProcessor fp, boolean snapshotDone) { if (IJ.debugMode) IJ.log("using threads: "+ip.getNChannels()); Thread thread = Thread.currentThread(); boolean convertToFloat = (flags&PlugInFilter.CONVERT_TO_FLOAT)!=0 && !(ip instanceof FloatProcessor); for (int i=0; i<ip.getNChannels(); i++) { fp = ip.toFloat(i, fp); fp.setSliceNumber(ip.getSliceNumber());
private void processImageUsingThreads(ImageProcessor ip, FloatProcessor fp, boolean snapshotDone) { if (IJ.debugMode) IJ.log("using threads: "+ip.getNChannels()); Thread thread = Thread.currentThread(); boolean convertToFloat = (flags&PlugInFilter.CONVERT_TO_FLOAT)!=0 && !(ip instanceof FloatProcessor); for (int i=0; i<ip.getNChannels(); i++) { fp = ip.toFloat(i, fp); fp.setSliceNumber(ip.getSliceNumber());
ip.reset(); ImageProcessor originalIp = imp.getProcessor(); if (originalIp.getNChannels() > 1) originalIp.reset(); return false;
/** Ask the user for the parameters */ public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { calledAsPlugin = true;; String options = Macro.getOptions(); boolean oldMacro = false; nChannels = imp.getProcessor().getNChannels(); if (options!=null) { if (options.indexOf("radius=") >= 0) { // ensure compatibility with old macros oldMacro = true; // specifying "radius=", not "sigma= Macro.setOptions(options.replaceAll("radius=", "sigma=")); } } GenericDialog gd = new GenericDialog(command); sigma = Math.abs(sigma); gd.addNumericField("Sigma (Radius):", sigma, 2); if (imp.getCalibration()!=null && !imp.getCalibration().getUnits().equals("pixels")) { hasScale = true; gd.addCheckbox("Scaled Units ("+imp.getCalibration().getUnits()+")", sigmaScaled); } else sigmaScaled = false; gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); // input by the user (or macro) happens here if (gd.wasCanceled()) return DONE; if (oldMacro) sigma /= 2.5; // for old macros, "radius" was 2.5 sigma IJ.register(this.getClass()); // protect static class variables (parameters) from garbage collection return IJ.setupDialog(imp, flags); // ask whether to process all slices of stack (if a stack) }
/** Ask the user for the parameters */ public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) { calledAsPlugin = true;; String options = Macro.getOptions(); boolean oldMacro = false; nChannels = imp.getProcessor().getNChannels(); if (options!=null) { if (options.indexOf("radius=") >= 0) { // ensure compatibility with old macros oldMacro = true; // specifying "radius=", not "sigma= Macro.setOptions(options.replaceAll("radius=", "sigma=")); } } GenericDialog gd = new GenericDialog(command); sigma = Math.abs(sigma); gd.addNumericField("Sigma (Radius):", sigma, 2); if (imp.getCalibration()!=null && !imp.getCalibration().getUnits().equals("pixels")) { hasScale = true; gd.addCheckbox("Scaled Units ("+imp.getCalibration().getUnits()+")", sigmaScaled); } else sigmaScaled = false; gd.addPreviewCheckbox(pfr); gd.addDialogListener(this); gd.showDialog(); // input by the user (or macro) happens here if (gd.wasCanceled()) return DONE; if (oldMacro) sigma /= 2.5; // for old macros, "radius" was 2.5 sigma IJ.register(this.getClass()); // protect static class variables (parameters) from garbage collection return IJ.setupDialog(imp, flags); // ask whether to process all slices of stack (if a stack) }
for (int i=0; i<ip.getNChannels(); i++) { fp = ip.toFloat(i, fp); fp.setSliceNumber(ip.getSliceNumber());
for (int i=0; i<ip.getNChannels(); i++) { fp = ip.toFloat(i, fp); fp.setSliceNumber(ip.getSliceNumber());
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(""); }
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(); } }
ImageProcessor ip2 = createProcessor(dstWidth, dstHeight); FloatProcessor fp = null; int channels = getNChannels(); boolean showStatus = getProgressIncrement(width,height)>0; boolean showProgress = showStatus && channels>1;
ImageProcessor ip2 = createProcessor(dstWidth, dstHeight); FloatProcessor fp = null; int channels = getNChannels(); boolean showStatus = getProgressIncrement(width,height)>0; boolean showProgress = showStatus && channels>1;
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(""); }
for (int ch=0; ch<ip.getNChannels(); ch++) { int filterType1 = filterType; if (isMultiStepFilter(filterType)) {
if (!useParaboloid) ball = new RollingBall(radius); FloatProcessor fp = null; for (int channelNumber=0; channelNumber<ip.getNChannels(); channelNumber++) { fp = ip.toFloat(channelNumber, fp); if ((ip instanceof FloatProcessor) && !calledAsPlugin && !createBackground)
for (int ch=0; ch<ip.getNChannels(); ch++) { int filterType1 = filterType; if (isMultiStepFilter(filterType)) {