Class Measurement3d

java.lang.Object
com.eco.bio7.spatial.Measurement3d

public class Measurement3d extends Object
Measurements of the iso surface and the volume in the 3D view. The results are displayed in new sheets of the Bio7 table:
  • The objects of the iso surface (connected parts of the mesh): volume, surface area, sphericity, centroid, ellipsoid axes, Feret diameter, holes, bounding box.
  • The statistics of the voxels in the region of the clipping (box, plane and mask) and the volume above a threshold.
  • Points picked with the mouse on the displayed data (the position, the value and the distances like a ruler, see Clipping.TOOL_PICK).
The values are calibrated (the unit of the image).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The types of the areas (the first value of a row of getAreas).
    static final String[]
    The columns of the measured areas and volumes (see getAreas).
    static final int
    The types of the areas (the first value of a row of getAreas).
    static final int
    The types of the areas (the first value of a row of getAreas).
    static final int
    The types of the areas (the first value of a row of getAreas).
    static final int
    The types of the areas (the first value of a row of getAreas).
    static final String[]
    The columns of the nearest neighbor distances (see measureDistances).
    static final String[]
    The columns of the iso surface measurement (see measureIsoSurface).
    static final int
    The matrices are displayed for up to this number of objects (see measureDistances).
    static final int
     
    static final int
    The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
    static final String[]
    The columns of the picked points (see getPoints).
    static final int
    The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
    static final int
    The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
    static final int
    The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
    static final String[]
    The columns of the region measurement (see measureRegion).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the measurements in the 3D view: the colors, numbers and selection of the objects and the picked points (the sheets of the table are kept).
    void
    Removes the highlight of the measured objects.
    void
    Removes the picked points and the measured areas (new sheets are created for the next measurements).
    void
    deleteSelected(boolean whole)
    Deletes the active point of the selected measurement (the last pressed or added point) or, if whole is true, the selected measurement.
    static String
    formatValue(double v)
    Formats a value like the tables of the measurements (see setDecimals).
    List<double[]>
    Returns the measured areas and volumes of the mouse tools (polygon, freehand, volume): the values of AREA_COLUMNS (the type is one of AREA_POLYGON, AREA_FREEHAND, AREA_OUTLINE, AREA_OBJECT; NaN if not available).
    int
    Returns the decimals of the tables (see setDecimals, -1 = full precision).
    double
    Returns the radius of the surface eraser (points of the screen).
    int
    getLabelAt(double x, double y)
    Returns the object number of the displayed label at the mouse position (in the 3D view, pixels from the top left) or 0.
    The CSV files of the matrices of the last measurement of the distances (see setMatrixFolder).
    int
    Returns the maximum size of a measured object (voxels of the data, 0 = no maximum).
    int
    Returns the minimum size of a measured object (voxels of the data).
    List<double[]>
    Returns the picked points (calibrated x, y, z, the value, the distance to the previous point and the length of the path, see POINT_COLUMNS).
    Returns the types of the picked points (like the column "Type" of the table "3D Points": "Segmented Line", "Point", "Straight Line", "Angle", a line which follows the surface with "(Surface)").
    int
    Returns the selected object (0 = none).
    Returns the settings of the measured iso surface (the iso value, the smoothing, the mesh smoothing, the resolution and the object sizes), which are also shown in the last row of the table of the objects.
    boolean
    Returns true if the volume of a clicked cavity is its free space (see setCavityFreeSpace).
    boolean
    Returns true if the lines and areas are fitted with a spline (see setFitSpline).
    boolean
    Returns true if the lines follow the surface (see setFollowSurface).
    boolean
    Returns true if the measured objects are highlighted (colors and numbers).
    boolean
    Returns true if the volume of a clicked object is its filled volume (see setObjectFilled).
    boolean
    Returns true if the sheets of the distance matrices are shown (see setShowDistanceMatrices).
    boolean
    Returns true if the numbers of the measurements are shown (see setShowNumbers).
    boolean
    Returns true if only the measured volumes are shown (the iso surface is hidden).
    boolean
    Returns true if the measured volumes are shown through the surface.
    boolean
    Returns true if the measured volumes are drawn as triangles.
    double[][][]
    measureDistances(boolean showTable)
    Measures the distances between the objects of the iso surface (the objects are measured again, see measureIsoSurface): for every object the nearest neighbor of the centroids and of the surfaces (edge to edge: the shortest distance between the triangles), the matrices of all centroid and surface distances and the Clark-Evans index R of the centroids (3D, R invalid input: '<' 1 clustered, R = 1 random, R > 1 regular, without an edge correction).
    double[][][]
    measureDistances(boolean showTable, org.eclipse.core.runtime.IProgressMonitor monitor)
    Measures the distances (see measureDistances(boolean)) with the progress of the steps (the objects, the centroid and the surface distances, the tables).
    double[][]
    measureIsoSurface(boolean showTable)
    Measures the objects (connected parts) of the iso surface mesh, sorted by the volume.
    double[]
    measureRegion(boolean showTable)
    Measures the voxels of the displayed stack (the full resolution of the ImageJ image or the data of a model) in the region of the clipping (the box, the cutting plane and the mask, the whole stack without a clipping).
    static int
    objectColor(int number)
    Returns the color (0xRRGGBB) of an object number (the colors of the objects in the 3D view and in the table).
    boolean
    pick(double[] start, double[] end)
    Picks the first visible point of the iso surface (or of the volume) along a ray like the mouse (the ruler, see getPoints), e.g., in a script.
    boolean
    Removes the surface of the selected area (else of the last measured area with a surface: a polygon, a freehand area, an object or a cavity) from the displayed iso surface: the surface is cut open (e.g., to measure inside of an object).
    void
    render(com.jogamp.opengl.GL2 gl, double[] bounds, boolean flip, boolean cartesian, float pixelScale)
    Draws the picked points and the lines between them (the scene coordinates of the current model view matrix).
    boolean
    selectLabelAt(double x, double y)
    Selects the object of the number label at the mouse position (in the 3D view, pixels from the top left).
    void
    selectObject(int number)
    Selects a measured object (highlighted in the 3D view, the other objects are dimmed) and the row of the object in the table.
    void
    setCavityFreeSpace(boolean freeSpace)
    The volume of a clicked cavity (its wall): true without the objects which float in it (the free space), false the whole space inside of the wall.
    void
    setDecimals(int digits)
    Sets the number of decimals of the values in the tables and in the CSV files of the matrices (default 4).
    void
    setEraserRadius(double radius)
    Sets the radius of the surface eraser (points of the screen, 1 - 200).
    void
    setFitSpline(boolean spline)
    Sets if the next segmented lines, polygons and freehand areas are fitted with a spline (a centripetal Catmull-Rom spline through the points, like "Fit Spline" of ImageJ): the length, the perimeter and the areas are measured along the spline.
    void
    setFollowSurface(boolean follow)
    Sets if the next segments of the segmented and the straight lines follow the surface (the path on the visible surface along the screen line between the points, measured along the surface) or are straight lines in 3D (the default).
    void
    setHighlightObjects(boolean highlight)
    Highlights the measured objects with colors and numbers (the object numbers of the table) in the 3D view.
    void
    Saves all centroid and surface distance matrices of the next measurements of the distances as CSV files in the folder (for any number of objects, the tables show the matrices for up to MAX_CENTROID_MATRIX and MAX_SURFACE_MATRIX objects).
    void
    setMaxObjectSize(int voxels)
    Sets the maximum size of a measured object (voxels of the data), larger objects are not measured (e.g., a background).
    void
    setMinObjectSize(int voxels)
    Sets the minimum size of a measured object (voxels of the data), smaller objects (e.g., noise) are not measured.
    void
    setObjectFilled(boolean filled)
    The volume of a clicked object: true the filled volume (inside of its outer surface, with its cavities), false the volume of its material (the outer surface without the cavities).
    static void
    Receives the description of what a click of the volume tool measures (the surface under the mouse) or an empty text (not in the UI thread).
    void
    Shows the centroid and the surface distance matrices in sheets of the table (see measureDistances; off by default: only the sheet of the nearest neighbors).
    void
    setShowNumbers(boolean show)
    Shows the numbers of the measurements in the 3D view: the row of an area in the table "3D Areas" (green) and the row of a point in the table "3D Points" (blue; for a line or an angle the row of its last point with the length or the angle).
    void
    setShowOnlyVolumes(boolean only)
    Shows only the measured volumes: the iso surface is hidden (its data and the measurements stay; the mouse tools still measure on it).
    void
    setShowVolumesThrough(boolean show)
    Shows the measured volumes (objects, cavities, outlines) as transparent bodies through the surface, e.g., a cavity inside of the object.
    void
    setShowVolumeTriangles(boolean show)
    Draws the measured volumes as triangles (a wireframe on a fainter fill).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ISO_COLUMNS

      public static final String[] ISO_COLUMNS
      The columns of the iso surface measurement (see measureIsoSurface).
    • DISTANCE_COLUMNS

      public static final String[] DISTANCE_COLUMNS
      The columns of the nearest neighbor distances (see measureDistances).
    • MAX_CENTROID_MATRIX

      public static final int MAX_CENTROID_MATRIX
      The matrices are displayed for up to this number of objects (see measureDistances).
      See Also:
    • MAX_SURFACE_MATRIX

      public static final int MAX_SURFACE_MATRIX
      See Also:
    • REGION_COLUMNS

      public static final String[] REGION_COLUMNS
      The columns of the region measurement (see measureRegion).
    • POINT_COLUMNS

      public static final String[] POINT_COLUMNS
      The columns of the picked points (see getPoints).
    • POINT_LINE

      public static final int POINT_LINE
      The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
      See Also:
    • POINT_SINGLE

      public static final int POINT_SINGLE
      The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
      See Also:
    • POINT_STRAIGHT

      public static final int POINT_STRAIGHT
      The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
      See Also:
    • POINT_ANGLE

      public static final int POINT_ANGLE
      The kinds of the picked points: a point of a segmented line, a single point, a point of a straight line and a point of an angle (the second point is the vertex).
      See Also:
    • AREA_COLUMNS

      public static final String[] AREA_COLUMNS
      The columns of the measured areas and volumes (see getAreas).
    • AREA_POLYGON

      public static final int AREA_POLYGON
      The types of the areas (the first value of a row of getAreas).
      See Also:
    • AREA_FREEHAND

      public static final int AREA_FREEHAND
      The types of the areas (the first value of a row of getAreas).
      See Also:
    • AREA_OUTLINE

      public static final int AREA_OUTLINE
      The types of the areas (the first value of a row of getAreas).
      See Also:
    • AREA_OBJECT

      public static final int AREA_OBJECT
      The types of the areas (the first value of a row of getAreas).
      See Also:
    • AREA_CAVITY

      public static final int AREA_CAVITY
      The types of the areas (the first value of a row of getAreas).
      See Also:
  • Method Details

    • getMinObjectSize

      public int getMinObjectSize()
      Returns the minimum size of a measured object (voxels of the data).
    • setMinObjectSize

      public void setMinObjectSize(int voxels)
      Sets the minimum size of a measured object (voxels of the data), smaller objects (e.g., noise) are not measured.
    • getMaxObjectSize

      public int getMaxObjectSize()
      Returns the maximum size of a measured object (voxels of the data, 0 = no maximum).
    • setMaxObjectSize

      public void setMaxObjectSize(int voxels)
      Sets the maximum size of a measured object (voxels of the data), larger objects are not measured (e.g., a background). 0 measures all objects (the default).
    • measureIsoSurface

      public double[][] measureIsoSurface(boolean showTable)
      Measures the objects (connected parts) of the iso surface mesh, sorted by the volume. The axes are the lengths of the axes of the ellipsoid with the same moments of inertia. Holes is the number of tunnels (genus). Mean Inside Value is the mean of the data one voxel inside of the surface.
      Parameters:
      showTable - true displays the results in a new sheet of the Bio7 table
      Returns:
      a row for each object with the values of ISO_COLUMNS or null if no surface is available
    • objectColor

      public static int objectColor(int number)
      Returns the color (0xRRGGBB) of an object number (the colors of the objects in the 3D view and in the table).
    • isHighlightObjects

      public boolean isHighlightObjects()
      Returns true if the measured objects are highlighted (colors and numbers).
    • setHighlightObjects

      public void setHighlightObjects(boolean highlight)
      Highlights the measured objects with colors and numbers (the object numbers of the table) in the 3D view.
    • selectObject

      public void selectObject(int number)
      Selects a measured object (highlighted in the 3D view, the other objects are dimmed) and the row of the object in the table.
      Parameters:
      number - the object number (1 - n, 0 removes the selection)
    • getSelectedObject

      public int getSelectedObject()
      Returns the selected object (0 = none).
    • selectLabelAt

      public boolean selectLabelAt(double x, double y)
      Selects the object of the number label at the mouse position (in the 3D view, pixels from the top left). A click on the selected label removes the selection.
      Returns:
      true if a label has been hit
    • getLabelAt

      public int getLabelAt(double x, double y)
      Returns the object number of the displayed label at the mouse position (in the 3D view, pixels from the top left) or 0.
    • setShowDistanceMatrices

      public void setShowDistanceMatrices(boolean show)
      Shows the centroid and the surface distance matrices in sheets of the table (see measureDistances; off by default: only the sheet of the nearest neighbors). The matrices are returned by measureDistances in any case.
      Parameters:
      show - true to show the sheets of the matrices
    • isShowDistanceMatrices

      public boolean isShowDistanceMatrices()
      Returns true if the sheets of the distance matrices are shown (see setShowDistanceMatrices).
    • measureDistances

      public double[][][] measureDistances(boolean showTable)
      Measures the distances between the objects of the iso surface (the objects are measured again, see measureIsoSurface): for every object the nearest neighbor of the centroids and of the surfaces (edge to edge: the shortest distance between the triangles), the matrices of all centroid and surface distances and the Clark-Evans index R of the centroids (3D, R invalid input: '<' 1 clustered, R = 1 random, R > 1 regular, without an edge correction). The nearest surface points are connected with lines in the 3D view.
      Parameters:
      showTable - true displays the results in new sheets of the Bio7 table
      Returns:
      {nearest[n][DISTANCE_COLUMNS], centroid matrix[n][n] (null for more than 500 objects), surface matrix[n][n] (null for more than 150 objects)} or null if no surface is available
    • measureDistances

      public double[][][] measureDistances(boolean showTable, org.eclipse.core.runtime.IProgressMonitor monitor)
      Measures the distances (see measureDistances(boolean)) with the progress of the steps (the objects, the centroid and the surface distances, the tables).
      Parameters:
      monitor - the progress or null
      Returns:
      the distances or null if no surface is available or the measurement was canceled
    • setMatrixFolder

      public void setMatrixFolder(File folder)
      Saves all centroid and surface distance matrices of the next measurements of the distances as CSV files in the folder (for any number of objects, the tables show the matrices for up to MAX_CENTROID_MATRIX and MAX_SURFACE_MATRIX objects).
      Parameters:
      folder - the folder or null for no files
    • getMatrixFiles

      public List<File> getMatrixFiles()
      The CSV files of the matrices of the last measurement of the distances (see setMatrixFolder).
    • clear

      public void clear()
      Clears the measurements in the 3D view: the colors, numbers and selection of the objects and the picked points (the sheets of the table are kept).
    • clearObjects

      public void clearObjects()
      Removes the highlight of the measured objects.
    • getSettings

      public String getSettings()
      Returns the settings of the measured iso surface (the iso value, the smoothing, the mesh smoothing, the resolution and the object sizes), which are also shown in the last row of the table of the objects.
      Returns:
      the settings as text or null if no surface is available
    • pick

      public boolean pick(double[] start, double[] end)
      Picks the first visible point of the iso surface (or of the volume) along a ray like the mouse (the ruler, see getPoints), e.g., in a script.
      Parameters:
      start - the start of the ray (relative positions 0 - 1 of the data, y = 0 is the first row)
      end - the end of the ray
      Returns:
      true if a point has been added
    • measureRegion

      public double[] measureRegion(boolean showTable)
      Measures the voxels of the displayed stack (the full resolution of the ImageJ image or the data of a model) in the region of the clipping (the box, the cutting plane and the mask, the whole stack without a clipping). The threshold is the iso value (if an iso surface of the data is available) or the threshold of the image (else NaN). The values of an RGB stack are the luminance 0.299 R + 0.587 G + 0.114 B (like the iso surface), the values of a 64-bit stack are read in double.
      Parameters:
      showTable - true displays the results in a new sheet of the Bio7 table
      Returns:
      the values of REGION_COLUMNS or null if no data is available
    • deleteSelected

      public void deleteSelected(boolean whole)
      Deletes the active point of the selected measurement (the last pressed or added point) or, if whole is true, the selected measurement. A line, a polygon or a freehand area with too few points (a straight line, an angle) is deleted. The measurement is measured again and the tables are updated.
      Parameters:
      whole - true deletes the selected measurement
    • getEraserRadius

      public double getEraserRadius()
      Returns the radius of the surface eraser (points of the screen).
    • setEraserRadius

      public void setEraserRadius(double radius)
      Sets the radius of the surface eraser (points of the screen, 1 - 200).
    • removeAreaSurface

      public boolean removeAreaSurface()
      Removes the surface of the selected area (else of the last measured area with a surface: a polygon, a freehand area, an object or a cavity) from the displayed iso surface: the surface is cut open (e.g., to measure inside of an object). The removed parts are kept when the surface is computed again; see IsoSurface.undoRemoval, redoRemoval and restoreSurface. The measurement of the objects uses the complete surface.
      Returns:
      true if a part of the surface has been removed
    • getAreas

      public List<double[]> getAreas()
      Returns the measured areas and volumes of the mouse tools (polygon, freehand, volume): the values of AREA_COLUMNS (the type is one of AREA_POLYGON, AREA_FREEHAND, AREA_OUTLINE, AREA_OBJECT; NaN if not available).
      Returns:
      a copy of the rows
    • setPreviewTextListener

      public static void setPreviewTextListener(Consumer<String> listener)
      Receives the description of what a click of the volume tool measures (the surface under the mouse) or an empty text (not in the UI thread).
    • setShowVolumeTriangles

      public void setShowVolumeTriangles(boolean show)
      Draws the measured volumes as triangles (a wireframe on a fainter fill).
    • isShowVolumeTriangles

      public boolean isShowVolumeTriangles()
      Returns true if the measured volumes are drawn as triangles.
    • getPointTypes

      public List<String> getPointTypes()
      Returns the types of the picked points (like the column "Type" of the table "3D Points": "Segmented Line", "Point", "Straight Line", "Angle", a line which follows the surface with "(Surface)").
    • isFollowSurface

      public boolean isFollowSurface()
      Returns true if the lines follow the surface (see setFollowSurface).
    • setFollowSurface

      public void setFollowSurface(boolean follow)
      Sets if the next segments of the segmented and the straight lines follow the surface (the path on the visible surface along the screen line between the points, measured along the surface) or are straight lines in 3D (the default).
    • isFitSpline

      public boolean isFitSpline()
      Returns true if the lines and areas are fitted with a spline (see setFitSpline).
    • setFitSpline

      public void setFitSpline(boolean spline)
      Sets if the next segmented lines, polygons and freehand areas are fitted with a spline (a centripetal Catmull-Rom spline through the points, like "Fit Spline" of ImageJ): the length, the perimeter and the areas are measured along the spline. A selected line or area (see the handles of the mouse tools) is changed and measured again.
    • getPoints

      public List<double[]> getPoints()
      Returns the picked points (calibrated x, y, z, the value, the distance to the previous point and the length of the path, see POINT_COLUMNS).
    • clearPoints

      public void clearPoints()
      Removes the picked points and the measured areas (new sheets are created for the next measurements).
    • render

      public void render(com.jogamp.opengl.GL2 gl, double[] bounds, boolean flip, boolean cartesian, float pixelScale)
      Draws the picked points and the lines between them (the scene coordinates of the current model view matrix).
    • setShowNumbers

      public void setShowNumbers(boolean show)
      Shows the numbers of the measurements in the 3D view: the row of an area in the table "3D Areas" (green) and the row of a point in the table "3D Points" (blue; for a line or an angle the row of its last point with the length or the angle). The number of the selected measurement is yellow.
      Parameters:
      show - true to show the numbers
    • setCavityFreeSpace

      public void setCavityFreeSpace(boolean freeSpace)
      The volume of a clicked cavity (its wall): true without the objects which float in it (the free space), false the whole space inside of the wall.
    • isCavityFreeSpace

      public boolean isCavityFreeSpace()
      Returns true if the volume of a clicked cavity is its free space (see setCavityFreeSpace).
    • setObjectFilled

      public void setObjectFilled(boolean filled)
      The volume of a clicked object: true the filled volume (inside of its outer surface, with its cavities), false the volume of its material (the outer surface without the cavities).
    • isObjectFilled

      public boolean isObjectFilled()
      Returns true if the volume of a clicked object is its filled volume (see setObjectFilled).
    • setShowVolumesThrough

      public void setShowVolumesThrough(boolean show)
      Shows the measured volumes (objects, cavities, outlines) as transparent bodies through the surface, e.g., a cavity inside of the object.
    • isShowVolumesThrough

      public boolean isShowVolumesThrough()
      Returns true if the measured volumes are shown through the surface.
    • setShowOnlyVolumes

      public void setShowOnlyVolumes(boolean only)
      Shows only the measured volumes: the iso surface is hidden (its data and the measurements stay; the mouse tools still measure on it).
    • isShowOnlyVolumes

      public boolean isShowOnlyVolumes()
      Returns true if only the measured volumes are shown (the iso surface is hidden).
    • isShowNumbers

      public boolean isShowNumbers()
      Returns true if the numbers of the measurements are shown (see setShowNumbers).
    • setDecimals

      public void setDecimals(int digits)
      Sets the number of decimals of the values in the tables and in the CSV files of the matrices (default 4). -1 shows the full precision: the shortest decimal number which gives the same double value when it is read (no rounding).
      Parameters:
      digits - the decimals (0 - 15) or -1 for the full precision
    • getDecimals

      public int getDecimals()
      Returns the decimals of the tables (see setDecimals, -1 = full precision).
    • formatValue

      public static String formatValue(double v)
      Formats a value like the tables of the measurements (see setDecimals).
      Parameters:
      v - the value
      Returns:
      the text