Package net.imglib2.img.cell
Class CellGrid
- java.lang.Object
-
- net.imglib2.img.cell.CellGrid
-
public class CellGrid extends java.lang.ObjectDefinesAbstractCellImggeometry and translates between image, cell, and grid coordinates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCellGrid.CellIntervalsprivate classCellGrid.CellIntervalsRA
-
Field Summary
Fields Modifier and Type Field Description private int[]borderSizeprivate int[]cellDimensionsprivate CellGrid.CellIntervalscellIntervalsprivate long[]dimensionsprivate inthashcodeprivate intnprivate long[]numCells
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcellDimension(int d)Get the number of pixels in a standard cell in dimensiond.voidcellDimensions(int[] dimensions)Write the number of pixels in a standard cell in each dimension into the provideddimensionsarray.CellGrid.CellIntervalscellIntervals()booleanequals(java.lang.Object obj)(package private) intgetCellCoordinates(long[] position, int[] cellSteps, long[] cellMin, long[] cellMax)Compute all cell-related coordinates/sizes required by CellRandomAccess.intgetCellDimension(int d, long cellGridPosition)From the position of a cell in the grid, compute the size of the cell in dimensiond.int[]getCellDimensions()Get the number of pixels in a standard cell in each dimension as a new int[].voidgetCellDimensions(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.voidgetCellDimensions(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.voidgetCellGridPositionFlat(long index, long[] cellGridPosition)From the flattened index of a cell in the grid, compute the position of a cell in the grid.voidgetCellInterval(long[] cellGridPosition, long[] cellMin, long[] cellMax)longgetCellMin(int d, long cellGridPosition)From the position of a cell in the grid, compute the image position in dimensiondof the first pixel of the cell (the offset of the cell in image coordinates).voidgetCellPosition(long[] position, long[] cellPos)Get the grid position of the cell containing the element atposition.voidgetCellPosition(long[] position, Positionable cellPos)Get the grid position of the cell containing the element atposition.long[]getGridDimensions()Get the number of cells in each dimension as a new long[].long[]getImgDimensions()Get the number of pixels in each dimension as a new long[].longgridDimension(int d)Get the number of cells in dimensiond.voidgridDimensions(long[] dimensions)Write the number of cells in each dimension into the provideddimensionsarray.inthashCode()longimgDimension(int d)Get the number of pixels in dimensiond.voidimgDimensions(long[] dimensions)Write the number of pixels in each dimension into the provideddimensionsarray.intnumDimensions()java.lang.StringtoString()
-
-
-
Field Detail
-
n
private final int n
-
dimensions
private final long[] dimensions
-
cellDimensions
private final int[] cellDimensions
-
numCells
private final long[] numCells
-
borderSize
private final int[] borderSize
-
hashcode
private final int hashcode
-
cellIntervals
private final CellGrid.CellIntervals cellIntervals
-
-
Constructor Detail
-
CellGrid
public CellGrid(long[] dimensions, int[] 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.
-
CellGrid
public CellGrid(CellGrid grid)
-
-
Method Detail
-
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 provideddimensionsarray.
-
gridDimension
public long gridDimension(int d)
Get the number of cells in dimensiond.
-
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 provideddimensionsarray. 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 dimensiond. Note, that this is the number of pixels in all cells combined, not the number of cells!
-
getCellDimensions
public int[] getCellDimensions()
Get the number of pixels in a standard cell in each dimension as a new int[]. Cells on the borders of the image may be cut off and have different dimensions.
-
cellDimensions
public void cellDimensions(int[] dimensions)
Write the number of pixels in a standard cell in each dimension into the provideddimensionsarray. Cells on the max border of the image may be cut off and have different dimensions.
-
cellDimension
public int cellDimension(int d)
Get the number of pixels in a standard cell in dimensiond. Cells on the max border of the image may be cut off and have different dimensions.
-
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 standardcellDimensionsunless 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 standardcellDimensionsunless 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 int getCellDimension(int d, long cellGridPosition)From the position of a cell in the grid, compute the size of the cell in dimensiond. The size will be the standardcellDimensionsunless the cell is at the border of the image in which case it might be truncated.- Parameters:
d- dimension indexcellGridPosition- grid coordinates of the cell in dimensiond.- 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 dimensiondof the first pixel of the cell (the offset of the cell in image coordinates).- Parameters:
d- dimension indexcellGridPosition- grid coordinates of the cell in dimensiond.- 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 atposition.- 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 atposition.- Parameters:
position- position of an element in the image.cellPos- is set to the grid position of the cell containing the element.
-
getCellCoordinates
int getCellCoordinates(long[] position, int[] cellSteps, long[] cellMin, long[] cellMax)Compute all cell-related coordinates/sizes required by CellRandomAccess.- Parameters:
position- current image positioncellSteps- allocation steps for cell are written here.cellMin- offset of the cell in image coordinates are written here.cellMax- is set to the max of the cell in image coordinates are written here.- Returns:
- index within the cell.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
cellIntervals
public CellGrid.CellIntervals cellIntervals()
-
-