- Direct Known Subclasses:
ScalarAccessor,VectorAccessor
An 'image accessor' is a wrapper around some ImageProcessor object to allow unified (read and write) access
to its pixels values. This abstract class defines unified access functionality to all 4 types of images available in
ImageJ: 8-bit, 16-bit, float, and color images. All pixel values are of type float[], either containing a
single element (for scalar-valued images) or three elements (for color images).
A generic ImageAccessor is created, e.g., by create(ImageProcessor), which returns an instance of
ByteAccessor, ShortAccessor, FloatAccessor or RgbAccessor. ImageAccessor
itself can access any ImageJ image using the methods getPix(int, int), getPix(double, double) for
retrieving pixel values and setPix(int, int, float[]) to modify pixel values.
In addition, the accessors for scalar-valued images (ByteAccessor, ShortAccessor,
FloatAccessor) provide the methods ScalarAccessor.getVal(int, int),
ScalarAccessor.getVal(double, double) and ScalarAccessor.setVal(int, int, float) to read and write
scalar-valued pixels passed as single float values.
The methods getPix(double, double) and
ScalarAccessor.getVal(double, double) perform interpolation at non-integer coordinates using the specified
InterpolationMethod.
A related concept for providing unified access to images is PixelPack, which copies all pixel data to
internal float arrays. In contrast to PixelPack, ImageAccessor does not duplicate any data
but reads and writes the original ImageProcessor pixel data directly.
- Version:
- 2020/12/27
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final InterpolationMethodThe default pixel interpolation method (seeInterpolationMethod).static final OutOfBoundsStrategyThe default out-of-bounds strategy (seeOutOfBoundsStrategy).protected final floatprotected final intprotected final GridIndexer2Dprotected final InterpolationMethodprotected final ImageProcessorprotected final OutOfBoundsStrategyprotected final int -
Method Summary
Modifier and TypeMethodDescriptionstatic final ImageAccessorcreate(ImageProcessor ip) Creates a newImageAccessorinstance for the given image, using the default out-of-bounds strategy and interpolation method.static ImageAccessorcreate(ImageProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) Creates a newImageAccessorinstance for the given image, using the specified out-of-bounds strategy and interpolation method.abstract ScalarAccessorgetComponentAccessor(int k) Returns theImageAccessorfor the k-th component; the result is a sub-type ofScalarAccessor.abstract intgetDepth()Returns the depth (number of components) of this image accessor. 1 is returned if the image is scalar-valued.intReturns the height of the associated image.Returns theInterpolationMethodspecified for thisImageAccessor.Returns theOutOfBoundsStrategyspecified for thisImageAccessor.abstract float[]getPix(double x, double y) Returns the interpolated pixel value for the specified continuous position as afloat[]with either 1 element for scalar-valued images and or more elements (e.g., 3 for for RGB images).abstract float[]getPix(int u, int v) Returns the pixel value for the specified integer position as afloat[]with either 1 element for scalar-valued images and or more elements (e.g., 3 for for RGB images).Returns the sourceImageProcessorassociated with thisImageAccessor.abstract floatgetVal(double x, double y, int k) Returns the interpolated value of the pixel's k-th component at the specified position.abstract floatgetVal(int u, int v, int k) Returns the value of the pixel's k-th component at the specified position.intgetWidth()Returns the width of the associated image.abstract voidsetPix(int u, int v, float[] val) Sets the pixel value at the specified integer position.abstract voidsetVal(int u, int v, int k, float val) Sets the value of the pixel's k-th component at the specified position.
-
Field Details
-
DefaultOutOfBoundsStrategy
The default out-of-bounds strategy (seeOutOfBoundsStrategy). -
DefaultInterpolationMethod
The default pixel interpolation method (seeInterpolationMethod). -
defaultValue
- See Also:
-
ip
-
width
-
height
-
indexer
-
outOfBoundsStrategy
-
interpolationMethod
-
-
Method Details
-
create
Creates a newImageAccessorinstance for the given image, using the default out-of-bounds strategy and interpolation method. The concrete type of the returned instance depends on the specified image.- Parameters:
ip- the source image- Returns:
- a new
ImageAccessorinstance
-
create
public static ImageAccessor create(ImageProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) Creates a newImageAccessorinstance for the given image, using the specified out-of-bounds strategy and interpolation method. The concrete type of the returned instance depends on the specified image.- Parameters:
ip- the source imageobs- the out-of-bounds strategy (usenullfor default settings)ipm- the interpolation method (usenullfor default settings)- Returns:
- a new
ImageAccessorinstance
-
getWidth
Returns the width of the associated image.- Returns:
- the image width.
-
getHeight
Returns the height of the associated image.- Returns:
- the image height.
-
getProcessor
Returns the sourceImageProcessorassociated with thisImageAccessor.- Returns:
- the image processor
-
getDepth
Returns the depth (number of components) of this image accessor. 1 is returned if the image is scalar-valued.- Returns:
- the image depth.
-
getOutOfBoundsStrategy
Returns theOutOfBoundsStrategyspecified for thisImageAccessor.- Returns:
- the out-of-bounds strategy
-
getInterpolationMethod
Returns theInterpolationMethodspecified for thisImageAccessor.- Returns:
- the interpolation method
-
getPix
Returns the pixel value for the specified integer position as afloat[]with either 1 element for scalar-valued images and or more elements (e.g., 3 for for RGB images).- Parameters:
u- the x-coordinatev- the y-coordinate- Returns:
- the pixel value (
float[])
-
getPix
Returns the interpolated pixel value for the specified continuous position as afloat[]with either 1 element for scalar-valued images and or more elements (e.g., 3 for for RGB images). Interpolation is used non-integer coordinates.- Parameters:
x- the x-coordinatey- the y-coordinate- Returns:
- the interpolated pixel value (
float[])
-
setPix
Sets the pixel value at the specified integer position. The new value must be provided asfloat[]with 1 element for scalar-valued images or 3 elements for RGB images.- Parameters:
u- the x-coordinatev- the y-coordinateval- the new pixel value (float[])
-
getVal
Returns the value of the pixel's k-th component at the specified position. If the associated image is scalar-valued, this is equivalent to component 0. See alsogetDepth().- Parameters:
u- the x-coordinatev- the y-coordinatek- the component index- Returns:
- the component value (
float)
-
getVal
Returns the interpolated value of the pixel's k-th component at the specified position. If the associated image is scalar-valued, this is equivalent to component 0. See alsogetDepth().- Parameters:
x- the x-coordinatey- the y-coordinatek- the component index- Returns:
- the interpolated component value (
float[])
-
setVal
Sets the value of the pixel's k-th component at the specified position. If the associated image is scalar-valued, this is equivalent to component 0. See alsogetDepth().- Parameters:
u- the x-coordinatev- the y-coordinatek- the component indexval- the new component value
-
getComponentAccessor
Returns theImageAccessorfor the k-th component; the result is a sub-type ofScalarAccessor. In the case of a scalar-valued image, THIS object is returned.- Parameters:
k- the component index- Returns:
- the component accessor.
-