public static int[] findMinima(double[] xx, double tolerance, int edgeMode) { int len = xx.length; double[] negArr = new double[len]; for (int jj = 0; jj < len; jj++) negArr[jj] = -xx[jj]; int[] minPositions = findMaxima(negArr, tolerance, edgeMode); return minPositions; }
public static int[] findMaxima(double[] xx, double tolerance, boolean excludeOnEdges) { int edgeBehavior = (excludeOnEdges) ? 1 : 0; return findMaxima(xx, tolerance, edgeBehavior); }
public static int[] findMaxima(double[] xx, double tolerance, boolean excludeOnEdges) { int edgeBehavior = (excludeOnEdges) ? 1 : 0; return findMaxima(xx, tolerance, edgeBehavior); }
public static int[] findMinima(double[] xx, double tolerance, int edgeMode) { int len = xx.length; double[] negArr = new double[len]; for (int jj = 0; jj < len; jj++) negArr[jj] = -xx[jj]; int[] minPositions = findMaxima(negArr, tolerance, edgeMode); return minPositions; }
/** Find the maxima of an image. * @param ip The input image * @param tolerance Height tolerance: maxima are accepted only if protruding more than this value * from the ridge to a higher maximum * @param outputType What to mark in output image: SINGLE_POINTS, IN_TOLERANCE or SEGMENTED. * No output image is created for output types POINT_SELECTION, LIST and COUNT. * @param excludeOnEdges Whether to exclude edge maxima * @return A new byteProcessor with a normal (uninverted) LUT where the marked points * are set to 255 (Background 0). Pixels outside of the roi of the input ip are not set. * Returns null if outputType does not require an output or if cancelled by escape */ public ByteProcessor findMaxima(ImageProcessor ip, double tolerance, int outputType, boolean excludeOnEdges) { return findMaxima(ip, tolerance, ImageProcessor.NO_THRESHOLD, outputType, excludeOnEdges, false); }
/** Find the maxima of an image. * @param ip The input image * @param tolerance Height tolerance: maxima are accepted only if protruding more than this value * from the ridge to a higher maximum * @param outputType What to mark in output image: SINGLE_POINTS, IN_TOLERANCE or SEGMENTED. * No output image is created for output types POINT_SELECTION, LIST and COUNT. * @param excludeOnEdges Whether to exclude edge maxima * @return A new byteProcessor with a normal (uninverted) LUT where the marked points * are set to 255 (Background 0). Pixels outside of the roi of the input ip are not set. * Returns null if outputType does not require an output or if cancelled by escape */ public ByteProcessor findMaxima(ImageProcessor ip, double tolerance, int outputType, boolean excludeOnEdges) { return findMaxima(ip, tolerance, ImageProcessor.NO_THRESHOLD, outputType, excludeOnEdges, false); }
/** Finds the image maxima and returns them as a Polygon. There * is an example at http://imagej.nih.gov/ij/macros/js/FindMaxima.js. * @param ip The input image * @param tolerance Height tolerance: maxima are accepted only if protruding more than this value * from the ridge to a higher maximum * @param excludeOnEdges Whether to exclude edge maxima * @return A Polygon containing the coordinates of the maxima */ public Polygon getMaxima(ImageProcessor ip, double tolerance, boolean excludeOnEdges) { findMaxima(ip, tolerance, ImageProcessor.NO_THRESHOLD, MaximumFinder.POINT_SELECTION, excludeOnEdges, false); if (points==null) return new Polygon(); else return points; }
/** Finds the image maxima and returns them as a Polygon. There * is an example at http://imagej.nih.gov/ij/macros/js/FindMaxima.js. * @param ip The input image * @param tolerance Height tolerance: maxima are accepted only if protruding more than this value * from the ridge to a higher maximum * @param excludeOnEdges Whether to exclude edge maxima * @return A Polygon containing the coordinates of the maxima */ public Polygon getMaxima(ImageProcessor ip, double tolerance, boolean excludeOnEdges) { findMaxima(ip, tolerance, ImageProcessor.NO_THRESHOLD, MaximumFinder.POINT_SELECTION, excludeOnEdges, false); if (points==null) return new Polygon(); else return points; }
/** Do watershed segmentation based on the EDM of the * foreground objects (nonzero pixels) in an 8-bit image. * Particles are segmented by their shape; segmentation * lines added are background pixels (value = 0); */ public void toWatershed (ImageProcessor ip) { FloatProcessor floatEdm = makeFloatEDM(ip, 0, false); ByteProcessor maxIp = maxFinder.findMaxima(floatEdm, MAXFINDER_TOLERANCE, ImageProcessor.NO_THRESHOLD, MaximumFinder.SEGMENTED, false, true); if (maxIp != null) ip.copyBits(maxIp, 0, 0, Blitter.AND); }
/** Do watershed segmentation based on the EDM of the * foreground objects (nonzero pixels) in an 8-bit image. * Particles are segmented by their shape; segmentation * lines added are background pixels (value = 0); */ public void toWatershed (ImageProcessor ip) { FloatProcessor floatEdm = makeFloatEDM(ip, 0, false); ByteProcessor maxIp = maxFinder.findMaxima(floatEdm, MAXFINDER_TOLERANCE, ImageProcessor.NO_THRESHOLD, MaximumFinder.SEGMENTED, false, true); if (maxIp != null) ip.copyBits(maxIp, 0, 0, Blitter.AND); }
public double getDiamaterMaximumInscribedCircle() { ImagePlus help = generateBlobImage(this); ImageProcessor ipHelp = help.getProcessor(); ipHelp.invert(); EDM dm = new EDM(); FloatProcessor fp = dm.makeFloatEDM (ipHelp, 0, false); MaximumFinder mf = new MaximumFinder(); ByteProcessor bp = mf.findMaxima(fp, 0.5, ImageProcessor.NO_THRESHOLD, MaximumFinder.SINGLE_POINTS, false, true); Polygon pl = mf.getMaxima(bp, 0, true); return fp.getf(pl.xpoints[0], pl.ypoints[0])*2*cal.getX(1); }
Variable[] findArrayMaxima(boolean minima) { int edgeMode = 0; interp.getLeftParen(); Variable[] a = getArray(); double tolerance = getNextArg(); if (interp.nextToken()==',') { interp.getComma(); edgeMode = (int)interp.getExpression(); } interp.getRightParen(); int n = a.length; double[] d = new double[n]; for (int i=0; i<n; i++) d[i] = a[i].getValue(); int[] maxima = null; if (minima) maxima = MaximumFinder.findMinima(d, tolerance, edgeMode); else maxima = MaximumFinder.findMaxima(d, tolerance, edgeMode); int n2 = maxima.length; Variable[] a2 = new Variable[n2]; for (int i=0; i<n2; i++) a2[i] = new Variable(maxima[i]); return a2; }
Variable[] findArrayMaxima(boolean minima) { int edgeMode = 0; interp.getLeftParen(); Variable[] a = getArray(); double tolerance = getNextArg(); if (interp.nextToken()==',') { interp.getComma(); edgeMode = (int)interp.getExpression(); } interp.getRightParen(); int n = a.length; double[] d = new double[n]; for (int i=0; i<n; i++) d[i] = a[i].getValue(); int[] maxima = null; if (minima) maxima = MaximumFinder.findMinima(d, tolerance, edgeMode); else maxima = MaximumFinder.findMaxima(d, tolerance, edgeMode); int n2 = maxima.length; Variable[] a2 = new Variable[n2]; for (int i=0; i<n2; i++) a2[i] = new Variable(maxima[i]); return a2; }
int maxOutputType = USES_WATERSHED[processType] ? MaximumFinder.SEGMENTED : MaximumFinder.SINGLE_POINTS; boolean isEDM = processType!=VORONOI; maxIp = maxFinder.findMaxima(floatEdm, MAXFINDER_TOLERANCE, ImageProcessor.NO_THRESHOLD, maxOutputType, false, isEDM); if (maxIp == null) { //segmentation cancelled by user?
int maxOutputType = USES_WATERSHED[processType] ? MaximumFinder.SEGMENTED : MaximumFinder.SINGLE_POINTS; boolean isEDM = processType!=VORONOI; maxIp = maxFinder.findMaxima(floatEdm, MAXFINDER_TOLERANCE, ImageProcessor.NO_THRESHOLD, maxOutputType, false, isEDM); if (maxIp == null) { //segmentation cancelled by user?
outIp = findMaxima(ip, tolerance, threshold, outputType, excludeOnEdges, false); //process the image if (outIp == null) return; //cancelled by user or previewing or no output image if (!Prefs.blackBackground) //normally, output has an inverted LUT, "active" pixels black (255) - like a mask
outIp = findMaxima(ip, tolerance, threshold, outputType, excludeOnEdges, false); //process the image if (outIp == null) return; //cancelled by user or previewing or no output image if (!Prefs.blackBackground) //normally, output has an inverted LUT, "active" pixels black (255) - like a mask