java.lang.Object
imagingbook.common.image.access.ImageAccessor
imagingbook.common.image.access.ScalarAccessor
- Direct Known Subclasses:
ByteAccessor,FloatAccessor,ShortAccessor
The common (abstract) super-class for all image accessors to scalar-valued images. It inherits all methods from
ImageAccessor but adds the methods getVal(int, int), getVal(double, double) and
setVal(int, int, float) for reading and writing scalar-valued pixel data.-
Field Summary
Fields inherited from class imagingbook.common.image.access.ImageAccessor
DefaultInterpolationMethod, DefaultOutOfBoundsStrategy, defaultValue, height, indexer, interpolationMethod, ip, outOfBoundsStrategy, width -
Method Summary
Modifier and TypeMethodDescriptionstatic ScalarAccessorcreate(ImageProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) Creates a new image accessor of general typeScalarAccessor.getComponentAccessor(int k) Returns theImageAccessorfor the k-th component; the result is a sub-type ofScalarAccessor.intgetDepth()Returns the depth (number of components) of this image accessor. 1 is returned if the image is scalar-valued.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).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).floatgetVal(double x, double y) Reads and returns the interpolated scalar pixel value for the given image position.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) Reads and returns the scalar pixel value for the given image position.floatgetVal(int u, int v, int k) Returns the value of the pixel's k-th component at the specified position.voidsetPix(int u, int v, float[] pix) Sets the pixel value at the specified integer position.abstract voidsetVal(int u, int v, float val) Writes a scalar pixel value to the given image position.voidsetVal(int u, int v, int k, float val) Sets the value of the pixel's k-th component at the specified position.Methods inherited from class imagingbook.common.image.access.ImageAccessor
create, getHeight, getInterpolationMethod, getOutOfBoundsStrategy, getProcessor, getWidth
-
Method Details
-
create
public static ScalarAccessor create(ImageProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) Creates a new image accessor of general typeScalarAccessor. The concrete type of the returned instance depends on the specified image, i.e.,ByteAccessorforByteProcessor,ShortAccessorforShortProcessor,FloatAccessorforFloatProcessor. An exception is thrown if the supplied image is not scalar-valued (i.e., a color image).- Parameters:
ip- the image to be accessedobs- the out-of-bounds strategy to be used (usenullfor default settings)ipm- the interpolation method to be used (usenullfor default settings)- Returns:
- a new image accessor
-
getDepth
Description copied from class:ImageAccessorReturns the depth (number of components) of this image accessor. 1 is returned if the image is scalar-valued.- Specified by:
getDepthin classImageAccessor- Returns:
- the image depth.
-
getComponentAccessor
Description copied from class:ImageAccessorReturns theImageAccessorfor the k-th component; the result is a sub-type ofScalarAccessor. In the case of a scalar-valued image, THIS object is returned.- Specified by:
getComponentAccessorin classImageAccessor- Parameters:
k- the component index- Returns:
- the component accessor.
-
getVal
Reads and returns the scalar pixel value for the given image position. The value returned for coordinates outside the image boundaries depends on theOutOfBoundsStrategyspecified for thisImageAccessor.- Parameters:
u- the x-coordinatev- the y-coordinate- Returns:
- the pixel value (
float)
-
getVal
Description copied from class:ImageAccessorReturns 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 alsoImageAccessor.getDepth().- Specified by:
getValin classImageAccessor- Parameters:
u- the x-coordinatev- the y-coordinatek- the component index- Returns:
- the component value (
float)
-
getVal
Description copied from class:ImageAccessorReturns 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 alsoImageAccessor.getDepth().- Specified by:
getValin classImageAccessor- Parameters:
x- the x-coordinatey- the y-coordinatek- the component index- Returns:
- the interpolated component value (
float[])
-
getVal
Reads and returns the interpolated scalar pixel value for the given image position. The value returned for coordinates outside the image boundaries depends on theOutOfBoundsStrategyspecified for thisImageAccessor.- Parameters:
x- the x-coordinatey- the y-coordinate- Returns:
- the pixel value (
float)
-
setVal
Writes a scalar pixel value to the given image position. An exception is thrown if u, v coordinates are outside the image.- Parameters:
u- the x-coordinatev- the y-coordinateval- the new pixel value (float)
-
setVal
Description copied from class:ImageAccessorSets 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 alsoImageAccessor.getDepth().- Specified by:
setValin classImageAccessor- Parameters:
u- the x-coordinatev- the y-coordinatek- the component indexval- the new component value
-
getPix
Description copied from class:ImageAccessorReturns 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).- Specified by:
getPixin classImageAccessor- Parameters:
u- the x-coordinatev- the y-coordinate- Returns:
- the pixel value (
float[])
-
getPix
Description copied from class:ImageAccessorReturns 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.- Specified by:
getPixin classImageAccessor- Parameters:
x- the x-coordinatey- the y-coordinate- Returns:
- the interpolated pixel value (
float[])
-
setPix
Description copied from class:ImageAccessorSets 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.- Specified by:
setPixin classImageAccessor- Parameters:
u- the x-coordinatev- the y-coordinatepix- the new pixel value (float[])
-