CVB++ 15.0
Cube Class Reference

Spectral Cube object. More...

#include <cvb/spectral/cube.hpp>

Inherited by WrappedCube.

Public Member Functions

std::unique_ptr< CubeClone ()
 Copies the memory to a new instance of a cube. More...
 
CubeType Type () const
 Retrieves the type of this cube object. More...
 
class DataType DataType () const
 Retrieves the data type of this cube object. More...
 
std::unique_ptr< CubeConvert (CubeEncoding targetView) const
 Converts cube to given cube encoding targetView. More...
 
std::unique_ptr< CubeMap (CubeRange spectralCubeoid)
 Creates a cropped cube. More...
 
Cvb::ImagePtr BufferView () const
 Retrieves the buffer view of the cube. More...
 
MetaDataPtr MetaData () const
 Retrieves the meta data object of the cube. More...
 
bool TryLinearAccess (LinearAccessData &linearAccessOut) const noexcept
 Retrieve linear access of cube data without throwing an exception. More...
 
LinearAccessData LinearAccess () const
 Retrieve linear access of cube data. More...
 
template<typename T >
std::vector< T > SpectralDensity (int sampleIndex, int lineIndex) const
 Retrieves spectral density at given pixel. More...
 
void Save (Cvb::String EnviHeader, Cvb::String EnviBinary) const
 Writes this cube object to ENVI-format. More...
 
void * Handle () const noexcept
 Returns C-API style handle to the Cube. More...
 
bool TryBufferView (ImagePtr &bufferViewOut) const noexcept
 Retrieves the buffer view of the cube without throwing an exception. More...
 
bool TryMetaData (MetaDataPtr &metaDataOut) const noexcept
 Retrieves the meta data object of the cube without throwing an exception. More...
 

Static Public Member Functions

static std::unique_ptr< CubeCreate (int numSamples, int numLines, int numBands, DataType dataType, CubeEncoding bufferLayout=CubeEncoding::BandInterleavedByLine)
 Creates a Continuous Cube object. More...
 
static std::unique_ptr< CubeFromImages (const std::vector< ImagePtr > &images, CubeEncoding bufferLayout)
 Initializes a stacked cube using an array of images. More...
 
static std::unique_ptr< CubeLoad (Cvb::String EnviHeader, Cvb::String EnviBinary)
 Static function Loads a cube from ENVI. More...
 
static std::unique_ptr< CubeFromHandle (HandleGuard< Cube > &&guard)
 Creates cube from a classic API handle. More...
 

Detailed Description

Spectral Cube object.

An Image Cube (or Cube) is a representation of a hyper spectral image. In CVB an Image Cube object consists of a meta data and a buffer view.

  • The meta data contains information on the Image Cube and holds a list of fields. Most notable field here is Interleave. This value defines the orientation of the Image Cube.
  • The buffer view is an Image object, which handles the pixel access. Accessing a pixel is done in the conventional CVB way using the VPAT (or Linear Access).

The dimensions of the Image Cube are referred to sample in the range [0, Samples[, line in the range [0, Lines[ and band in the range [0, Bands[. The dimensions of an Image in CVB are referred to x in the range [0, width[ , y in the range [0, height[ and z in the range [0, dimensions[. The Interleaved value in the meta data defines the mapping between these two spaces.

There are four distinct types of Image Cubes: Continuous Image Cubes, Mapped Image Cubes, Stacked Image Cubes and Linear Non-Owning Cubes

  • A Continuous Image Cube owns a linear buffer. In this buffer each pixel is order in a sequential order without any mapping. This allows fast linear pixel access.
  • In contrast a Mapped Image Cube references a Continuous Image Cube and accesses its buffer. Here the view on the buffer is mapped. This enables fast operations like cropping without copying the buffer. As a drawback the linear pixel access may be slower then with Continuous Image Cubes.
  • Stacked Image Cubes are used to initialize Image Cubes through an array of Images. This Image Cube makes no copy of the Image Buffer but instead references each buffer. Therefore make sure that all Image buffers are not deleted during the lifetime this cube. To normalize a Stacked Image Cube call Cube::Clone first.
  • Linear Non-Owning Cube can be created from any linear buffer. This makes this kind of cube highly flexible and allows a broader range of applications. The drawback is that during lifetime the buffer is potentially invalidated.

In the CVB++ wrapper the Cube object covers the following cube types: Continuous Image Cubes, Mapped Image Cubes, Stacked Image Cubes The Linear Non-Owning Cube is covered by the WrappedCube as this Cube holds potential dangers.

Member Function Documentation

◆ BufferView()

Cvb::ImagePtr BufferView ( ) const
inline

Retrieves the buffer view of the cube.

Returns
The view on the buffer through an ImagePtr.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
MetaData

The buffer view is the shared pointer to object containing the image. This image encapsulates the buffer of the cube. This image is of size width x height x dimensions. These dimensions can be mapped to samples, lines and bands depending on the Cvb::Spectral::CubeEncoding of this cube.

◆ Clone()

std::unique_ptr< Cube > Clone ( )
inline

Copies the memory to a new instance of a cube.

Returns
Pointer to Continuous Cube object.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Create Save Map Transpose

In cases the source cube has a mapped view only this particular view is copied

◆ Convert()

std::unique_ptr< Cube > Convert ( CubeEncoding  targetView) const
inline

Converts cube to given cube encoding targetView.

Creates a continous image cube and copies data. The number of samples, lines and bands are equal, but the order in the buffer is different.

Parameters
[in]targetViewView perspective of the returned cube.
Returns
The converted cube.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Create()

static std::unique_ptr< Cube > Create ( int  numSamples,
int  numLines,
int  numBands,
DataType  dataType,
CubeEncoding  bufferLayout = CubeEncoding::BandInterleavedByLine 
)
inlinestatic

Creates a Continuous Cube object.

Parameters
[in]numSamplesNumber of Samples
[in]numLinesNumber of Lines
[in]numBandsNumber of Bands
[in]dataTypeData type of each pixel value
[in]bufferLayoutView perspective on the buffer
Returns
Pointer to Continuous Cube object.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
FromImages Load FromHandle

◆ DataType()

class DataType DataType ( ) const
inline

Retrieves the data type of this cube object.

Returns
DataType of this cube instance
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Type MetaData

This function can be called with any type of cube

◆ FromHandle()

static std::unique_ptr< Cube > FromHandle ( HandleGuard< Cube > &&  guard)
inlinestatic

Creates cube from a classic API handle.

Parameters
[in]guardLife time guard for C-API handle.
Returns
The Cube created from the classic API handle.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Handle

The Cube takes ownership of the handle, so you must share it before using this function.

◆ FromImages()

static std::unique_ptr< Cube > FromImages ( const std::vector< ImagePtr > &  images,
CubeEncoding  bufferLayout 
)
inlinestatic

Initializes a stacked cube using an array of images.

Parameters
[in]imagesSingle planed image array of equal size and datatype
[in]bufferLayoutInterleaved type of input images
Returns
Pointer to stacked cube object.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Load Create FromHandle

Creates a stacked ImageCube using the given image arrays without copying any buffer.

Examples
Spectral/CubeAcquisition.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Returns C-API style handle to the Cube.

Returns
C-API handle

◆ LinearAccess()

LinearAccessData LinearAccess ( ) const
inline

Retrieve linear access of cube data.

Returns
Returns the linear access to access spectral data
Exceptions
Throwsan exception if linear access is not possible
See also
TryLinearAccess

◆ Load()

static std::unique_ptr< Cube > Load ( Cvb::String  EnviHeader,
Cvb::String  EnviBinary 
)
inlinestatic

Static function Loads a cube from ENVI.

Parameters
[in]EnviHeaderHeader file of the ENVI-format data (.hdr).
[in]EnviBinaryBinary file of the ENVI-format data (.bin).
Returns
The cube loaded from file.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Save Create FromImages
Examples
Spectral/ColorConvert.

◆ Map()

std::unique_ptr< Cube > Map ( CubeRange  spectralCubeoid)
inline

Creates a cropped cube.

Parameters
[in]spectralCubeoidCrop the source cube by this cuboid.
Returns
A cropped cube. Target cube type depends on source type.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Transpose Clone

The returned cube type depends on the source cube type.

Input CubeTypeOutput CubeType
CubeType::ContinuousCube CubeType::MappedCube
CubeType::MappedCube CubeType::MappedCube
CubeType::StackedCube CubeType::ContinuousCube
CubeType::LinearNonOwningCube CubeType::LinearNonOwningCube

◆ MetaData()

MetaDataPtr MetaData ( ) const
inline

Retrieves the meta data object of the cube.

Returns
The meta data.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
BufferView

This method returns a shared pointer to the meta data object

◆ Save()

void Save ( Cvb::String  EnviHeader,
Cvb::String  EnviBinary 
) const
inline

Writes this cube object to ENVI-format.

Parameters
[in]EnviHeaderHeader file of the ENVI-format data (.hdr)
[in]EnviBinaryBinary file of the ENVI-format data (.bin)
Exceptions
Anyexception derived from std::exception including CvbException.
See also
Load

◆ SpectralDensity()

std::vector< T > SpectralDensity ( int  sampleIndex,
int  lineIndex 
) const
inline

Retrieves spectral density at given pixel.

Parameters
[in]sampleIndexIndex of the sample to inspect.
[in]lineIndexIndex of the line to inspect.
Returns
The spectral density at given pixel.
Exceptions
Anyexception derived from std::exception including CvbException.
See also
BufferView

◆ TryBufferView()

bool TryBufferView ( ImagePtr bufferViewOut) const
inlinenoexcept

Retrieves the buffer view of the cube without throwing an exception.

Parameters
[out]bufferViewOutOutput meta data
Returns
Returns true for successful, false otherwise
Exceptions
Doesnot throw an exception

The buffer view is a pointer to the image which contains the buffer of the cube. This image is of size Width x Height x Dimensions. These dimensions can mapped to samples, lines and bands depending on the CubeEncoding of this cube.

◆ TryLinearAccess()

bool TryLinearAccess ( LinearAccessData linearAccessOut) const
inlinenoexcept

Retrieve linear access of cube data without throwing an exception.

Parameters
[out]linearAccessOutOutput of spectral linear access
Returns
Returns true if successful, otherwise false
Exceptions
Doesnot throw an exception
See also
LinearAccess

◆ TryMetaData()

bool TryMetaData ( MetaDataPtr metaDataOut) const
inlinenoexcept

Retrieves the meta data object of the cube without throwing an exception.

Parameters
[out]metaDataOutOutput meta data
Returns
Returns true for successful, false otherwise
Exceptions
Doesnot throw an exception

◆ Type()

CubeType Type ( ) const
inline

Retrieves the type of this cube object.

Returns
Type of this cube instance
Exceptions
Anyexception derived from std::exception including CvbException.
See also
DataType MetaData