Java Code Examples for ij.measure.ResultsTable#show()
The following examples show how to use
ij.measure.ResultsTable#show() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegionMorphometryPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
public void run(ImageProcessor ip) { // check if image is a label image // Check if image may be a label image if (!LabelImages.isLabelImageType(imagePlus)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin ResultsTable table = process(imagePlus, 4); // show result String tableName = imagePlus.getShortTitle() + "-Morphometry"; table.show(tableName); }
Example 2
Source File: ShollAnalysisDialog.java From SNT with GNU General Public License v3.0 | 6 votes |
public void addToResultsTable() { final ResultsTable rt = Analyzer.getResultsTable(); if (!Analyzer.resetCounter()) return; rt.incrementCounter(); rt.addValue("Filename", getOriginalFilename()); rt.addValue("All paths used", String.valueOf(useAllPaths)); rt.addValue("Paths used", numberOfPathsUsed); rt.addValue("Sphere separation", sphereSeparation); rt.addValue("Normalization", normalization); rt.addValue("Axes", axes); rt.addValue("Max inters. radius", getCriticalValue()); rt.addValue("Max inters.", getDendriteMaximum()); rt.addValue("Regression coefficient", getShollRegressionCoefficient()); rt.addValue("Regression gradient", getRegressionGradient()); rt.addValue("Regression intercept", getRegressionIntercept()); rt.show("Results"); }
Example 3
Source File: AverageThicknessPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void run(String arg) { // selected image ImagePlus currentImage = IJ.getImage(); // check if image is a label image if (!LabelImages.isLabelImageType(currentImage)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin AverageThickness op = new AverageThickness(); Map<Integer, AverageThickness.Result> results = op.analyzeRegions(currentImage); // Display plugin result as table ResultsTable table = op.createTable(results); String tableName = currentImage.getShortTitle() + "-AvgThickness"; table.show(tableName); }
Example 4
Source File: SkeletonPlugin.java From SNT with GNU General Public License v3.0 | 5 votes |
private void summarizeSkeleton(final SkeletonResult sr) { final String TABLE_TITLE = "Summary of Rendered Paths"; final ResultsTable rt = getTable(TABLE_TITLE); try { double sumLength = 0d; final int[] branches = sr.getBranches(); final double[] avgLengths = sr.getAverageBranchLength(); for (int i = 0; i < sr.getNumOfTrees(); i++) sumLength += avgLengths[i] * branches[i]; rt.incrementCounter(); rt.addValue("N. Rendered Paths", renderingPaths.size()); rt.addValue("Unit", imp.getCalibration().getUnits()); rt.addValue("Total length", sumLength); rt.addValue("Mean branch length", StatUtils.mean(avgLengths)); rt.addValue("Length of longest branch", StatUtils.max(sr.getMaximumBranchLength())); rt.addValue("# Branches", IntStream.of(sr.getBranches()).sum()); rt.addValue("# Junctions", IntStream.of(sr.getJunctions()).sum()); rt.addValue("# End-points", IntStream.of(sr.getEndPoints()).sum()); rt.addValue("Fitering", getFilterString()); if (restrictByRoi && roi != null && roi.isArea()) rt.addValue("ROI Name", roi.getName() == null ? "Unammed ROI" : roi.getName()); } catch (final Exception ignored) { SNT.error("Some statistics could not be calculated."); } finally { rt.show(TABLE_TITLE); } }
Example 5
Source File: RegionMorphometryPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Deprecated public Object[] exec(ImagePlus inputImage, int nDirs) { // Check validity of parameters if (inputImage==null) return null; if (debug) { System.out.println("Compute Crofton perimeter on image '" + inputImage.getTitle()); } ImageProcessor proc = inputImage.getProcessor(); // Extract spatial calibration Calibration cal = inputImage.getCalibration(); double[] resol = new double[]{1, 1}; if (cal.scaled()) { resol[0] = cal.pixelWidth; resol[1] = cal.pixelHeight; } ResultsTable results = GeometricMeasures2D.analyzeRegions(proc, resol); // create string for indexing results String tableName = inputImage.getShortTitle() + "-Morphometry"; // show result results.show(tableName); // return the created array return new Object[]{"Morphometry", results}; }
Example 6
Source File: InertiaEllipsoidPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { ImagePlus imagePlus = IJ.getImage(); if (imagePlus.getStackSize() == 1) { IJ.error("Requires a Stack"); return; } // Extract required information ImageStack image = imagePlus.getStack(); int[] labels = LabelImages.findAllLabels(imagePlus); Calibration calib= imagePlus.getCalibration(); // Compute inertia moments ResultsTable table; ResultsTable vectorTable; try { InertiaEllipsoid algo = new InertiaEllipsoid(); DefaultAlgoListener.monitor(algo); table = algo.computeTable(imagePlus); // show table results String title = imagePlus.getShortTitle() + "-ellipsoid"; table.show(title); InertiaMoments3D[] moments = algo.computeMoments(image, labels, calib); vectorTable = createVectorTable(labels, moments); title = imagePlus.getShortTitle() + "-eigenVectors"; vectorTable.show(title); } catch (Exception ex) { String msg = ex.getMessage(); IJ.log(msg); IJ.error("Problem occured during Inertia Ellipsoid computation:\n" + msg); ex.printStackTrace(System.err); return; } }
Example 7
Source File: MaxFeretDiameterPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run(String arg) { // Open a dialog to choose: // - a label image // - image to display results int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Max. Feret Diameter"); gd.addChoice("Label Image:", imageNames, selectedImageName); // Set Chessknight weights as default gd.addCheckbox("Show Overlay Result", true); gd.addChoice("Image to overlay:", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelPlus = WindowManager.getImage(labelImageIndex+1); boolean overlay = gd.getNextBoolean(); int resultImageIndex = gd.getNextChoiceIndex(); // check if image is a label image if (!LabelImages.isLabelImageType(labelPlus)) { IJ.showMessage("Input image should be a label image"); return; } // Compute max Feret diameters MaxFeretDiameter op = new MaxFeretDiameter(); Map<Integer, PointPair2D> maxDiamsMap = op.analyzeRegions(labelPlus); // Display the result Table ResultsTable results = op.createTable(maxDiamsMap); // create string for indexing results String tableName = labelPlus.getShortTitle() + "-FeretDiams"; // show result results.show(tableName); // Optionally display overlay if (overlay) { ImagePlus resultImage = WindowManager.getImage(resultImageIndex + 1); drawDiameters(resultImage, maxDiamsMap); } }
Example 8
Source File: BoundingBoxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { // Open a dialog to choose: // - a label image // - a set of weights int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Bounding Box"); gd.addChoice("Label Image:", imageNames, selectedImageName); gd.addCheckbox("Show Overlay Result", true); gd.addChoice("Image to overlay:", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelImage = WindowManager.getImage(labelImageIndex + 1); boolean showOverlay = gd.getNextBoolean(); int resultImageIndex = gd.getNextChoiceIndex(); // check if image is a label image if (!LabelImages.isLabelImageType(labelImage)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin BoundingBox op = new BoundingBox(); Map<Integer, Box2D> boxes = op.analyzeRegions(labelImage); ResultsTable results = op.createTable(boxes); // show result String tableName = labelImage.getShortTitle() + "-BBox"; results.show(tableName); // Check if results must be displayed on an image if (showOverlay) { // find image for displaying geometric overlays ImagePlus resultImage = WindowManager.getImage(resultImageIndex + 1); showResultsAsOverlay(boxes, resultImage); } }
Example 9
Source File: AnalyzeRegions3D.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { ImagePlus imagePlus = IJ.getImage(); if (imagePlus.getStackSize() == 1) { IJ.error("Requires a Stack"); return; } // create the dialog, with operator options GenericDialog gd = new GenericDialog("Analyze Regions 3D"); gd.addCheckbox("Volume", true); gd.addCheckbox("Surface_Area", true); gd.addCheckbox("Mean_Breadth", true); gd.addCheckbox("Sphericity", true); gd.addCheckbox("Euler_Number", true); gd.addCheckbox("Bounding_Box", true); gd.addCheckbox("Centroid", true); gd.addCheckbox("Equivalent_Ellipsoid", true); gd.addCheckbox("Ellipsoid_Elongations", true); gd.addCheckbox("Max._Inscribed Ball", true); gd.addMessage(""); gd.addChoice("Surface_area_method:", surfaceAreaMethods, surfaceAreaMethods[1]); gd.addChoice("Euler_Connectivity:", connectivityNames, connectivityNames[1]); gd.showDialog(); // If cancel was clicked, do nothing if (gd.wasCanceled()) return; // Extract features to extract from image computeVolume = gd.getNextBoolean(); computeSurface = gd.getNextBoolean(); computeMeanBreadth = gd.getNextBoolean(); computeSphericity = gd.getNextBoolean(); computeEulerNumber = gd.getNextBoolean(); computeBoundingBox = gd.getNextBoolean(); computeCentroid = gd.getNextBoolean(); computeEllipsoid = gd.getNextBoolean(); computeElongations = gd.getNextBoolean(); computeInscribedBall = gd.getNextBoolean(); // extract analysis options surfaceAreaDirs = dirNumbers[gd.getNextChoiceIndex()]; connectivity = connectivityValues[gd.getNextChoiceIndex()]; // Execute the plugin ResultsTable table = process(imagePlus); // create string for indexing results String tableName = imagePlus.getShortTitle() + "-morpho"; // show result table.show(tableName); }
Example 10
Source File: AnalyzeRegions.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(ImageProcessor ip) { // check if image is a label image // Check if image may be a label image if (!LabelImages.isLabelImageType(imagePlus)) { IJ.showMessage("Input image should be a label image"); return; } // create the dialog, with operator options GenericDialog gd = new GenericDialog("Analyze Regions"); gd.addCheckbox("Area", true); gd.addCheckbox("Perimeter", true); gd.addCheckbox("Circularity", true); gd.addCheckbox("Euler_Number", true); gd.addCheckbox("Bounding_Box", true); gd.addCheckbox("Centroid", true); gd.addCheckbox("Equivalent_Ellipse", true); gd.addCheckbox("Ellipse_Elong.", true); gd.addCheckbox("Convexity", true); gd.addCheckbox("Max._Feret Diameter", true); gd.addCheckbox("Oriented_Box", true); gd.addCheckbox("Oriented_Box_Elong.", true); gd.addCheckbox("Geodesic Diameter", true); gd.addCheckbox("Tortuosity", true); gd.addCheckbox("Max._Inscribed_Disc", true); gd.addCheckbox("Average_Thickness", true); gd.addCheckbox("Geodesic_Elong.", true); gd.showDialog(); // If cancel was clicked, do nothing if (gd.wasCanceled()) return; // Extract features to extract from image computeArea = gd.getNextBoolean(); computePerimeter = gd.getNextBoolean(); computeCircularity = gd.getNextBoolean(); computeEulerNumber = gd.getNextBoolean(); computeBoundingBox = gd.getNextBoolean(); computeCentroid = gd.getNextBoolean(); computeEquivalentEllipse = gd.getNextBoolean(); computeEllipseElongation = gd.getNextBoolean(); computeConvexity = gd.getNextBoolean(); computeMaxFeretDiameter = gd.getNextBoolean(); computeOrientedBox = gd.getNextBoolean(); computeOrientedBoxElongation = gd.getNextBoolean(); computeGeodesicDiameter = gd.getNextBoolean(); computeTortuosity = gd.getNextBoolean(); computeMaxInscribedDisc = gd.getNextBoolean(); computeAverageThickness = gd.getNextBoolean(); computeGeodesicElongation = gd.getNextBoolean(); // Execute the plugin ResultsTable table = process(imagePlus); // show result String tableName = imagePlus.getShortTitle() + "-Morphometry"; table.show(tableName); }
Example 11
Source File: EquivalentEllipsoidPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { ImagePlus imagePlus = IJ.getImage(); if (imagePlus.getStackSize() == 1) { IJ.error("Requires a Stack"); return; } // Extract required information ImageStack image = imagePlus.getStack(); int[] labels = LabelImages.findAllLabels(imagePlus); Calibration calib= imagePlus.getCalibration(); // Compute inertia moments ResultsTable table; ResultsTable vectorTable; try { EquivalentEllipsoid algo = new EquivalentEllipsoid(); DefaultAlgoListener.monitor(algo); table = algo.computeTable(imagePlus); // show table results String title = imagePlus.getShortTitle() + "-ellipsoid"; table.show(title); Moments3D[] moments = algo.computeMoments(image, labels, calib); vectorTable = createVectorTable(labels, moments); title = imagePlus.getShortTitle() + "-eigenVectors"; vectorTable.show(title); } catch (Exception ex) { String msg = ex.getMessage(); IJ.log(msg); IJ.error("Problem occured during Equivalent Ellipsoid computation:\n" + msg); ex.printStackTrace(System.err); return; } }
Example 12
Source File: MaxInscribedSpherePlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run(String arg0) { // Open a dialog to choose: // - a label image // - a set of weights int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Max. Inscribed Sphere"); gd.addChoice("Label Image:", imageNames, selectedImageName); // Set Borgefors weights as default // gd.addChoice("Distances", ChamferWeights3D.getAllLabels(), // ChamferWeights3D.BORGEFORS.toString()); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelImage = WindowManager.getImage(labelImageIndex+1); // ChamferWeights3D weights = ChamferWeights3D.fromLabel(gd.getNextChoice()); // check if image is a 3D label image if (labelImage.getStackSize() <= 1) { IJ.showMessage("Input image should be a 3D label image"); return; } // Check if image may be a label image if (!LabelImages.isLabelImageType(labelImage)) { IJ.showMessage("Input image should be a 3D label image"); return; } // Execute the plugin LargestInscribedBall algo = new LargestInscribedBall(); DefaultAlgoListener.monitor(algo); ResultsTable table = algo.computeTable(labelImage); // Display plugin result String tableName = labelImage.getShortTitle() + "-MaxInscribedSphere"; table.show(tableName); }
Example 13
Source File: MicrostructureAnalysisPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Main body of the plugin. Computes geometric measures on the image * contained in <code>image</code>, using <code>nDirs</code> discrete * directions. If the addPorosity flag is set to true, an additional column * equal to 1-area density is added. * * @param image * the image to process * @param nDirs * the number of directions to consider, either 2 or 4 * @param addPorosity * specifies if porosity should be computed * @return an array of objects * @deprecated use process method instead */ @Deprecated public Object[] exec(ImagePlus image, int nDirs, boolean addPorosity) { // Check validity of parameters if (image==null) return null; if (debug) { System.out.println("Compute Crofton densities on image '" + image.getTitle() + "' using " + nDirs + " directions."); } ImageProcessor proc = image.getProcessor(); // Extract spatial calibration Calibration calib = image.getCalibration(); // Compute basis measures double areaDensity = IntrinsicVolumes2D.areaDensity(proc); double perimDensity = IntrinsicVolumes2D.perimeterDensity(proc, calib, nDirs); ResultsTable table = new ResultsTable(); table.incrementCounter(); table.addValue("AreaDensity", areaDensity); table.addValue("PerimeterDensity", perimDensity); // eventually add the porosity for those who do not want to subtract by hand... if (addPorosity) { table.addValue("Porosity", 1-areaDensity); } // create string for indexing results String tableName = removeImageExtension(image.getTitle()) + "-Densities"; // show result table.show(tableName); // return the created array return new Object[]{"Crofton Densties", table}; }
Example 14
Source File: Lines_.java From ij-ridgedetection with GNU General Public License v2.0 | 4 votes |
/** * Creates the results table. * * @param showJunctions * the show junctions */ private void createResultsTable(boolean showJunctions) { ResultsTable rt = ResultsTable.getResultsTable(); ResultsTable rtSum = new ResultsTable(); rt.setPrecision(3); Calibration cal = imp.getCalibration(); for (Lines contours : result) { for (Line c : contours) { double meanWidth = 0; for (int i = 0; i < c.num; i++) { rt.incrementCounter(); rt.addValue("Frame", contours.getFrame()); rt.addValue("Contour ID", c.getID()); rt.addValue("Pos.", i + 1); rt.addValue("X", c.col[i] * cal.pixelWidth); rt.addValue("Y", c.row[i] * cal.pixelHeight); rt.addValue("Length", c.estimateLength() * cal.pixelHeight); if (doCorrectPosition && doEstimateWidth) { rt.addValue("Contrast", Math.abs(c.intensity[i])); rt.addValue("Asymmetry", Math.abs(c.asymmetry[i])); } if (doEstimateWidth) { rt.addValue("Line width", (c.width_l[i] + c.width_r[i]) * cal.pixelWidth); meanWidth += c.width_l[i] + c.width_r[i]; rt.addValue("Angle of normal", c.angle[i]); } rt.addValue("Class", c.getContourClass().toString().substring(5)); } rtSum.incrementCounter(); rtSum.addValue("Frame", contours.getFrame()); rtSum.addValue("Contour ID", c.getID()); rtSum.addValue("Length", c.estimateLength() * cal.pixelWidth); if (doEstimateWidth) { rtSum.addValue("Mean line width", meanWidth / c.num * cal.pixelWidth); } } } rt.show("Results"); rtSum.show("Summary"); if (showJunctions) { ResultsTable rt2 = new ResultsTable(); rt2.setPrecision(0); for (Junctions junctions : resultJunction) { for (Junction j : junctions) { rt2.incrementCounter(); rt2.addValue("Frame", junctions.getFrame()); rt2.addValue("Contour ID 1", j.getLine1().getID());// c.get( j.cont1) rt2.addValue("Contour ID 2", j.getLine2().getID()); rt2.addValue("X", j.x * cal.pixelWidth); rt2.addValue("Y", j.y * cal.pixelHeight); } } rt2.show("Junctions"); } }
Example 15
Source File: InertiaEllipsePlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { // Open a dialog to choose: // - a label image // - a set of weights int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Inertia Ellipse"); gd.addChoice("Label Image:", imageNames, selectedImageName); gd.addCheckbox("Overlay Ellipse", true); gd.addCheckbox("Overlay Axes", true); gd.addChoice("Image to overlay:", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelImage = WindowManager.getImage(labelImageIndex + 1); boolean showEllipse = gd.getNextBoolean(); boolean showAxes = gd.getNextBoolean(); int resultImageIndex = gd.getNextChoiceIndex(); // check if image is a label image if (!LabelImages.isLabelImageType(labelImage)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin InertiaEllipse op = new InertiaEllipse(); Map<Integer, Ellipse> ellipses = op.analyzeRegions(labelImage); ResultsTable results = op.createTable(ellipses); // show result String tableName = labelImage.getShortTitle() + "-Ellipses"; results.show(tableName); // Check if results must be displayed on an image if (showEllipse || showAxes) { // find image for displaying geometric overlays ImagePlus resultImage = WindowManager.getImage(resultImageIndex + 1); showResultsAsOverlay(ellipses, resultImage, showEllipse, showAxes); } }
Example 16
Source File: RegionAdjacencyGraphPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run(String arg0) { ImagePlus imagePlus = IJ.getImage(); boolean isPlanar = imagePlus.getStackSize() == 1; boolean showRAG = false; ImagePlus targetPlus = imagePlus; if (isPlanar) { // create the list of image names int[] indices = WindowManager.getIDList(); String[] imageNames = new String[indices.length]; for (int i = 0; i < indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); GenericDialog gd = new GenericDialog("Region Adjacency Graph"); gd.addCheckbox("Show RAG", true); gd.addChoice("Image to overlay", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) { return; } showRAG = gd.getNextBoolean(); int targetImageIndex = gd.getNextChoiceIndex(); targetPlus = WindowManager.getImage(indices[targetImageIndex]); } Set<LabelPair> adjList = RegionAdjacencyGraph.computeAdjacencies(imagePlus); if (showRAG) { overlayRAG(adjList, imagePlus, targetPlus); } ResultsTable table = createTable(adjList); String newName = imagePlus.getShortTitle() + "-RAG"; table.show(newName); }
Example 17
Source File: MaxInscribedCirclePlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run(String arg0) { // Open a dialog to choose: // - a label image // - a set of weights int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Max. Inscribed Circle"); gd.addChoice("Label Image:", imageNames, selectedImageName); // // Set Chessknight weights as default // gd.addChoice("Distances", ChamferWeights.getAllLabels(), // ChamferWeights.CHESSKNIGHT.toString()); gd.addCheckbox("Show Overlay Result", true); gd.addChoice("Image to overlay:", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelImage = WindowManager.getImage(labelImageIndex+1); // ChamferWeights weights = ChamferWeights.fromLabel(gd.getNextChoice()); boolean showOverlay = gd.getNextBoolean(); int resultImageIndex = gd.getNextChoiceIndex(); // check if image is a label image if (!LabelImages.isLabelImageType(labelImage)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin LargestInscribedCircle op = new LargestInscribedCircle(); Map<Integer, Circle2D> results = op.analyzeRegions(labelImage); // Display plugin result as table ResultsTable table = op.createTable(results); String tableName = labelImage.getShortTitle() + "-MaxInscribedCircle"; table.show(tableName); // Check if results must be displayed on an image if (showOverlay) { // find image for displaying geometric overlays ImagePlus resultImage = WindowManager.getImage(resultImageIndex + 1); showResultsAsOverlay(results, resultImage); } }
Example 18
Source File: Utils.java From Scripts with GNU General Public License v3.0 | 4 votes |
/** * Opens a tab or comma delimited text file. * * @param path * The absolute pathname string of the file. A file open dialog * is displayed if path is {@code null} or an empty string. * @param title * The title of the window in which data is displayed. The * filename is used if title is null or an empty string. To avoid * windows with duplicated titles, title is made unique by * {@link WindowManager} . * @param listener * The {@link WindowListener} to be added to the window * containing data if retrieval was successful. It is ignored * when {@code null}. * @throws IOException * if file could not be opened * @return A reference to the opened {link ResultsTable} or {@code null} if * table was empty. * * @see #getTable() * @see ij.io.Opener#openTable(String) */ public static ResultsTable openAndDisplayTable(final String path, final String title, final WindowListener listener) throws IOException { ResultsTable rt = null; rt = ResultsTable.open(path); if (rt == null || rt.getCounter() == 0) // nothing to be displayed return null; rt.showRowNumbers(false); String rtTitle = (title != null && !title.isEmpty()) ? title : OpenDialog.getLastName(); rtTitle = WindowManager.makeUniqueName(rtTitle); rt.show(rtTitle); final TextWindow rtWindow = (TextWindow) WindowManager.getFrame(rtTitle); if (rtWindow != null && listener != null) rtWindow.addWindowListener(listener); return rt; }
Example 19
Source File: OrientedBoundingBoxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { // Open a dialog to choose: // - a label image // - a set of weights int[] indices = WindowManager.getIDList(); if (indices==null) { IJ.error("No image", "Need at least one image to work"); return; } // create the list of image names String[] imageNames = new String[indices.length]; for (int i=0; i<indices.length; i++) { imageNames[i] = WindowManager.getImage(indices[i]).getTitle(); } // name of selected image String selectedImageName = IJ.getImage().getTitle(); // create the dialog GenericDialog gd = new GenericDialog("Oriented Bounding Box"); gd.addChoice("Label Image:", imageNames, selectedImageName); gd.addCheckbox("Show Overlay Result", true); gd.addChoice("Image to overlay:", imageNames, selectedImageName); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelImage = WindowManager.getImage(labelImageIndex + 1); boolean showOverlay = gd.getNextBoolean(); int resultImageIndex = gd.getNextChoiceIndex(); // check if image is a label image if (!LabelImages.isLabelImageType(labelImage)) { IJ.showMessage("Input image should be a label image"); return; } // Execute the plugin OrientedBoundingBox2D op = new OrientedBoundingBox2D(); Map<Integer, OrientedBox2D> boxes = op.analyzeRegions(labelImage); ResultsTable results = op.createTable(boxes); // show result String tableName = labelImage.getShortTitle() + "-OBox"; results.show(tableName); // Check if results must be displayed on an image if (showOverlay) { // find image for displaying geometric overlays ImagePlus resultImage = WindowManager.getImage(resultImageIndex + 1); showResultsAsOverlay(boxes, resultImage); } }
Example 20
Source File: ParticleAnalysis3DPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
public void run(String args) { ImagePlus imagePlus = IJ.getImage(); if (imagePlus.getStackSize() == 1) { IJ.error("Requires a Stack"); return; } // create the dialog, with operator options GenericDialog gd = new GenericDialog("Particles Analysis 3D"); gd.addCheckbox("Volume", true); gd.addCheckbox("Surface Area", true); gd.addCheckbox("Sphericity", true); gd.addCheckbox("Euler Number", true); gd.addCheckbox("Equivalent Ellipsoid", true); gd.addCheckbox("Ellipsoid Elongation", true); gd.addCheckbox("Max. Inscribed Ball", true); gd.addMessage(""); gd.addChoice("Surface area method:", surfaceAreaMethods, surfaceAreaMethods[1]); gd.addChoice("Euler Connectivity:", connectivityNames, connectivityNames[1]); gd.showDialog(); // If cancel was clicked, do nothing if (gd.wasCanceled()) return; // Extract features to extract from image computeVolume = gd.getNextBoolean(); computeSurface = gd.getNextBoolean(); computeSphericity = gd.getNextBoolean() & computeVolume & computeSurface; computeEulerNumber = gd.getNextBoolean(); computeEllipsoid = gd.getNextBoolean(); computeElongations = gd.getNextBoolean() & computeEllipsoid; computeInscribedBall = gd.getNextBoolean(); // extract analysis options surfaceAreaDirs = dirNumbers[gd.getNextChoiceIndex()]; connectivity = connectivityValues[gd.getNextChoiceIndex()]; // Execute the plugin ResultsTable table = process(imagePlus); // create string for indexing results String tableName = imagePlus.getShortTitle() + "-morpho"; // show result table.show(tableName); }