本文整理汇总了Java中ij.measure.ResultsTable.getHeadings方法的典型用法代码示例。如果您正苦于以下问题:Java ResultsTable.getHeadings方法的具体用法?Java ResultsTable.getHeadings怎么用?Java ResultsTable.getHeadings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.ResultsTable
的用法示例。
在下文中一共展示了ResultsTable.getHeadings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPathObjectsFromROIs
import ij.measure.ResultsTable; //导入方法依赖的package包/类
/**
* Turn an array of ImageJ ROIs into a list of QuPath PathObjects, optionally adding measurements as well.
*
* @param imp
* @param rois
* @param server
* @param downsample
* @param asDetection
* @param includeMeasurements
* @return
*/
public static List<PathObject> createPathObjectsFromROIs(final ImagePlus imp, final Roi[] rois, final ImageServer<?> server, final double downsample, final boolean asDetection, final boolean includeMeasurements, final int c, final int z, final int t) {
List<PathObject> pathObjects = new ArrayList<>();
ResultsTable rt = new ResultsTable();
Analyzer analyzer = new Analyzer(imp, Analyzer.getMeasurements(), rt);
String[] headings = null;
for (Roi roi : rois) {
PathObject pathObject = IJTools.convertToPathObject(imp, server, roi, downsample, asDetection, c, z, t);
if (pathObject == null)
IJ.log("Sorry, I could not convert " + roi + " to a value QuPath object");
else {
// Make measurements
if (includeMeasurements) {
ImageProcessor ip = imp.getProcessor();
ip.setRoi(roi);
ImageStatistics stats = ImageStatistics.getStatistics(ip, Analyzer.getMeasurements(), imp.getCalibration());
analyzer.saveResults(stats, roi);
// Get measurements from table and append
if (headings == null)
headings = rt.getHeadings();
int row = rt.getCounter()-1;
MeasurementList ml = pathObject.getMeasurementList();
for (String h : headings) {
if ("Label".equals(h))
continue;
ml.putMeasurement(h, rt.getValue(h, row));
}
ml.closeList();
}
pathObjects.add(pathObject);
}
}
return pathObjects;
}
示例2: run
import ij.measure.ResultsTable; //导入方法依赖的package包/类
@Override
public void run(String arg) {
if ("about".equalsIgnoreCase(arg)) {
IJ.showMessage("About " + TITLE, ABOUT);
return;
}
final Pair<List<ResultsTable>, List<String>> resultTables = listTextWindows();
if (resultTables.getFirst().size() < 1) {
IJ.error("Expecting at least one open Result Table window.");
return;
}
final Pair<List<ImagePlus>, List<String>> images = listSupportedImages();
if (images.getFirst().size() < 1) {
IJ.error("Expecting at least one open image (that is not indexed color).");
return;
}
// Ask user for image, results table, and other options
if (!showOptionsDialog(resultTables.getSecond(), images.getSecond())) {
return;
}
if (CONFIG.interpretStackAs3D) {
IJ.error(TITLE, "Interpreting stacks as 3D images not yet supported.");
return;
}
final ResultsTable rt = resultTables.getFirst().get(CONFIG.tableIndex);
final ImagePlus imp = images.getFirst().get(CONFIG.imageIndex);
//
// Verify that table headings match image bands
//
final ImagePlus stack = KMeansClusteringPlugin.convertToFloatStack(imp);
final int stackSize = stack.getStackSize();
final String[] bandLabels = stack.getStack().getSliceLabels();
final String[] expectedHeadings = new String[stackSize + 1];
expectedHeadings[0] = "Cluster";
System.arraycopy(bandLabels, 0, expectedHeadings, 1, stackSize);
final String[] tableHeadings = rt.getHeadings();
if (tableHeadings.length < expectedHeadings.length) {
IJ.error(TITLE, "Not enough headings, expecting: " + Arrays.toString(expectedHeadings));
return;
}
for (int i = 0; i < expectedHeadings.length; i++) {
if (!expectedHeadings[i].equals(tableHeadings[i])) {
IJ.error(TITLE, "Expecting heading " + (i + 1) + " to be " + expectedHeadings[i] + ", but got: " + tableHeadings[i] + ".");
return;
}
}
// Read cluster centers from the table
final int nbClusters = rt.getCounter();
final float[][] clusterCenters = new float[nbClusters][expectedHeadings.length - 1];
for (int clusterIndex = 0; clusterIndex < nbClusters; clusterIndex++) {
for (int bandIndex = 1; bandIndex < expectedHeadings.length; bandIndex++)
clusterCenters[clusterIndex][bandIndex - 1] = (float) rt.getValueAsDouble(bandIndex, clusterIndex);
}
// Apply clustering to input image
final VectorProcessor vp = new VectorProcessor(stack);
final ByteProcessor bp = KMeans2D.encodeSegmentedImage(vp, clusterCenters);
// Apply default color map
if (KMeansClusteringPlugin.APPLY_LUT) {
bp.setColorModel(KMeansClusteringPlugin.defaultColorModel());
}
if (KMeansClusteringPlugin.AUTO_BRIGHTNESS) {
bp.setMinAndMax(0, nbClusters);
}
new ImagePlus("Clusters", bp).show();
// Apply clustering
if (CONFIG.showCentroidImage) {
final ImageStack clustered = KMeansUtils.encodeCentroidValueImage(clusterCenters, new VectorProcessor(stack));
final ImagePlus cvImp = KMeansUtils.createCentroidImage(imp.getType(), clustered);
cvImp.show();
}
}