java.lang.Object
imagingbook.common.image.PixelPack.PixelSlice
- Enclosing class:
- PixelPack
Inner class representing a single (scalar-valued) component of a (vector-valued)
PixelPack
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyTo
(PixelPack.PixelSlice other) Copies the contents of this pixel slice to another pixel slice.float[][]
get3x3Neighborhood
(int uc, int vc, float[][] nh) Returns the pixel values from the 3x3 neighborhood centered at the specified position.float[]
getArray()
Returns a reference to the data array associated with this pixel slice.Returns aFloatProcessor
for thisPixelPack.PixelSlice
sharing the internal pixel data (nothing is copied).Returns aFloatProcessor
for thisPixelPack.PixelSlice
by copying the internal pixel data.int
Returns the height of the associated image (see alsoGridIndexer2D
).int
getIndex()
Returns the slice index for this pixel slice, i.e, the component number in the containing pixel pack.int
Returns the length (number of pixels) of the associated 1D pixel array.float
getVal
(int u, int v) Returns the pixel value for the specified image position.int
getWidth()
Returns the width of the associated image (see alsoGridIndexer2D
).void
setVal
(int u, int v, float val) Sets the pixel value at the specified image position.void
zero()
Sets all pixel values to zero.
-
Method Details
-
getVal
Returns the pixel value for the specified image position.- Parameters:
u
- the x-positionv
- the y-position- Returns:
- the slice value
-
setVal
Sets the pixel value at the specified image position.- Parameters:
u
- the x-positionv
- the y-positionval
- the new value
-
getIndex
Returns the slice index for this pixel slice, i.e, the component number in the containing pixel pack. -1 is returned if the pixel slice is not associated with a pixel pack.- Returns:
- the slice index
-
getArray
Returns a reference to the data array associated with this pixel slice.- Returns:
- the data array
-
getFloatProcessor
Returns aFloatProcessor
for thisPixelPack.PixelSlice
sharing the internal pixel data (nothing is copied).- Returns:
- a
FloatProcessor
-
getFloatProcessorCopy
Returns aFloatProcessor
for thisPixelPack.PixelSlice
by copying the internal pixel data.- Returns:
- a
FloatProcessor
-
getLength
Returns the length (number of pixels) of the associated 1D pixel array.- Returns:
- the length of the image array
-
getWidth
Returns the width of the associated image (see alsoGridIndexer2D
).- Returns:
- the image width
-
getHeight
Returns the height of the associated image (see alsoGridIndexer2D
).- Returns:
- the image height
-
zero
Sets all pixel values to zero. -
copyTo
Copies the contents of this pixel slice to another pixel slice.- Parameters:
other
- the pixel slice to modified
-
get3x3Neighborhood
Returns the pixel values from the 3x3 neighborhood centered at the specified position. The 3x3 arraynh[x][y]
has the coordinates x = 0,..,2 and y = 0,..,2; the value at position[1][1]
belongs to the specified position. If a non-null array is supplied, it is filled and returned. If null, a new array is created and returned.- Parameters:
uc
- the center x-positionvc
- the center y-positionnh
- a 3x3 array or null- Returns:
- a 3x3 array of pixel values
-