Class ImageGray<T extends ImageGray<T>>
- All Implemented Interfaces:
Serializable
,Cloneable
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:
- width
- number of columns in the image.
- height
- number of rows in the image.
- startIndex
- The index of the first pixel in the data array.
- stride
- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class boofcv.struct.image.ImageBase
ImageBase.PixelXY
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Object
_getData()
Returns the data array the image is stored in.abstract void
Sets the image's internal data array.void
Copies the row into the array.static <B extends ImageGray<B>>
B<B extends ImageGray<B>>
BcreateSameShape
(Class<B> type) Creates a single band image of the specified type that will have the same shape as this imageabstract ImageDataType
Returns image type informationprotected void
initialize
(int width, int height) abstract void
print()
Prints the image to standard outvoid
reshape
(int width, int height) Changes the image's width and height without declaring new memory.void
Reshape to match the input image's width and heightSets the values of each pixel equal to the pixels in the specified matrix.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, isSameShape, isSubimage, reshapeTo, subimage, totalPixels
-
Constructor Details
-
ImageGray
protected ImageGray(int width, int height) Creates a new image with all of its parameters initialized, including the data array.- Parameters:
width
- Image's width.height
- Image's height.
-
ImageGray
protected ImageGray()
-
-
Method Details
-
initialize
protected void initialize(int width, int height) -
subimage
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:
subimage
in classImageBase<T extends ImageGray<T>>
- Parameters:
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.- Returns:
- A sub-image of 'this' image.
-
reshape
public 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. -
reshape
Reshape to match the input image's width and height -
setTo
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. -
createSameShape
Creates a single band image of the specified type that will have the same shape as this image -
create
-
copyRow
Description copied from class:ImageBase
Copies the row into the array. -
print
public abstract void print()Prints the image to standard out -
_getData
Returns the data array the image is stored in.- Returns:
- data array;
-
getDataType
Returns image type information- Returns:
- The type of image.
-
_setData
Sets the image's internal data array.- Parameters:
data
- data array
-