ij.measure.ResultsTable Java Examples

The following examples show how to use ij.measure.ResultsTable. 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: MaxFeretDiameter3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts the result of maximum Feret diameters computation to a
 * ResultsTable that can be displayed within ImageJ.
 * 
 * @param maxDiamsMap
 *            the map of PointPair3D for each label within a label image
 * @return a ResultsTable instance
 */
public ResultsTable createTable(Map<Integer, PointPair3D> maxDiamsMap)
{
	// Create data table
	ResultsTable table = new ResultsTable();

	// compute ellipse parameters for each region
	for (int label : maxDiamsMap.keySet()) 
	{
		table.incrementCounter();
		table.addLabel(Integer.toString(label));
		
		// add coordinates of origin pixel (IJ coordinate system)
		PointPair3D maxDiam = maxDiamsMap.get(label);
		table.addValue("Diameter", maxDiam.diameter());
		table.addValue("P1.x", maxDiam.p1.getX());
		table.addValue("P1.y", maxDiam.p1.getY());
		table.addValue("P1.z", maxDiam.p1.getZ());
		table.addValue("P2.x", maxDiam.p2.getX());
		table.addValue("p2.y", maxDiam.p2.getY());
		table.addValue("p2.z", maxDiam.p2.getZ());
	}
	
	// return the created array
	return table;
}
 
Example #2
Source File: Polyline.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResultsTable measure(ResultsTable rt) {
	if (-1 == n_points) setupForDisplay(); //reload
	if (0 == n_points) return rt;
	if (null == rt) rt = Utils.createResultsTable("Polyline results", new String[]{"id", "length", "name-id"});
	// measure length
	double len = 0;
	final Calibration cal = layer_set.getCalibration();
	if (n_points > 1) {
		final VectorString3D vs = asVectorString3D();
		vs.calibrate(cal);
		len = vs.computeLength(); // no resampling
	}
	rt.incrementCounter();
	rt.addLabel("units", cal.getUnit());
	rt.addValue(0, this.id);
	rt.addValue(1, len);
	rt.addValue(2, getNameId());
	return rt;
}
 
Example #3
Source File: RegionMorphometryPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #4
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getMean()}.
 */
@Test
public final void testGetMean_NineLabels()
{
    // use the same image for label and gray levels
    ImagePlus labelImagePlus = createImage3DNineLabels();
    ImagePlus grayImagePlus = createImage3DNineLabels();
    double[] meanValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6., 7.0, 8.0, 10.0};
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getMean();
    assertEquals(9, table.getCounter());
    for (int i = 0; i < 9; i++)
    {
        assertEquals(meanValues[i], table.getValueAsDouble(0, i), .01);
    }
}
 
Example #5
Source File: LabeledVoxelsMeasure.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get number of voxels per label
 * @return number of voxels per label
 */
public ResultsTable getNumberOfVoxels()
{
	final int numLabels = objectVoxels.length;
			
	// create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < numLabels; i++)
	{
		table.incrementCounter();
		table.addLabel(Integer.toString( labels[i] ));
		table.addValue("NumberOfVoxels", objectVoxels[ i ].size() );
	}

	return table;
}
 
Example #6
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getMean()}.
 */
@Test
public final void testGetMean_EightAdjacentCubes()
{
    // use the same image for label and gray levels
    ImagePlus labelImagePlus = createImage3DEightAdjacentLabels();
    ImagePlus grayImagePlus = createImage3DEightAdjacentLabels();
    
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getMean();
    assertEquals(8, table.getCounter());
    for (int i = 0; i < 8; i++)
    {
        assertEquals(i+1, table.getValueAsDouble(0, i), .01);
    }
}
 
Example #7
Source File: Dissector.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
final void addResults(final ResultsTable rt, final Calibration cal, final double nameid) {
	for (int i=0; i<n_points; i++) {
		final Layer la = layer_set.getLayer(p_layer[i]);
		if (null == layer) {
			Utils.log("Dissector.addResults: could not find layer with id " + p_layer[i]);
			continue;
		}
		final Point2D.Double po = M.transform(Dissector.this.at, p[0][i], p[1][i]);
		rt.incrementCounter();
		rt.addLabel("units", cal.getUnit());
		rt.addValue(0, Dissector.this.id);
		rt.addValue(1, tag);
		rt.addValue(2, po.x * cal.pixelWidth);
		rt.addValue(3, po.y * cal.pixelHeight);
		rt.addValue(4, la.getZ() * cal.pixelWidth); // layer Z is in pixels
		rt.addValue(5, radius * cal.pixelWidth);
		rt.addValue(6, nameid);
	}
}
 
Example #8
Source File: AreaList.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResultsTable measure(ResultsTable rt) {
	if (0 == ht_areas.size()) return rt;
	if (null == rt) rt = Utils.createResultsTable("AreaList results",
			new String[]{"id", "volume", "LB-surface", "UBs-surface",
			"UB-surface", "AVGs-surface", "AVG-surface", "max diameter",
			"Sum of tops", "name-id", "Xcm", "Ycm", "Zcm"});
	rt.incrementCounter();
	rt.addLabel("units", layer_set.getCalibration().getUnit());
	rt.addValue(0, this.id);
	final double[] m = measure();
	rt.addValue(1, m[0]); // aprox. volume
	rt.addValue(2, m[1]); // lower bound surface
	rt.addValue(3, m[2]); // upper bound surface smoothed
	rt.addValue(4, m[3]); // upper bound surface
	rt.addValue(5, (m[1] + m[2]) / 2); // average of LB and UBs
	rt.addValue(6, (m[1] + m[3]) / 2); // average of LB and UB
	rt.addValue(7, m[4]); // max diameter
	rt.addValue(8, m[5]); // sum of all cappings (tops and bottoms)
	rt.addValue(9, getNameId());
	rt.addValue(10, m[6]); // X of the center of mass
	rt.addValue(11, m[7]); // Y
	rt.addValue(12, m[8]); // Z
	return rt;
}
 
Example #9
Source File: LargestInscribedCircleTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.region2d.LargestInscribedCircle#analyzeRegions(ij.ImagePlus)}.
 */
@Test
public final void testAnalyzeRegionsImagePlus_Rectangles()
{
	ImageProcessor image = new ByteProcessor(14, 9);
	image.set(1, 1, 1);
	fillRect(image, 3, 4, 1, 2, 2);		// radius 2
	fillRect(image, 1, 1+3, 4, 4+3, 3); // radius 4
	fillRect(image, 6, 6+6, 1, 1+6, 4); // radius 7
	
	LargestInscribedCircle op = new LargestInscribedCircle();
	ResultsTable table = op.createTable(op.analyzeRegions(image, new Calibration()));
	
	assertEquals(1, table.getValue("InscrCircle.Radius", 0), .1);
	assertEquals(1, table.getValue("InscrCircle.Radius", 1), .1);
	assertEquals(2, table.getValue("InscrCircle.Radius", 2), .1);
	assertEquals(4, table.getValue("InscrCircle.Radius", 3), .1);
}
 
Example #10
Source File: Convexity.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ResultsTable createTable(Map<Integer, Convexity.Result> results)
{
	// Initialize a new result table
	ResultsTable table = new ResultsTable();

	// Convert all results that were computed during execution of the
	// "computeGeodesicDistanceMap()" method into rows of the results table
	for (int label : results.keySet())
	{
		// current diameter
		Result res = results.get(label);
		
		// add an entry to the resulting data table
		table.incrementCounter();
		table.addLabel(Integer.toString(label));
		table.addValue("Area", res.area);
		table.addValue("ConvexArea", res.convexArea);
		table.addValue("Convexity", res.convexity);
	}

	return table;
}
 
Example #11
Source File: MaxFeretDiameter.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts the result of maximum Feret diameters computation to a
 * ResultsTable that can be displayed within ImageJ.
 * 
 * @param maxDiamsMap
 *            the map of PointPair2D for each label within a label image
 * @return a ResultsTable instance
 */
public ResultsTable createTable(Map<Integer, PointPair2D> maxDiamsMap)
{
	// Create data table
	ResultsTable table = new ResultsTable();

	// compute ellipse parameters for each region
	for (int label : maxDiamsMap.keySet()) 
	{
		table.incrementCounter();
		table.addLabel(Integer.toString(label));
		
		// add coordinates of origin pixel (IJ coordinate system)
		PointPair2D maxDiam = maxDiamsMap.get(label);
		table.addValue("Diameter", maxDiam.diameter());
		table.addValue("Orientation", Math.toDegrees(maxDiam.angle()));
		table.addValue("P1.x", maxDiam.p1.getX());
		table.addValue("P1.y", maxDiam.p1.getY());
		table.addValue("P2.x", maxDiam.p2.getX());
		table.addValue("p2.y", maxDiam.p2.getY());
	}
	
	// return the created array
	return table;
}
 
Example #12
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getNeighborsMedian()}.
 */
@Test
public final void testGetNeighborsMedian_NineLabels()
{
    // use the same image for label and gray levels
    ImagePlus labelImagePlus = createImage3DNineLabels();
    ImagePlus grayImagePlus = createImage3DNineLabels();
    double[] medianValues = new double[] {3.0, 4.0, 4.0, 3.0, 6.0, 5.0, 5.0, 6.0, Double.NaN};
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getNeighborsMedian();
    assertEquals(9, table.getCounter());
    for (int i = 0; i < 9; i++)
    {
        assertEquals(medianValues[i], table.getValueAsDouble(0, i), .01);
    }
}
 
Example #13
Source File: LabeledVoxelsMeasure.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
	 * Get sum of all voxel intensities per labeled object
	 * 
	 *  @return sum of voxel intensities (Integrated Density) per labeled object
	 */
	public ResultsTable getSumOfVoxels() 
	{
		final int numLabels = objectVoxels.length;

		// create data table
		ResultsTable table = new ResultsTable();
		for (int i = 0; i < numLabels; i++)
		{
			table.incrementCounter();
			table.addLabel(Integer.toString( labels[i] ));
//			double vox_sum = objectVoxels[ i ].stream().mapToDouble(Double::doubleValue).sum();
			// compute the sum, 1.6-compatible
			double voxelSum = 0;
			for (double value : objectVoxels[i])
			{
				voxelSum += value;
			}
			table.addValue( "Voxels Sum", voxelSum);
		}
			return table;
	}
 
Example #14
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getNeighborsMean()}.
 */
@Test
public final void testGetNeighborsMean_NineLabels()
{
    // use the same image for label and gray levels
    ImagePlus labelImagePlus = createImage3DNineLabels();
    ImagePlus grayImagePlus = createImage3DNineLabels();
    double[] meanValues = new double[] {3.33, 3.67, 4.0, 4.33, 4.67, 5.00, 5.33, 5.67, Double.NaN};
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getNeighborsMean();
    assertEquals(9, table.getCounter());
    for (int i = 0; i < 9; i++)
    {
        assertEquals(meanValues[i], table.getValueAsDouble(0, i), .01);
    }
}
 
Example #15
Source File: OrientedBoundingBox2D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ResultsTable createTable(Map<Integer, OrientedBox2D> results)
{
	// Create data table
	ResultsTable table = new ResultsTable();

	// convert each item into a row of the table
	for (int label : results.keySet()) 
	{
		table.incrementCounter();
		table.addLabel(Integer.toString(label));
		
		// add new row containing parameters of oriented box
		OrientedBox2D obox = results.get(label);
		Point2D center = obox.center();
		table.addValue("Box.Center.X", 	center.getX());
		table.addValue("Box.Center.Y",	center.getY());
		table.addValue("Box.Length", 	obox.length());
		table.addValue("Box.Width", 	obox.width());
		table.addValue("Box.Orientation", obox.orientation());
	}

	return table;
}
 
Example #16
Source File: Ball.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
/** Returns a listing of all balls contained here, one per row with index, x, y, z, and radius, all calibrated.
 * 'name-id' is a column that displays the title of this Ball object only when such title is purely a number.
 */
@Override
public ResultsTable measure(ResultsTable rt) {
	if (-1 == n_points) setupForDisplay(); //reload
	if (0 == n_points) return rt;
	if (null == rt) rt = Utils.createResultsTable("Ball results", new String[]{"id", "index", "x", "y", "z", "radius", "name-id"});
	final Object[] ob = getTransformedData();
	final double[][] p = (double[][])ob[0];
	final double[] p_width = (double[])ob[1];
	final Calibration cal = layer_set.getCalibration();
	for (int i=0; i<n_points; i++) {
		rt.incrementCounter();
		rt.addLabel("units", cal.getUnit());
		rt.addValue(0, this.id);
		rt.addValue(1, i+1);
		rt.addValue(2, p[0][i] * cal.pixelWidth);
		rt.addValue(3, p[1][i] * cal.pixelHeight);
		rt.addValue(4, layer_set.getLayer(p_layer[i]).getZ() * cal.pixelWidth);
		rt.addValue(5, p_width[i] * cal.pixelWidth);
		rt.addValue(6, getNameId());
	}
	return rt;
}
 
Example #17
Source File: LabeledVoxelsMeasure.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get volume per labeled object based on the input
 * image calibration
 * 
 * @return volume per labeled object
 */
public ResultsTable getVolume()
{
	final int numLabels = objectVoxels.length;
	
	double volumePerVoxel = calibration.pixelWidth * calibration.pixelHeight * calibration.pixelDepth;
	
	// create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < numLabels; i++) 
	{
		table.incrementCounter();
		table.addLabel(Integer.toString( labels[i] ));
		table.addValue( "Volume", objectVoxels[ i ].size() * volumePerVoxel );
	}

	return table;
}
 
Example #18
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getMedian()}.
 */
@Test
public final void testGetMedian_NineLabels()
{
    // use the same image for label and gray levels
    ImagePlus labelImagePlus = createImage3DNineLabels();
    ImagePlus grayImagePlus = createImage3DNineLabels();
    double[] medianValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0};
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getMedian();
    assertEquals(9, table.getCounter());
    for (int i = 0; i < 9; i++)
    {
        assertEquals(medianValues[i], table.getValueAsDouble(0, i), .01);
    }
}
 
Example #19
Source File: Pipe.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResultsTable measure(ResultsTable rt) {
	if (-1 == n_points) setupForDisplay(); //reload
	if (0 == n_points) return rt;
	if (null == rt) rt = Utils.createResultsTable("Pipe results", new String[]{"id", "length", "name-id"});
	// measure length
	double len = 0;
	final Calibration cal = layer_set.getCalibration();
	if (n_points > 1) {
		final VectorString3D vs = asVectorString3D();
		vs.calibrate(cal);
		len = vs.computeLength(); // no resampling
	}
	rt.incrementCounter();
	rt.addLabel("units", cal.getUnit());
	rt.addValue(0, this.id);
	rt.addValue(1, len);
	rt.addValue(2, getNameId());
	return rt;
}
 
Example #20
Source File: GeometricMeasures2DTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link ijt.measure.geometric.GeometricMeasures2D#maxInscribedCircle(ij.process.ImageProcessor)}.
 */
@Test
@Deprecated
public final void testMaxInscribedCircle() 
{
	ImageProcessor image = new ByteProcessor(14, 9);
	image.set(1, 1, 1);
	fillRect(image, 3, 4, 1, 2, 2);		// radius 2
	fillRect(image, 1, 1+3, 4, 4+3, 3); // radius 4
	fillRect(image, 6, 6+6, 1, 1+6, 4); // radius 7
	
	ResultsTable table = GeometricMeasures2D.maximumInscribedCircle(image);
	
	assertEquals(1, table.getValue("InscrCircle.Radius", 0), .1);
	assertEquals(1, table.getValue("InscrCircle.Radius", 1), .1);
	assertEquals(2, table.getValue("InscrCircle.Radius", 2), .1);
	assertEquals(4, table.getValue("InscrCircle.Radius", 3), .1);
}
 
Example #21
Source File: IntensityMeasuresTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.measure.IntensityMeasures#getMedian()}.
 */
@Test
public final void testGetMedian()
{
    String fileName = getClass().getResource("/files/grains.tif").getFile();
    ImagePlus grayImagePlus = IJ.openImage(fileName);
    assertNotNull(grayImagePlus);
    
    fileName = getClass().getResource("/files/grains-med-WTH-lbl.tif").getFile();
    ImagePlus labelImagePlus = IJ.openImage(fileName);
    assertNotNull(labelImagePlus);
    
    IntensityMeasures algo = new IntensityMeasures(grayImagePlus, labelImagePlus);
    
    ResultsTable table = algo.getMedian();
    assertTrue(table.getCounter() > 80);
}
 
Example #22
Source File: GeometricMeasures3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Measures the volume of each particle in a 3D label image.
 * 
 * @deprecated used IntrinsicVolumes3D instead
 * 
 * @param labelImage image containing the label of each particle
 * @param resol image resolution, as a double array with 3 elements
 * @return the volume of each particle in the image
 */
@Deprecated
public final static ResultsTable volume(ImageStack labelImage, double[] resol) 
{
	Calibration calib = new Calibration();
	calib.pixelWidth = resol[0];
	calib.pixelHeight = resol[1];
	calib.pixelDepth = resol[2];
	
	IJ.showStatus("Compute volume...");
	int[] labels = LabelImages.findAllLabels(labelImage);
	int nbLabels = labels.length;

	double[] volumes = IntrinsicVolumes3D.volumes(labelImage, labels, calib);

	// Create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < nbLabels; i++) 
	{
		table.incrementCounter();
		table.addLabel(Integer.toString(labels[i]));
		table.addValue("Volume", volumes[i]);
	}

	IJ.showStatus("");
	return table;
}
 
Example #23
Source File: GeodesicDiameterShortTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.binary.geodesic.GeodesicDiameterShort#analyzeImage(ij.process.ImageProcessor)}.
 */
@Test
public void testAnalyzeImage_Grains()
{
	ImagePlus imagePlus = IJ.openImage(getClass().getResource("/files/grains-WTH-areaOpen-lbl2.tif").getFile());
	ImageProcessor image = imagePlus.getProcessor();

	// Need to use weights in 3-by-3 neighborhood, to avoid propagating distances to another grain 
	GeodesicDiameterShort algo = new GeodesicDiameterShort(ChamferWeights.BORGEFORS);
	ResultsTable table = algo.analyzeImage(image);

	assertEquals(71, table.getCounter());
}
 
Example #24
Source File: RegionAdjacencyGraphPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ResultsTable createTable(Set<LabelPair> adjList)
{
	ResultsTable table = new ResultsTable();
	table.setPrecision(0);
	
	// populate the table with the list of adjacencies
	for (LabelPair pair : adjList)
	{
		table.incrementCounter();
		table.addValue("Label 1", pair.label1);
		table.addValue("Label 2", pair.label2);
	}
	
	return table;
}
 
Example #25
Source File: LargestInscribedCircle.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Utility method that transforms the mapping between labels and inscribed
 * circle instances into a ResultsTable that can be displayed with ImageJ.
 * 
 * @param map
 *            the mapping between labels and Circle2D instances
 * @return a ResultsTable that can be displayed with ImageJ.
 */
public ResultsTable createTable(Map<Integer, Circle2D> map)
{
	// Initialize a new result table
	ResultsTable table = new ResultsTable();

	// Convert all results that were computed during execution of the
	// "computeGeodesicDistanceMap()" method into rows of the results table
	for (int label : map.keySet())
	{
		// current diameter
		Circle2D circle = map.get(label);
		
		// add an entry to the resulting data table
		table.incrementCounter();
		table.addLabel(Integer.toString(label));
		
		// coordinates of circle center
		table.addValue("InscrCircle.Center.X", circle.getCenter().getX());
		table.addValue("InscrCircle.Center.Y", circle.getCenter().getY());
		
		// circle radius
		table.addValue("InscrCircle.Radius", circle.getRadius());
	}

	return table;
}
 
Example #26
Source File: IntensityMeasures.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get minimum voxel values per label
 * 
 * @return result table with minimum values per label
 */
public ResultsTable getMin()
{
	this.min = minPerLabel();

	// create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < objectVoxels.length; i++) {
		table.incrementCounter();
		table.addLabel(Integer.toString( labels[i] ));
		table.addValue("Min", min[i]);
	}

	return table;
}
 
Example #27
Source File: IntensityMeasures.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get the standard deviation of the intensity values of the neighbor labels
 *
 * @return result table with standard deviation values of neighbor labels
 */
public ResultsTable getNeighborsStdDev()
{
	// Check if neighbors mean already exists
	if( null == neighborsMean )
		this.neighborsMean = neighborsMeanPerLabel();
	// Check if neighbor voxels have been calculated
	if( this.neighborVoxels == null )
		this.neighborVoxels = computeNeighborVoxels();
	final int numLabels = neighborsMean.length;

	double[] sd = new double[ numLabels ];

	// Calculate standard deviation
	for( int i=0; i<numLabels; i++ )
	{
		if( neighborVoxels[ i ].size() > 0 )
		{
			for( final double v : neighborVoxels[ i ] )
			{
				double diff = v - neighborsMean[ i ];
				sd[ i ] += diff * diff;
			}
			sd[ i ] /= neighborVoxels[ i ].size();
			sd[ i ] = Math.sqrt( sd[ i ] );
		}
		else
			sd[ i ] = Double.NaN;
	}

	// create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < numLabels; i++) {
		table.incrementCounter();
		table.addLabel(Integer.toString( labels[i] ));
		table.addValue("NeighborsStdDev", sd[i]);
	}

	return table;
}
 
Example #28
Source File: GeometricMeasures3DTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
@Deprecated
public final void testSurfaceArea_SingleBall_D3() {
	ImageStack image = createBallImage();
	double[] resol = new double[]{1, 1, 1};
	ResultsTable table = GeometricMeasures3D.surfaceArea(image, resol, 3);
	double exp = 5026.;
	assertEquals(1, table.getCounter());
	assertEquals(exp, table.getValueAsDouble(0, 0), 2.);
}
 
Example #29
Source File: AnalyzeRegions.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static final void addColumnToTable(ResultsTable table, String colName, double[] values)
{
	for (int i = 0; i < values.length; i++)
	{
		table.setValue(colName, i, values[i]);
	}
}
 
Example #30
Source File: IntensityMeasures.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get maximum voxel values per label
 * 
 * @return result table with maximum values per label
 */
public ResultsTable getMax()
{
	this.max = maxPerLabel();
	
	// create data table
	ResultsTable table = new ResultsTable();
	for (int i = 0; i < objectVoxels.length; i++) {
		table.incrementCounter();
		table.addLabel(Integer.toString( labels[i] ));
		table.addValue("Max", max[i]);
	}

	return table;
}