Java Code Examples for ij.measure.ResultsTable#getColumnIndex()
The following examples show how to use
ij.measure.ResultsTable#getColumnIndex() .
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: LabelToValuePlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
private double[] getColumnValues(ResultsTable table, String heading) { String[] allHeaders = table.getHeadings(); // Check if column header corresponds to row label header boolean hasRowLabels = hasRowLabelColumn(table); if (hasRowLabels && heading.equals(allHeaders[0])) { // need to parse row label column int nr = table.size(); double[] values = new double[nr]; for (int r = 0; r < nr; r++) { String label = table.getLabel(r); values[r] = Double.parseDouble(label); } return values; } // determine index of column int index = table.getColumnIndex(heading); if (index == ResultsTable.COLUMN_NOT_FOUND) { throw new RuntimeException("Unable to find column index from header: " + heading); } return table.getColumnAsDoubles(index); }
Example 2
Source File: DrawTableValuesPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
private double[] getColumnValues(ResultsTable table, String heading) { String[] allHeaders = table.getHeadings(); // Check if column header corresponds to row label header boolean hasRowLabels = hasRowLabelColumn(table); if (hasRowLabels && heading.equals(allHeaders[0])) { // need to parse row label column int nr = table.size(); double[] values = new double[nr]; for (int r = 0; r < nr; r++) { String label = table.getLabel(r); values[r] = Double.parseDouble(label); } return values; } // determine index of column int index = table.getColumnIndex(heading); if (index == ResultsTable.COLUMN_NOT_FOUND) { throw new RuntimeException("Unable to find column index from header: " + heading); } return table.getColumnAsDoubles(index); }
Example 3
Source File: GeodesicDiameter3DPlugin.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("Geodesic Diameter 3D"); gd.addChoice("Label Image (3D):", imageNames, selectedImageName); // Set Chessknight weights as default gd.addChoice("Distances", ChamferWeights3D.getAllLabels(), ChamferWeights3D.WEIGHTS_3_4_5_7.toString()); gd.showDialog(); if (gd.wasCanceled()) return; // set up current parameters int labelImageIndex = gd.getNextChoiceIndex(); ImagePlus labelPlus = WindowManager.getImage(labelImageIndex+1); ChamferWeights3D weights = ChamferWeights3D.fromLabel(gd.getNextChoice()); // check if image is a label image if (!LabelImages.isLabelImageType(labelPlus)) { IJ.showMessage("Input image should be a label image"); return; } // extract label ImageProcessor ImageStack labelImage = labelPlus.getStack(); // Compute geodesic diameters, using floating-point calculations long start = System.nanoTime(); ResultsTable table = process(labelImage, weights.getFloatWeights()); long finalTime = System.nanoTime(); // Final time, displayed in milliseconds float elapsedTime = (finalTime - start) / 1000000.0f; // display the result table String tableName = labelPlus.getShortTitle() + "-GeodDiameters"; table.show(tableName); IJUtils.showElapsedTime("Geodesic Diameter 3D", (long) elapsedTime, labelPlus); // extract column corresponding to geodesic diameter int gdIndex = table.getColumnIndex("Geod. Diam."); double[] geodDiamArray = table.getColumnAsDoubles(gdIndex); // Check validity of resulting geodesic diameters for (double geodDiam : geodDiamArray) { if (Float.isInfinite((float) geodDiam)) { IJ.showMessage("Geodesic Diameter Warning", "Some geodesic diameters are infinite,\n" + "meaning that some particles are not connected.\n" + "Maybe labeling was not performed?"); break; } } }