Package boofcv.struct.image
Class ImageBase<T extends ImageBase>
java.lang.Object
boofcv.struct.image.ImageBase<T>
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ImageGray
,ImageMultiBand
public abstract class ImageBase<T extends ImageBase>
extends Object
implements Serializable, Cloneable
Base class for all image types.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Lambda for each (x,y) coordinate in the image -
Field Summary
Modifier and TypeFieldDescriptionint
Number of rows in the image.Description of the image data structureint
Index of the first pixel in the data arrayint
How many elements need to be skipped over to go one row down.boolean
Indicates if it is a sub-image or notint
Number of columns in the image. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates an identical image.abstract void
Copies the column into the array.abstract void
Copies the row into the array.abstract T
createNew
(int imgWidth, int imgHeight) Returns a new image.Creates a new image of the same type which also has the same shape.void
forEachXY
(ImageBase.PixelXY function) For each for each (x,y) coordinate inside the image.Description of the image data structureint
getIndex
(int x, int y) int
indexToPixelX
(int index) int
indexToPixelY
(int index) final boolean
isInBounds
(int x, int y) Returns true if the pixel coordinate is inside the image or false if not.boolean
isSameShape
(ImageBase<?> image) Returns true if these two images have the same shapeboolean
If this matrix is a sub-image or not.abstract void
reshape
(int width, int height) Changes the width and height of the image.void
Reshapes this image so that the width and height matches the input image.abstract T
Sets the value of 'this' image to be identical to the passed in image.subimage
(int x0, int y0, int x1, int y1) Same assubimage(int, int, int, int, ImageBase)
, but sets the storage for the input subimage to null.abstract T
Creates a rectangular sub-image from 'this' image.int
Returns the number of pixels in the image.
-
Field Details
-
startIndex
public int startIndexIndex of the first pixel in the data array -
stride
public int strideHow many elements need to be skipped over to go one row down. -
width
public int widthNumber of columns in the image. -
height
public int heightNumber of rows in the image. -
subImage
public boolean subImageIndicates if it is a sub-image or not -
imageType
Description of the image data structure
-
-
Constructor Details
-
ImageBase
public ImageBase()
-
-
Method Details
-
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).
- 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.
-
subimage
Same assubimage(int, int, int, int, ImageBase)
, but sets the storage for the input subimage to null.- 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.- Returns:
- A sub-image of 'this' image.
-
reshape
public abstract void reshape(int width, int height) Changes the width and height of the image. If the image data array isn't large enough to hold an image of this size then a new array is declared. Otherwise the image data array is left unchanged and only the width and height variables are modified.- Parameters:
width
- Desired image widthheight
- Desired image height
-
reshapeTo
Reshapes this image so that the width and height matches the input image. If both images are multi band then the number of bands will also be matched.- Parameters:
image
- Image whose shape will be matched
-
setTo
Sets the value of 'this' image to be identical to the passed in image. All structural attributes of the images must be the same.- Parameters:
orig
- Image for which 'this' is to be a copy of.- Returns:
- Instance of 'this' to allow chaining.
-
isSubimage
public boolean isSubimage()If this matrix is a sub-image or not.- Returns:
- true if it is a subimage, otherwise false.
-
isInBounds
public final boolean isInBounds(int x, int y) Returns true if the pixel coordinate is inside the image or false if not.- Parameters:
x
- pixel location x-axisy
- pixel location y-axis- Returns:
- true if inside and false if outside
-
getIndex
public int getIndex(int x, int y) -
indexToPixelX
public int indexToPixelX(int index) -
indexToPixelY
public int indexToPixelY(int index) -
createNew
Returns a new image. If either width or height are set to -1 then none of the class parameters set. Otherwise a new image is created with the specified dimensions which has all other parameters the same as the original matrix.- Parameters:
imgWidth
- Width of the new imageimgHeight
- height of the new image- Returns:
- new image
-
getImageType
Description of the image data structure- Returns:
- Description of the image data structure
-
createSameShape
Creates a new image of the same type which also has the same shape. This is the same as callingcreateNew(int, int)
with this image's width and height.- Returns:
- new image with the same shape as this.
-
isSameShape
Returns true if these two images have the same shape -
totalPixels
public int totalPixels()Returns the number of pixels in the image. width*height -
forEachXY
For each for each (x,y) coordinate inside the image. -
copyRow
Copies the row into the array.- Parameters:
row
- Which row to copy.col0
- First column. Inclusive.col1
- Last column. Exclusive.offset
- First index in output arrayarray
- Output array
-
copyCol
Copies the column into the array.- Parameters:
col
- Which column to copy.row0
- First row. Inclusive.row1
- Last row. Exclusive.offset
- First index in output arrayarray
- Output array
-
clone
Creates an identical image. Note that if this image is a sub-image portions of hte image which are not part of the sub-image are not copied.
-