Package boofcv.struct.image
Class Planar<T extends ImageGray<T>>
- All Implemented Interfaces:
Serializable
,Cloneable
Multi-band image composed of discontinuous planar images for each band. The bands are discontinuous in that
each one is an independent memory and are of type ImageGray
. Planar images fully supports all
functions inside of ImageBase
. Each internal image has the same width, height, startIndex, and stride.
For example, in a RGB image there would be three bands one for each color,
and each color would be stored in its own gray scale image. To access the image for a particular
band call getBand(int)
. To get the RGB value for a pixel (x,y) one would need to:
int red = image.getBand(0).get(x,y); int green = image.getBand(1).get(x,y); int blue = image.getBand(2).get(x,y);Setting the RGB value of pixel (x,y) is done in a similar manner:
image.getBand(0).set(x,y,red); image.getBand(1).set(x,y,green); image.getBand(2).set(x,y,blue);
May image processing operations can be run independently on each color band. This is useful since many
operations have been written for ImageGray
, but not Planar yet.
for( int i = 0; i < image.numBands(); i++ ) { SomeGrayImageFilter.process( image.getBand(0) ); }
- 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 TypeMethodDescriptionvoid
Copies the column into the array.void
Copies the row into the array.createNew
(int imgWidth, int imgHeight) Creates a new image of the same type and number of bandsint
get24u8
(int x, int y) Returns an integer formed from 3 bands.int
get32u8
(int x, int y) Returns an integer formed from 4 bands.getBand
(int band) Returns a band in the multi-band image.T[]
getBands()
Type of image each band is stored as.int
Returns the number of bands or colors stored in this image.partialSpectrum
(int... which) Returns a newPlanar
which references the same internal single band images at this one.void
reorderBands
(int... order) Changes the bands ordervoid
reshape
(int width, int height) Changes the image's width and height without declaring new memory.void
reshape
(int width, int height, int numberOfBands) Reshape for MultiBand images which allows the number of bands to be changed a the same time toovoid
set24u8
(int x, int y, int value) void
set32u8
(int x, int y, int value) void
void
void
setBandType
(Class<T> type) void
setNumberOfBands
(int numberOfBands) Changes the number of bands in the image.Sets the values of each pixel equal to the pixels in the specified matrix.Creates a sub-image from 'this' image.Methods inherited from class boofcv.struct.image.ImageMultiBand
reshapeTo
Methods inherited from class boofcv.struct.image.ImageBase
clone, createSameShape, forEachXY, getImageType, getIndex, indexToPixelX, indexToPixelY, isInBounds, isSameShape, isSubimage, subimage, totalPixels
-
Field Details
-
type
Type of image in each band -
bands
Set of gray scale images
-
-
Constructor Details
-
Planar
Creates a Planar image with the specified properties.- Parameters:
type
- The type of image which each band is stored as.width
- Width of the image.height
- Height of the image.numBands
- Total number of bands.
-
Planar
Declares internal arrays for storing each band, but not the images in each band.- Parameters:
type
- The type of image which each band is stored as.numBands
- Number of bands in the image.
-
-
Method Details
-
getBandType
Type of image each band is stored as.- Returns:
- The type of ImageGray which each band is stored as.
-
getNumBands
public int getNumBands()Returns the number of bands or colors stored in this image.- Specified by:
getNumBands
in classImageMultiBand<Planar<T extends ImageGray<T>>>
- Returns:
- Number of bands in the image.
-
getBand
Returns a band in the multi-band image.- Parameters:
band
- Which band should be returned.- Returns:
- Image band
-
subimage
Creates a sub-image from 'this' image. The subimage will share the same internal array that stores each pixel's value, but will only pertain to an axis-aligned rectangular segment of the original.- Specified by:
subimage
in classImageBase<Planar<T extends ImageGray<T>>>
- Parameters:
x0
- x-coordinate of top-left corner of the sub-image.y0
- y-coordinate of top-left corner of the sub-image.x1
- x-coordinate of bottom-right corner of the sub-image.y1
- y-coordinate of bottom-right corner of the sub-image.output
- Optional storage for subimage- Returns:
- A sub-image of this image.
-
setTo
Sets the values of each pixel equal to the pixels in the specified matrix. Automatically resized to match the input 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
public void reshape(int width, int height, int numberOfBands) Description copied from class:ImageMultiBand
Reshape for MultiBand images which allows the number of bands to be changed a the same time too -
createNew
Creates a new image of the same type and number of bands -
copyRow
Description copied from class:ImageBase
Copies the row into the array. -
copyCol
Description copied from class:ImageBase
Copies the column into the array. -
partialSpectrum
Returns a newPlanar
which references the same internal single band images at this one.- Parameters:
which
- List of bands which will comprise the new image- Returns:
- New image
-
reorderBands
public void reorderBands(int... order) Changes the bands order- Parameters:
order
- The new band order
-
setNumberOfBands
public void setNumberOfBands(int numberOfBands) Changes the number of bands in the image. A new array is declared and individual bands are recycled if possible- Specified by:
setNumberOfBands
in classImageMultiBand<Planar<T extends ImageGray<T>>>
- Parameters:
numberOfBands
- New number of bands in the image.
-
get32u8
public int get32u8(int x, int y) Returns an integer formed from 4 bands. band[0]<<24 | band[1] << 16 | band[2]<<8 | band[3]. Assumes arrays are U8 type.- Parameters:
x
- columny
- row- Returns:
- 32 bit integer
-
get24u8
public int get24u8(int x, int y) Returns an integer formed from 3 bands. band[0]<<16| band[1] << 8 | band[2]- Parameters:
x
- columny
- row- Returns:
- 32 bit integer
-
set24u8
public void set24u8(int x, int y, int value) -
set32u8
public void set32u8(int x, int y, int value) -
setBandType
-
getBands
-
setBands
-
setBand
-