Class Grid

java.lang.Object
net.imglib2.util.Grid

public class Grid extends Object
Defines a regular grid on an interval and translates between interval and grid coordinates.

In contrast to CellGrid, all coordinates are in long, and gridlines can be shifted such that cells at the min border are truncated.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
    private class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long[]
     
    private final Grid.CellIntervals
     
    private final long[]
     
    private final int
     
    private final long[]
     
    private final long[]
     
    private final int
     
    private final long[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Grid(long[] dimensions, long[] cellDimensions)
     
    Grid(long[] dimensions, long[] cellDimensions, long[] offset)
     
    Grid(Grid grid)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the number of pixels in a standard cell in dimension d.
    void
    cellDimensions(long[] dimensions)
    Write the number of pixels in a standard cell in each dimension into the provided dimensions array.
     
    boolean
     
    long
    getCellDimension(int d, long cellGridPosition)
    From the position of a cell in the grid, compute the size of the cell in dimension d.
    long[]
    Get the number of pixels in a standard cell in each dimension as a new long[].
    void
    getCellDimensions(long[] cellGridPosition, long[] cellMin, long[] cellDims)
    From the position of a cell in the grid, compute the image position of the first pixel of the cell (the offset of the cell in image coordinates) and the dimensions of the cell.
    void
    getCellDimensions(long index, long[] cellMin, long[] cellDims)
    From the index of a cell in the grid, compute the image position of the first pixel of the cell (the offset of the cell in image coordinates) and the dimensions of the cell.
    void
    getCellGridPositionFlat(long index, long[] cellGridPosition)
    From the flattened index of a cell in the grid, compute the position of a cell in the grid.
    void
    getCellInterval(long[] cellGridPosition, long[] cellMin, long[] cellMax)
     
    long
    getCellMin(int d, long cellGridPosition)
    From the position of a cell in the grid, compute the image position in dimension d of the first pixel of the cell (the offset of the cell in image coordinates).
    void
    getCellPosition(long[] position, long[] cellPos)
    Get the grid position of the cell containing the element at position.
    void
    getCellPosition(long[] position, Positionable cellPos)
    Get the grid position of the cell containing the element at position.
    long[]
    Get the number of cells in each dimension as a new long[].
    long[]
    Get the number of pixels in each dimension as a new long[].
    long
    Get the number of cells in dimension d.
    void
    gridDimensions(long[] dimensions)
    Write the number of cells in each dimension into the provided dimensions array.
    int
     
    long
    imgDimension(int d)
    Get the number of pixels in dimension d.
    void
    imgDimensions(long[] dimensions)
    Write the number of pixels in each dimension into the provided dimensions array.
    int
     
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • n

      private final int n
    • dimensions

      private final long[] dimensions
    • cellDimensions

      private final long[] cellDimensions
    • minBorderSize

      private final long[] minBorderSize
    • numCells

      private final long[] numCells
    • maxBorderSize

      private final long[] maxBorderSize
    • hashcode

      private final int hashcode
    • cellIntervals

      private final Grid.CellIntervals cellIntervals
  • Constructor Details

    • Grid

      public Grid(long[] dimensions, long[] cellDimensions)
      Parameters:
      dimensions - the dimensions of the image (in pixels, not in cells).
      cellDimensions - the dimensions of a standard cell (in pixels). Cells on the max border of the image may be cut off and have different dimensions.
    • Grid

      public Grid(long[] dimensions, long[] cellDimensions, long[] offset)
      Parameters:
      dimensions - the dimensions of the image (in pixels, not in cells).
      cellDimensions - the dimensions of a standard cell (in pixels). Cells on the borders of the image may be cut off and have different dimensions.
      offset - offset of the grid on the min border. Cell on the min border of the image will be cut off according to offset. For example, if cellDimensions={10,10} and offset={5,0} then the first cell will have dimensions {5,10} (assuming that dimensions is larger than {10,10}).
    • Grid

      public Grid(Grid grid)
  • Method Details

    • numDimensions

      public int numDimensions()
    • getGridDimensions

      public long[] getGridDimensions()
      Get the number of cells in each dimension as a new long[].
    • gridDimensions

      public void gridDimensions(long[] dimensions)
      Write the number of cells in each dimension into the provided dimensions array.
    • gridDimension

      public long gridDimension(int d)
      Get the number of cells in dimension d.
    • getImgDimensions

      public long[] getImgDimensions()
      Get the number of pixels in each dimension as a new long[]. Note, that this is the number of pixels in all cells combined, not the number of cells!
    • imgDimensions

      public void imgDimensions(long[] dimensions)
      Write the number of pixels in each dimension into the provided dimensions array. Note, that this is the number of pixels in all cells combined, not the number of cells!
    • imgDimension

      public long imgDimension(int d)
      Get the number of pixels in dimension d. Note, that this is the number of pixels in all cells combined, not the number of cells!
    • getCellDimensions

      public long[] getCellDimensions()
      Get the number of pixels in a standard cell in each dimension as a new long[]. Cells on the borders of the image may be cut off and have different dimensions.
    • cellDimensions

      public void cellDimensions(long[] dimensions)
      Write the number of pixels in a standard cell in each dimension into the provided dimensions array. Cells on the max borders of the image may be cut off and have different dimensions.
    • cellDimension

      public long cellDimension(int d)
      Get the number of pixels in a standard cell in dimension d. Cells on the borders of the image may be cut off and have different dimensions.
    • getCellDimensions

      public void getCellDimensions(long index, long[] cellMin, long[] cellDims)
      From the index of a cell in the grid, compute the image position of the first pixel of the cell (the offset of the cell in image coordinates) and the dimensions of the cell. The dimensions will be the standard cellDimensions unless the cell is at the border of the image in which case it might be truncated.

      Note, that this method assumes that the cell grid has flat iteration order. It this is not the case, use getCellDimensions(long[], long[], long[]).

      Parameters:
      index - flattened grid coordinates of the cell.
      cellMin - offset of the cell in image coordinates are written here.
      cellDims - dimensions of the cell are written here.
    • getCellDimensions

      public void getCellDimensions(long[] cellGridPosition, long[] cellMin, long[] cellDims)
      From the position of a cell in the grid, compute the image position of the first pixel of the cell (the offset of the cell in image coordinates) and the dimensions of the cell. The dimensions will be the standard cellDimensions unless the cell is at the border of the image in which case it might be truncated.
      Parameters:
      cellGridPosition - grid coordinates of the cell.
      cellMin - offset of the cell in image coordinates are written here.
      cellDims - dimensions of the cell are written here.
    • getCellInterval

      public void getCellInterval(long[] cellGridPosition, long[] cellMin, long[] cellMax)
    • getCellDimension

      public long getCellDimension(int d, long cellGridPosition)
      From the position of a cell in the grid, compute the size of the cell in dimension d. The size will be the standard cellDimensions unless the cell is at the border of the image in which case it might be truncated.
      Parameters:
      d - dimension index
      cellGridPosition - grid coordinates of the cell in dimension d.
      Returns:
      size of the cell in dimension d.
    • getCellMin

      public long getCellMin(int d, long cellGridPosition)
      From the position of a cell in the grid, compute the image position in dimension d of the first pixel of the cell (the offset of the cell in image coordinates).
      Parameters:
      d - dimension index
      cellGridPosition - grid coordinates of the cell in dimension d.
      Returns:
      offset of the cell in dimension d (in image coordinates).
    • getCellGridPositionFlat

      public void getCellGridPositionFlat(long index, long[] cellGridPosition)
      From the flattened index of a cell in the grid, compute the position of a cell in the grid.
      Parameters:
      index - flattened grid coordinates of the cell.
      cellGridPosition - grid coordinates of the cell are written here.
    • getCellPosition

      public void getCellPosition(long[] position, long[] cellPos)
      Get the grid position of the cell containing the element at position.
      Parameters:
      position - position of an element in the image.
      cellPos - is set to the grid position of the cell containing the element.
    • getCellPosition

      public void getCellPosition(long[] position, Positionable cellPos)
      Get the grid position of the cell containing the element at position.
      Parameters:
      position - position of an element in the image.
      cellPos - is set to the grid position of the cell containing the element.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • cellIntervals

      public Grid.CellIntervals cellIntervals()