Class SummedAreaTable

java.lang.Object
org.eclipse.dawnsci.analysis.dataset.impl.SummedAreaTable

public class SummedAreaTable extends Object
This code is based on: http://en.wikipedia.org/wiki/Summed_area_table This class can calculate the sum of a box region very fast compared to ROIProfile. Therefore for instance if calculating means of ROIs within a given plot, create a SummedAreaTable and do the calculation through that. I(x,y) = i(x,y) + I(x-1,y) + I(x,y-1) - I(x-1,y-1) getDouble(...) and set(Object, ...) On Dataset are slow. Therefore we have replaced these with absolute index.
  • Constructor Details

    • SummedAreaTable

      public SummedAreaTable(org.eclipse.january.dataset.Dataset image) throws Exception
      Calls SummedAreaTable(Image, false)
      Parameters:
      image -
      Throws:
      Exception
    • SummedAreaTable

      public SummedAreaTable(org.eclipse.january.dataset.Dataset image, boolean willRequireVariance) throws Exception
      Constructs the summed table.
      Parameters:
      image -
      willRequireVariance - set to true if you know that you need fano or variance
      Throws:
      Exception
  • Method Details

    • getFanoImage

      public org.eclipse.january.dataset.Dataset getFanoImage(int radius) throws Exception
      Creates a fano image where each pixel is the fano factor for a give box surrounding it. This operation has improved speed because it uses the summed area table to compute a fast mean and variance for a given square.
      Parameters:
      radius -
      Returns:
      fano factor image using box passed in.
      Throws:
      Exception
    • getFanoImage

      public org.eclipse.january.dataset.Dataset getFanoImage(int... box) throws Exception
      Creates a fano image where each pixel is the fano factor for a give box surrounding it. This operation has improved speed because it uses the summed area table to compute a fast mean and variance for a given box.
      Parameters:
      box -
      Returns:
      fano factor image using box passed in.
      Throws:
      Exception
    • getMeanImage

      public org.eclipse.january.dataset.Dataset getMeanImage(int radius) throws Exception
      Creates a mean image where each pixel is the mean for a give box surrounding it. This operation has improved speed because it uses the summed area table to compute a fast mean and variance for a given square.
      Parameters:
      radius -
      Returns:
      mean image using box passed in.
      Throws:
      Exception
    • getMeanImage

      public org.eclipse.january.dataset.Dataset getMeanImage(int... box) throws Exception
      Throws:
      Exception
    • getBoxSum

      public double getBoxSum(IRectangularROI box) throws Exception
      Give a point point, this will return the sum of a box around it. The box should really be an odd number such that the point is in the center
      Parameters:
      box -
      Returns:
      the sum of a box around point of shape box
      Throws:
      Exception
    • getBoxMean

      public double getBoxMean(IRectangularROI box) throws Exception
      Parameters:
      box -
      Returns:
      mean from the summed area table
      Throws:
      Exception
    • getBoxSum

      public double getBoxSum(int[] point, int... box) throws Exception
      Parameters:
      point -
      box -
      Returns:
      sum of box
      Throws:
      Exception
    • getBoxMean

      public double getBoxMean(int[] point, int... box) throws Exception
      Parameters:
      box -
      Returns:
      mean from the summed area table
      Throws:
      Exception
    • getBoxVariance

      public double getBoxVariance(IRectangularROI box) throws Exception
      Get the variance for a given box. (1/n)(S2 - S1^2/n) Where: S1 is sum of box ( D+A-B-C of sum ) S2 is sum^2 of box ( D+A-B-C of sum ) n is number of pixels box covers
      Parameters:
      box -
      Returns:
      variance
      Throws:
      Exception
    • getBoxVariance

      public double getBoxVariance(int[] point, int... box) throws Exception
      Get the variance for a given box. (1/n)(S2 - S1^2/n) Where: S1 is sum of box ( D+A-B-C of sum ) S2 is sum^2 of box ( D+A-B-C of sum2 ) n is number of pixels box covers
      Throws:
      Exception
    • getBoxFanoFactor

      public double getBoxFanoFactor(IRectangularROI box) throws Exception
      Get the variance for a given box. (1/n)(S2 - S1^2/n) Where: S1 is sum of box ( D+A-B-C of sum ) S2 is sum^2 of box ( D+A-B-C of sum ) n is number of pixels box covers
      Parameters:
      box -
      Returns:
      variance
      Throws:
      Exception
    • getBoxFanoFactor

      public double getBoxFanoFactor(int[] point, int... box) throws Exception
      Get the variance for a given box. (1/n)(S2 - S1^2/n) Where: S1 is sum of box ( D+A-B-C of sum ) S2 is sum^2 of box ( D+A-B-C of sum2 ) n is number of pixels box covers
      Throws:
      Exception
    • getShape

      public int[] getShape()
    • getDouble

      public double getDouble(int i, int j)