Class ImageGray<T extends ImageGray<T>>
public abstract class ImageGray<T extends ImageGray<T>> extends ImageBase<T>
A base class for a single band intensity image. The image is an rectangular array where each pixel represents an intensity measurement from an imaging sensor. Internally the pixels are stored a 1D array in a row-major format. Different primitive types (e.g. byte, short, float, double) are implemented by children of this class. This image format is designed to allow quick and easy read/write access to each pixel and automatically supports sub-images.
Most image operations work off of direct children of this class. For operations which support images with
multiple bands or colors (e.g. RGB or planar cameras) there is the
ImageInterleaved class and others.
The image is defined by the following parameters:
- number of columns in the image.
- number of rows in the image.
- The index of the first pixel in the data array.
- Number of elements which need to be skipped over in the data array between rows.
Sub-images are images that are a rectangular image inside of a larger image. The original image and the sub-image share the same data array, so an operation in one will affect the other. They are useful when only part of the image needs to be processed. All image processing operations support sub-images.
Pixels can be directly accessed by elements. For example, to access the pixel at (x = 3, y = 10) one would do:
pixelValue = img.data[ startIndex + 10*stride ]
- See Also:
- Serialized Form
Nested Class Summary
Constructors Modifier Constructor Description
(int width, int height)Creates a new image with all of its parameters initialized, including the data array.
Modifier and Type Method Description
protected abstract Object
()Returns the data array the image is stored in.
Object data)(Sets the image's internal data array.
Object array)(int row, int col0, int col1, int offset,Copies the row into the array.
static <B extends ImageGray<B>>
Class<B> type, int width, int height)(
<B extends ImageGray<B>>
Class<B> type)(Creates a single band image of the specified type that will have the same shape as this image
()Returns image type information
(int width, int height)
()Prints the image to standard out
(int width, int height)Changes the image's width and height without declaring new memory.
ImageBase img)(Reshape to match the input image's width and height
T orig)(Sets the values of each pixel equal to the pixels in the specified matrix.
T subimage)(int x0, int y0, int x1, int y1,Creates a rectangular sub-image from 'this' image.
Methods inherited from class boofcv.struct.image.ImageBase
clone, copyCol, createNew, createSameShape, forEachXY, getImageType, getIndex, indexToPixelX, indexToPixelY, isInBounds, isSubimage, matchShape, subimage, totalPixels
ImageGrayprotected ImageGray(int width, int height)Creates a new image with all of its parameters initialized, including the data array.
width- Image's width.
height- Image's height.
initializeprotected void initialize(int width, int height)
Creates a rectangular sub-image from 'this' image. The subimage will share the same internal array that stores each pixel's value. Any changes to pixel values in the original image or the sub-image will affect the other. A sub-image must be a sub-set of the original image and cannot specify a bounds larger than the original.
When specifying the sub-image, the top-left corner is inclusive and the bottom right corner exclusive. Thus, a sub-image will contain all the original pixels if the following is used: subimage(0,0,width,height,null).
- Specified by:
ImageBase<T extends ImageGray<T>>
x0- x-coordinate of top-left corner of the sub-image, inclusive.
y0- y-coordinate of top-left corner of the sub-image, inclusive.
x1- x-coordinate of bottom-right corner of the sub-image, exclusive.
y1- y-coordinate of bottom-right corner of the sub-image, exclusive.
subimage- Optional output for sub-image. If not null the subimage will be written into this image.
- A sub-image of 'this' image.
reshapepublic void reshape(int width, int height)Changes the image's width and height without declaring new memory. If the internal array is not large enough to store the new image an IllegalArgumentException is thrown.
reshapepublic void reshape(ImageBase img)Reshape to match the input image's width and height
setTopublic void setTo(T orig)Sets the values of each pixel equal to the pixels in the specified matrix. If the images are not the same shape this will be resized.
createSameShapeCreates a single band image of the specified type that will have the same shape as this image
copyRowpublic void copyRow(int row, int col0, int col1, int offset, Object array)Description copied from class:
ImageBaseCopies the row into the array.
public abstract void print()Prints the image to standard out
_getDataprotected abstract Object _getData()Returns the data array the image is stored in.
- data array;
getDataTypepublic abstract ImageDataType getDataType()Returns image type information
- The type of image.
_setDatapublic abstract void _setData(Object data)Sets the image's internal data array.
data- data array