/** 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(); }