Class CellGrid

java.lang.Object
net.imglib2.img.cell.CellGrid

public class CellGrid extends Object
Defines AbstractCellImg geometry and translates between image, cell, and grid coordinates.
Author:
Tobias Pietzsch
  • Constructor Summary

    Constructors
    Constructor
    Description
    CellGrid(long[] dimensions, int[] cellDimensions)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the number of pixels in a standard cell in a given dimension d.
    void
    cellDimensions(int[] dimensions)
    Write the number of pixels in a standard cell in each dimension into long[].
    boolean
     
    void
    getCellDimensions(long[] cellGridPosition, long[] cellMin, int[] 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, int[] 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
    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[]
     
    long[]
    Get the number of pixels in each dimension as a new long[].
    long
     
    void
    gridDimensions(long[] s)
     
    int
     
    long
    imgDimension(int d)
    Get the number of pixels in a given dimension d.
    void
    imgDimensions(long[] dimensions)
    Write the number of pixels in each dimension into long[].
    int
     
     

    Methods inherited from class java.lang.Object

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

    • CellGrid

      public CellGrid(long[] dimensions, int[] cellDimensions)
    • CellGrid

      public CellGrid(CellGrid grid)
  • Method Details

    • numDimensions

      public int numDimensions()
    • getGridDimensions

      public long[] getGridDimensions()
    • gridDimensions

      public void gridDimensions(long[] s)
    • gridDimension

      public long gridDimension(int 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 long[]. Note, that this is the number of pixels in all cells combined, not the number of cells!
      Parameters:
      dimensions -
    • imgDimension

      public long imgDimension(int d)
      Get the number of pixels in a given dimension d. Note, that this is the number of pixels in all cells combined, not the number of cells!
      Parameters:
      d -
    • cellDimensions

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

      public int cellDimension(int d)
      Get the number of pixels in a standard cell in a given dimension d. Cells on the max border of the image may be cut off and have different dimensions.
      Parameters:
      d -
    • getCellDimensions

      public void getCellDimensions(long index, long[] cellMin, int[] 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[], int[]).

      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, int[] 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.
    • 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