public abstract class ImageGray<T extends ImageGray> 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:
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 second band in an image with three color
bands at pixel (3,10) one would do:
secondBand = img.data[ startIndex + 10*stride + 3 ]
| Modifier | Constructor and Description |
|---|---|
protected |
ImageGray() |
protected |
ImageGray(int width,
int height)
Creates a new image with all of its parameters initialized, including the
data array.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.Object |
_getData()
Returns the data array the image is stored in.
|
protected abstract void |
_setData(java.lang.Object data)
Sets the image's internal data array.
|
abstract ImageDataType |
getDataType()
Returns image type information
|
void |
reshape(int width,
int height)
Changes the image's width and height without declaring new memory.
|
void |
setTo(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,
T subimage)
Creates a rectangular sub-image from 'this' image.
|
_createNew, clone, createSameShape, getHeight, getImageType, getIndex, getStartIndex, getStride, getWidth, indexToPixel, isInBounds, isSubimage, setHeight, setStartIndex, setStride, setWidth, subimageprotected ImageGray(int width,
int height)
width - Image's width.height - Image's height.protected ImageGray()
public T subimage(int x0, int y0, int x1, int y1, T 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).
subimage in class ImageBase<T extends ImageGray>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.public void reshape(int width,
int height)
public void setTo(T orig)
protected abstract java.lang.Object _getData()
public abstract ImageDataType getDataType()
protected abstract void _setData(java.lang.Object data)
data - data array