- Direct Known Subclasses:
GridIndexer2D.DefaultValueIndexer,GridIndexer2D.ExceptionIndexer,GridIndexer2D.MirrorImageIndexer,GridIndexer2D.NearestBorderIndexer,GridIndexer2D.PeriodicImageIndexer
Instances of this class perform the transformation between 2D image coordinates and indexes into the associated 1D
pixel array and vice versa. As usual images are assumed to be stored in row-major order. Instances of this class do
not hold any image data themselves, they just perform the indexing task. This is used, for example, by class
PixelPack, which provides a universal image data container which uses GridIndexer2D internally.
The (abstract) method getIndex(int, int) returns the 1D array index for a pair of 2D image coordinates. It
is implemented by the inner subclasses GridIndexer2D.DefaultValueIndexer, GridIndexer2D.MirrorImageIndexer and
GridIndexer2D.NearestBorderIndexer. They exhibit different behaviors when accessing out-of-image coordinates (see
OutOfBoundsStrategy).
- Version:
- 2022/09/17
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis indexer returns -1 for coordinates outside the image bounds, indicating that a (predefined) default pixel value should be used.static classThis indexer throws an exception if coordinates outside image bounds are accessed.static classThis indexer returns mirrored image values for coordinates outside the image bounds.static classThis indexer returns the closest border pixel for coordinates outside the image bounds.static classException to be thrown byGridIndexer2D.ExceptionIndexer.static classThis indexer returns repetitive image values for coordinates outside the image bounds. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic GridIndexer2Dcreate(int width, int height, OutOfBoundsStrategy obs) Creates and returns a newGridIndexer2Dwith the specified size andOutOfBoundsStrategy.static GridIndexer2Dcreate(ImageProcessor ip, OutOfBoundsStrategy obs) Creates and returns a newGridIndexer2Dfor the specified image andOutOfBoundsStrategy.intReturns the height of the associated image.abstract intgetIndex(int u, int v) Returns the 1D array index for a given pair of image coordinates.Returns the out-of-bounds strategy (see {qlink OutOfBoundsStrategy} used by this indexer.intgetWidth()Returns the width of the associated image.protected intgetWithinBoundsIndex(int u, int v) Returns the 1D array index for a given pair of image coordinates, assuming that the specified position is inside the image.
-
Field Details
-
DefaultOutOfBoundsStrategy
-
-
Method Details
-
create
Creates and returns a newGridIndexer2Dwith the specified size andOutOfBoundsStrategy.- Parameters:
width- grid size (horizontal)height- grid size (vertical)obs- out-of-bounds strategy- Returns:
- a new
GridIndexer2D
-
create
Creates and returns a newGridIndexer2Dfor the specified image andOutOfBoundsStrategy.- Parameters:
ip- the image to be associated with the returned indexerobs- out-of-bounds strategy- Returns:
- a new
GridIndexer2D
-
getIndex
Returns the 1D array index for a given pair of image coordinates. For u, v coordinates outside the image, the returned index depends on the implementing subclass ofGridIndexer2D. As a general rule, this method either returns a valid 1D array index or throws an exception. Subclasses implement (override) this method.- Parameters:
u- x-coordinatev- y-coordinate- Returns:
- 1D array index
-
getWithinBoundsIndex
Returns the 1D array index for a given pair of image coordinates, assuming that the specified position is inside the image.- Parameters:
u- x-coordinatev- y-coordinate- Returns:
- the associated 1D index
-
getWidth
Returns the width of the associated image.- Returns:
- the image width
-
getHeight
Returns the height of the associated image.- Returns:
- the image height
-
getOutOfBoundsStrategy
Returns the out-of-bounds strategy (see {qlink OutOfBoundsStrategy} used by this indexer.- Returns:
- the out-of-bounds strategy
-