Java Code Examples for ij.measure.Calibration#scaled()

The following examples show how to use ij.measure.Calibration#scaled() . 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: OrientedBoundingBox2D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static final ArrayList<Point2D> calibrate(ArrayList<Point2D> points, Calibration calib)
{
	if (!calib.scaled())
	{
		return points;
	}
	
	ArrayList<Point2D> res = new ArrayList<Point2D>(points.size());
	for (Point2D point : points)
	{
		double x = point.getX() * calib.pixelWidth + calib.xOrigin;
		double y = point.getY() * calib.pixelHeight + calib.yOrigin;
		res.add(new Point2D.Double(x, y));
	}
	return res;
}
 
Example 2
Source File: RegionMorphometryPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ResultsTable process(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);

// return the created array
return results;
  }
 
Example 3
Source File: RegionMorphometryPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 4
Source File: AnalyzeMicrostructure3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Computes features from an ImageStack object, specifying the calibration.
 * 
 * @param image
 *            the 3D label image to analyze
 * @param calib
 *            the spatial calibration of the image
 * @return the results in a new ResultsTable
 */
public ResultsTable process(ImageStack image, Calibration calib)
{
    // Extract spatial calibration
    double[] resol = new double[]{1, 1, 1};
    if (calib != null && calib.scaled()) 
    {
        resol[0] = calib.pixelWidth;
        resol[1] = calib.pixelHeight;
        resol[2] = calib.pixelDepth;
    }

    // Compute histogram of binary 2-by-2-by-2 configurations (array length: 256)
    BinaryConfigurationsHistogram3D algo = new BinaryConfigurationsHistogram3D();
    DefaultAlgoListener.monitor(algo);
    IJ.showStatus("Compute Configuration Histogram");
    int[] histogram = algo.processInnerFrame(image);
  
    // pre-compute LUT corresponding to resolution and number of directions
    double vol = IntrinsicVolumes3D.samplingVolume(image, calib);
    
    // Convert to ResultsTable object
    IJ.showStatus("Create Table");
    ResultsTable table = new ResultsTable();
    
    table.incrementCounter();
    // geometrical quantities
    if (computeVolume)
    {
        double[] volumeLut = IntrinsicVolumes3DUtils.volumeLut(calib);
        double volume = BinaryConfigurationsHistogram3D.applyLut(histogram, volumeLut);
        table.addValue("VolumeDensity", volume / vol);
    }
    if (computeSurface)
    {
        double[] surfaceAreaLut = IntrinsicVolumes3DUtils.surfaceAreaLut(calib, surfaceAreaDirs);
        double surfaceArea = BinaryConfigurationsHistogram3D.applyLut(histogram, surfaceAreaLut);
        table.addValue("SurfaceAreaDensity", surfaceArea / vol);
    }
    if (computeMeanBreadth)
    {
        double[] meanBreadthLut = IntrinsicVolumes3DUtils.meanBreadthLut(calib, meanBreadthDirs, connectivity2d);
        double meanBreadth = BinaryConfigurationsHistogram3D.applyLut(histogram, meanBreadthLut);
        table.addValue("MeanBreadthDensity", meanBreadth / vol);
    }
    if (computeEulerNumber)
    {
        double[] eulerNumberLut = IntrinsicVolumes3DUtils.eulerNumberLut(connectivity);
        double eulerNumber = BinaryConfigurationsHistogram3D.applyLut(histogram, eulerNumberLut);
        table.addValue("EulerNumberDensity", eulerNumber / vol);
    }

    return table;
 }