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

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Lambda for each (x,y) coordinate in the image
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    Number of rows in the image.
    Description of the image data structure
    int
    Index of the first pixel in the data array
    int
    How many elements need to be skipped over to go one row down.
    boolean
    Indicates if it is a sub-image or not
    int
    Number of columns in the image.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates an identical image.
    abstract void
    copyCol(int col, int row0, int row1, int offset, Object array)
    Copies the column into the array.
    abstract void
    copyRow(int row, int col0, int col1, int offset, Object array)
    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
    For each for each (x,y) coordinate inside the image.
    Description of the image data structure
    int
    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
    Returns true if these two images have the same shape
    boolean
    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
    setTo(T orig)
    Sets the value of 'this' image to be identical to the passed in image.
    subimage(int x0, int y0, int x1, int y1)
    Same as subimage(int, int, int, int, ImageBase), but sets the storage for the input subimage to null.
    abstract T
    subimage(int x0, int y0, int x1, int y1, T subimage)
    Creates a rectangular sub-image from 'this' image.
    int
    Returns the number of pixels in the image.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • startIndex

      public int startIndex
      Index of the first pixel in the data array
    • stride

      public int stride
      How many elements need to be skipped over to go one row down.
    • width

      public int width
      Number of columns in the image.
    • height

      public int height
      Number of rows in the image.
    • subImage

      public boolean subImage
      Indicates if it is a sub-image or not
    • imageType

      public ImageType imageType
      Description of the image data structure
  • Constructor Details

    • ImageBase

      public ImageBase()
  • Method Details

    • subimage

      public abstract T subimage(int x0, int y0, int x1, int y1, @Nullable 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).

      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

      public T subimage(int x0, int y0, int x1, int y1)
      Same as subimage(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 width
      height - Desired image height
    • reshapeTo

      public void reshapeTo(ImageBase image)
      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

      public abstract T setTo(T orig)
      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-axis
      y - 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

      public abstract T createNew(int imgWidth, int imgHeight)
      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 image
      imgHeight - height of the new image
      Returns:
      new image
    • getImageType

      public ImageType<T> getImageType()
      Description of the image data structure
      Returns:
      Description of the image data structure
    • createSameShape

      public T createSameShape()
      Creates a new image of the same type which also has the same shape. This is the same as calling createNew(int, int) with this image's width and height.
      Returns:
      new image with the same shape as this.
    • isSameShape

      public boolean isSameShape(ImageBase<?> image)
      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

      public void forEachXY(ImageBase.PixelXY function)
      For each for each (x,y) coordinate inside the image.
    • copyRow

      public abstract void copyRow(int row, int col0, int col1, int offset, Object array)
      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 array
      array - Output array
    • copyCol

      public abstract void copyCol(int col, int row0, int row1, int offset, Object array)
      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 array
      array - Output array
    • clone

      public T 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.
      Overrides:
      clone in class Object
      Returns:
      Clone of this image.