Class PointFunctions

java.lang.Object
jhd.PointFunctions.PointFunctions

public class PointFunctions
extends java.lang.Object
Experimental Class for Point probability functions
Author:
John
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    class  PointFunctions.Histogram
    Class for holding histogram bin andvalue data
    class  PointFunctions.Point3D
    A structure describing a 3D pixel
  • Constructor Summary

    Constructors
    Constructor Description
    PointFunctions()  
  • Method Summary

    Modifier and Type Method Description
    PointFunctions.Point3D[] bresenhamLine​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D start, PointFunctions.Point3D end)
    Gets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image
    PointFunctions.Point3D[] bresenhamLine​(PointFunctions.Point3D startPoint, PointFunctions.Point3D endPoint)
    Gets the coordinates along a Bresenham line between p1 and p2
    PointFunctions.Histogram chordLengthDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
    Computes the chord length distribution as a probability density,
    i .e . the likelihood of finding a chord in the interval between L +/- dL in image units This code measures the length of chords through the selected component along
    a random line of length = (min image dimension)/2.
    PointFunctions.Histogram chordLengthDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
    Computes the chord length distribution as a probability density,
    i .e . the likelihood of finding a chord in the interval between L and dL in pixels or voxels This code measures the length of chords through the selected component along
    a random line of length = (min image dimension)/2.
    float[] getChords​(PointFunctions.Point3D[] theLine, java.lang.String valChoice, double pixelWidth, double pixelHeight, double pixelDepth)
    Returns an array containing the length of chords along a line through the selected component.
    void getLineValues​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D[] line)
    Gets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image and adds them to the Point3D val parameter.
    int getMaxPixelSeparationDistance​(int imgWidth, int imgHeight, int imgDepth)
    Returns the smallest image dimension divided by 2
    double getMaxProbeSize​(int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth)
    The probe box is a cube in the image's physical dimensions, not pixel dimensions.
    void initRandom()
    Required call, initializes the random generator using a seed drawn from the last 4 digits of the millisecond system clock.
    PointFunctions.Histogram linealPathDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
    Find the probability that a random line of length R in image units will lie completely in the chosen image space.
    PointFunctions.Histogram linealPathDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
    Find the probability that a random line of length R in pixels will lie completely in the chosen image space.
    PointFunctions.Histogram poreSizeDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double probeDim, double pixelWidth, double pixelHeight, double pixelDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
    Experimental: Estimates the pore size distribution as a probability density using local measurements of the surface-to-volume ratio and computing the radius of an equivalent sphere.
    void randomPointPair​(int imgWidth, int imgHeight, int imgDepth, double xScale, double yScale, double zScale, double sepDist, PointFunctions.Point3D p1, PointFunctions.Point3D p2)
    Function to return a random point p1 within a 2D or 3D space and a second random point p2 separated by sepDist in image units
    The scale factor for the smallest pixel dimension should be 1 and the others are relative to it.
    e .g . pixelWidth = 10um, pixelHeight=20um and pixelDepth = 30um, xScale = 1, yScale=2, zScale=3
    The pixel units must be the same.
    void randomPointPair​(int imgWidth, int imgHeight, int imgDepth, double sepDist, PointFunctions.Point3D p1, PointFunctions.Point3D p2)
    Function to return a random point p1 within a 2D or 3D space and a second random point p2 separated by sepDist in pixels
    void setLine​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D p1, PointFunctions.Point3D p2, double val)
    Sets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image
    PointFunctions.Histogram twoPointFunction​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
    Find the probability that two points separated by a distance D will both lie in the selected image space.
    double vectorLength​(PointFunctions.Point3D p1, PointFunctions.Point3D p2, double pixelWidth, double pixelHeight, double pixelDepth)
    Get the length of the vector p1-p2 in image units

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PointFunctions

      public PointFunctions()
  • Method Details

    • initRandom

      public void initRandom()
      Required call, initializes the random generator using a seed drawn from the last 4 digits of the millisecond system clock.
    • bresenhamLine

      public PointFunctions.Point3D[] bresenhamLine​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D start, PointFunctions.Point3D end)
      Gets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image
      Parameters:
      image - the image data as an array of 2D slices. Pass z=0 for a 2D image.
      imgWidth - The width of the image in pixels
      imgHeight - The height of the image in pixels
      imgDepth - The depth of the image in pixels
      start - A Point3D descriptor of the x,y,z point start of the line
      end - A Point3D descriptor of the x,y,z point end of the line
      Returns:
      A Point3D Array containing the pixel coordinates and nearest neighbor values along the line
    • bresenhamLine

      public PointFunctions.Point3D[] bresenhamLine​(PointFunctions.Point3D startPoint, PointFunctions.Point3D endPoint)
      Gets the coordinates along a Bresenham line between p1 and p2
      Parameters:
      startPoint - A Point3D descriptor of the x,y,z point start of the line
      endPoint - A Point3D descriptor of the x,y,z point end of the line
      Returns:
      A Point3D Array containing the pixel coordinates along the line
    • chordLengthDistribution

      public PointFunctions.Histogram chordLengthDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
      Computes the chord length distribution as a probability density,
      i .e . the likelihood of finding a chord in the interval between L +/- dL in image units This code measures the length of chords through the selected component along
      a random line of length = (min image dimension)/2. The chord collection is then binned by length.
      Anisotropic pixels and voxels are supported.
      Parameters:
      image - 1D Reference to a binarized 3D short image
      imgWidth - The image width in pixels
      imgHeight - The height width in pixels
      imgDepth - The depth width in pixels
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.)
      nBins - The number of bins in the histogram
      nSamples - The number of samples for each line length
      valChoice - use "Map 0" to measure the zero component and "Map !0" for the non-zero component
      showProgress - true to display a progress bar
      Returns:
      Reference to a histogram of length (in user units ) vs length
    • chordLengthDistribution

      public PointFunctions.Histogram chordLengthDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
      Computes the chord length distribution as a probability density,
      i .e . the likelihood of finding a chord in the interval between L and dL in pixels or voxels This code measures the length of chords through the selected component along
      a random line of length = (min image dimension)/2. The chord collection is then binned by length.
      Parameters:
      image - 1D Reference to a binarized 3D short image
      imgWidth - The image width in pixels
      imgHeight - The height width in pixels
      imgDepth - The depth width in pixels
      nBins - The number of bins in the histogram
      nSamples - The number of samples for each line length
      valChoice - use "Map 0" to measure the zero component and "Map !0" for the non-zero component
      showProgress - true to display a progress bar
      Returns:
      Reference to a histogram of length (in pixels) vs length
    • getLineValues

      public void getLineValues​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D[] line)
      Gets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image and adds them to the Point3D val parameter.
      Parameters:
      image - the image data as an array of 2D slices. Pass z=0 for a 2D image.
      imgWidth - The width of the image in pixels
      imgHeight - The height of the image in pixels
      imgDepth - The depth of the image in pixels
      line - A Point3D descriptor of the x,y,z points of the line
    • getMaxProbeSize

      public double getMaxProbeSize​(int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth)
      The probe box is a cube in the image's physical dimensions, not pixel dimensions.
      The probe box must be small enough to allow many samples each image dimension,
      and larger than the typical pore size.
      Parameters:
      imgWidth - The image width in pixels
      imgHeight - The height width in pixels
      imgDepth - The depth width in pixels
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.)
      Returns:
      One fourth of the smallest image physical dimension
    • getMaxPixelSeparationDistance

      public int getMaxPixelSeparationDistance​(int imgWidth, int imgHeight, int imgDepth)
      Returns the smallest image dimension divided by 2
      Parameters:
      imgWidth - the image width
      imgHeight - the image height
      imgDepth - the image depth
      Returns:
      The smallest image dimension divided by 2
      For 2D images (imgDepth=1) only width and imgHeight are compared.
    • linealPathDistribution

      public PointFunctions.Histogram linealPathDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
      Find the probability that a random line of length R in image units will lie completely in the chosen image space. Note 1. Distances are scanned in integer pixel steps. Note 2. The longest distance sampled is half the smallest image dimension.
      Parameters:
      image - A reference to an 2D or 3D image segmented into zero and non-zero value regions
      imgWidth - The image width in pixels
      imgHeight - The image height in pixels
      imgDepth - The image depth in pixels, pass 1 for 2D images.
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.), ignored for 2D images
      nSamples - The number of samples at each distance step. More samples = less noise
      valChoice - "Map 0" or "Map !0".
      showProgress - Display progress Bar while running
      Returns:
      Reference to a Histogram of probability vs length in image units.
    • linealPathDistribution

      public PointFunctions.Histogram linealPathDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
      Find the probability that a random line of length R in pixels will lie completely in the chosen image space.
      Parameters:
      image - 1D Reference to a binarized 2D short image
      imgWidth - The image width in pixels
      imgHeight - The height width in pixels
      imgDepth - The depth in pixels, pass 1 for 2D images.
      nSamples - The number of samples for each line length
      valChoice - "Map 0" or "Map 255": Note that the ImageJ 255 short value = -1
      showProgress - Display progress Bar while running
      Returns:
      Reference to a histogram of length (in pixels) vs probability
    • poreSizeDistribution

      public PointFunctions.Histogram poreSizeDistribution​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double probeDim, double pixelWidth, double pixelHeight, double pixelDepth, int nBins, int nSamples, java.lang.String valChoice, boolean showProgress)
      Experimental: Estimates the pore size distribution as a probability density using local measurements of the surface-to-volume ratio and computing the radius of an equivalent sphere.
      i .e . the likelihood of finding a pore of radius R in the interval between R +/- dR in image units.
      This code measures the surface and volume the selected component within a randomly located cube of maximum length = (min image dimension)/2. the actual size of the cube is selected by the user. And should be larger than a typical pore. The pore collection is then binned by radius. Anisotropic pixels and voxels are supported.
      Parameters:
      image - 1D Reference to a binarized 2D short image
      imgWidth - The image width in pixels
      imgHeight - The height width in pixels
      imgDepth - The depth width in pixels
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.)
      probeDim - the edge dimension of the probe cube in image units, should be slightly larger than typical pore
      nBins - The number of bins in the histogram
      nSamples - The number of samples for each line length
      valChoice - "Map 0" or "Map !0"
      showProgress - Display progress Bar while running
      Returns:
      Reference to a histogram of estimated pore radius (in pixels) vs count
    • randomPointPair

      public void randomPointPair​(int imgWidth, int imgHeight, int imgDepth, double xScale, double yScale, double zScale, double sepDist, PointFunctions.Point3D p1, PointFunctions.Point3D p2)
      Function to return a random point p1 within a 2D or 3D space and a second random point p2 separated by sepDist in image units
      The scale factor for the smallest pixel dimension should be 1 and the others are relative to it.
      e .g . pixelWidth = 10um, pixelHeight=20um and pixelDepth = 30um, xScale = 1, yScale=2, zScale=3
      The pixel units must be the same.
      Use getVoxelValue to obtain the Point3D.val at the Point3D coordinates in an image.
      Parameters:
      imgWidth - The width of the space in pixels
      imgHeight - The height of the space in pixels
      imgDepth - The depth of the space in pixels. Pass 1 for 2D spaces
      sepDist - The desired distance of p2 from p1
      xScale - the relative length in the x direction
      yScale - the relative length in the y direction
      zScale - the relative length in the z direction
      p1 - Returns the first random pixel's coordinates
      p2 - Returns the second random pixel's coordinates
    • randomPointPair

      public void randomPointPair​(int imgWidth, int imgHeight, int imgDepth, double sepDist, PointFunctions.Point3D p1, PointFunctions.Point3D p2)
      Function to return a random point p1 within a 2D or 3D space and a second random point p2 separated by sepDist in pixels
      Parameters:
      imgWidth - The image imgWidth in pixels
      imgHeight - The height imgWidth in pixels
      imgDepth - The depth in pixels
      sepDist - The length of the line between p1 and p2
      p1 - Returns the first random pixel coordinates
      p2 - Returns the second random pixel coordinates
    • setLine

      public void setLine​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, PointFunctions.Point3D p1, PointFunctions.Point3D p2, double val)
      Sets the coordinates and voxel values along a Bresenham line between p1 and p2 in an image
      Parameters:
      image - the image data as an array of 2D slices. Pass z=0 for a 2D image.
      imgWidth - The width of the image in pixels
      imgHeight - The height of the image in pixels
      imgDepth - The depth of the image in pixels
      p1 - A Point3D descriptor of the x,y,z point start of the line
      p2 - A Point3D descriptor of the x,y,z point end of the line
      val - the new value for the pixels between P1 and p2
    • twoPointFunction

      public PointFunctions.Histogram twoPointFunction​(java.lang.Object[] image, int imgWidth, int imgHeight, int imgDepth, double pixelWidth, double pixelHeight, double pixelDepth, int nSamples, java.lang.String valChoice, boolean showProgress)
      Find the probability that two points separated by a distance D will both lie in the selected image space. Note 1. Distances are scanned in integer pixel steps. Note 2. The longest distance sampled is half the smallest image dimension.
      Parameters:
      image - A reference to an 2D or 3D image segmented into zero and non-zero value regions
      imgWidth - The image width in pixels
      imgHeight - The height in pixels
      imgDepth - The depth in pixels, pass 1 for 2D images.
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.), pass 1 for 2D images
      nSamples - The number of samples at each distance step. More samples = less noise
      valChoice - "Map 0" or "Map !0".
      showProgress - Display progress Bar while running
      Returns:
      Reference to a Histogram of probability vs length in image units.
    • vectorLength

      public double vectorLength​(PointFunctions.Point3D p1, PointFunctions.Point3D p2, double pixelWidth, double pixelHeight, double pixelDepth)
      Get the length of the vector p1-p2 in image units
      Parameters:
      p1 - A Point3D descriptor of the x,y,z point start of the line
      p2 - A Point3D descriptor of the x,y,z point end of the line
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.), ignored for 2D images
      Returns:
      The length of the vector p1-p2 in image Units
    • getChords

      public float[] getChords​(PointFunctions.Point3D[] theLine, java.lang.String valChoice, double pixelWidth, double pixelHeight, double pixelDepth)
      Returns an array containing the length of chords along a line through the selected component.
      Parameters:
      theLine - An array of Point3D descriptors of the line
      valChoice - "Map !0" get chords along the non-zero portions of line, "Map 0" get from zero component
      pixelWidth - the size of the voxel in the x, width, column, direction (e .g . cm , inch etc.)
      pixelHeight - the size of the voxel in the y, imgHeight, row, direction (e .g . cm , inch etc.)
      pixelDepth - the size of the voxel in the z, width, slice, direction (e .g . cm , inch etc.), ignored for 2D images
      Returns:
      an array of chord length along the line.