/** Performs projection using the specified method and stack range, and returns the result, where 'method' is "avg", "min", "max", "sum", "sd" or "median". Add " all" to 'method' to project all hyperstack time points. <br> Example: http://imagej.nih.gov/ij/macros/js/ProjectionDemo.js */ public static ImagePlus run(ImagePlus imp, String method, int startSlice, int stopSlice) { ZProjector zp = new ZProjector(imp); zp.setStartSlice(startSlice); zp.setStopSlice(stopSlice); zp.isHyperstack = imp.isHyperStack(); if (zp.isHyperstack && startSlice==1 && stopSlice==imp.getStackSize()) zp.setDefaultBounds(); if (method==null) return null; method = method.toLowerCase(); int m = -1; if (method.startsWith("av")) m = AVG_METHOD; else if (method.startsWith("max")) m = MAX_METHOD; else if (method.startsWith("min")) m = MIN_METHOD; else if (method.startsWith("sum")) m = SUM_METHOD; else if (method.startsWith("sd")) m = SD_METHOD; else if (method.startsWith("median")) m = MEDIAN_METHOD; if (m<0) throw new IllegalArgumentException("Invalid projection method: "+method); zp.allTimeFrames = method.contains("all"); zp.setMethod(m); zp.doProjection(true); return zp.getProjection(); }
/** Performs projection using the specified method and stack range, and returns the result, where 'method' is "avg", "min", "max", "sum", "sd" or "median". Add " all" to 'method' to project all hyperstack time points. <br> Example: http://imagej.nih.gov/ij/macros/js/ProjectionDemo.js */ public static ImagePlus run(ImagePlus imp, String method, int startSlice, int stopSlice) { ZProjector zp = new ZProjector(imp); zp.setStartSlice(startSlice); zp.setStopSlice(stopSlice); zp.isHyperstack = imp.isHyperStack(); if (zp.isHyperstack && startSlice==1 && stopSlice==imp.getStackSize()) zp.setDefaultBounds(); if (method==null) return null; method = method.toLowerCase(); int m = -1; if (method.startsWith("av")) m = AVG_METHOD; else if (method.startsWith("max")) m = MAX_METHOD; else if (method.startsWith("min")) m = MIN_METHOD; else if (method.startsWith("sum")) m = SUM_METHOD; else if (method.startsWith("sd")) m = SD_METHOD; else if (method.startsWith("median")) m = MEDIAN_METHOD; if (m<0) throw new IllegalArgumentException("Invalid projection method: "+method); zp.allTimeFrames = method.contains("all"); zp.setMethod(m); zp.doProjection(true); return zp.getProjection(); }
private ImageProcessor projImp() { ImageProcessor ip; final ZProjector zp = new ZProjector(imp); zp.setMethod(ZProjector.MAX_METHOD); zp.setStartSlice(minZ); zp.setStopSlice(maxZ); if (imp.isComposite()) { zp.doHyperStackProjection(false); final ImagePlus projImp = zp.getProjection(); projImp.setC(channel); ip = projImp.getChannelProcessor(); } else { zp.doProjection(); ip = zp.getProjection().getProcessor(); } return ip; }
public ImagePlus groupZProject(ImagePlus imp, int method, int groupSize) { if (method<0 || method>=ZProjector.METHODS.length) return null; int[] dim = imp.getDimensions(); int projectedStackSize = imp.getStackSize()/groupSize; imp.setDimensions(1, groupSize, projectedStackSize); ZProjector zp = new ZProjector(imp); zp.setMethod(method); zp.setStartSlice(1); zp.setStopSlice(groupSize); zp.doHyperStackProjection(true); imp.setDimensions(dim[2], dim[3], dim[4]); ImagePlus zProjectorOutput = zp.getProjection(); int[] zProjectDim = zProjectorOutput.getDimensions(); for (int i=2; i<dim.length; i++) { if (dim[i] != 1) zProjectDim[i] = projectedStackSize; else zProjectDim[i] = 1; } // Fix dimensions for output ImagePlus zProjectorOutput.setDimensions(zProjectDim[2], zProjectDim[3], zProjectDim[4]); return zProjectorOutput; }
public ImagePlus groupZProject(ImagePlus imp, int method, int groupSize) { if (method<0 || method>=ZProjector.METHODS.length) return null; int[] dim = imp.getDimensions(); int projectedStackSize = imp.getStackSize()/groupSize; imp.setDimensions(1, groupSize, projectedStackSize); ZProjector zp = new ZProjector(imp); zp.setMethod(method); zp.setStartSlice(1); zp.setStopSlice(groupSize); zp.doHyperStackProjection(true); imp.setDimensions(dim[2], dim[3], dim[4]); ImagePlus zProjectorOutput = zp.getProjection(); int[] zProjectDim = zProjectorOutput.getDimensions(); for (int i=2; i<dim.length; i++) { if (dim[i] != 1) zProjectDim[i] = projectedStackSize; else zProjectDim[i] = 1; } // Fix dimensions for output ImagePlus zProjectorOutput.setDimensions(zProjectDim[2], zProjectDim[3], zProjectDim[4]); return zProjectorOutput; }
int startSlice2 = startSlice; int stopSlice2 = stopSlice; setStartSlice((int)gd.getNextNumber()); setStopSlice((int)gd.getNextNumber()); boolean rangeChanged = startSlice!=startSlice2 || stopSlice!=stopSlice2;
int startSlice2 = startSlice; int stopSlice2 = stopSlice; setStartSlice((int)gd.getNextNumber()); setStopSlice((int)gd.getNextNumber()); boolean rangeChanged = startSlice!=startSlice2 || stopSlice!=stopSlice2;
new ImagePlus(imp.getTitle() + " Projection", i5d.getStack()); final ZProjector zp = new ZProjector(tempImg); zp.setStartSlice(startSlice); zp.setStopSlice(stopSlice); zp.setMethod(method);
new ImagePlus(imp.getTitle() + " Projection", i5d.getStack()); final ZProjector zp = new ZProjector(tempImg); zp.setStartSlice(startSlice); zp.setStopSlice(stopSlice); zp.setMethod(method);