Class CellGrid


  • public class CellGrid
    extends java.lang.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)  
      CellGrid​(CellGrid grid)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int cellDimension​(int d)
      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 equals​(java.lang.Object obj)  
      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[] getGridDimensions()  
      long[] getImgDimensions()
      Get the number of pixels in each dimension as a new long[].
      long gridDimension​(int d)  
      void gridDimensions​(long[] s)  
      int hashCode()  
      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 numDimensions()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • CellGrid

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

        public CellGrid​(CellGrid grid)
    • Method Detail

      • 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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object