Visual Servoing Platform
version 3.6.1 under development (2024-12-17)
|
#include <visp3/visual_features/vpFeatureLuminanceMapping.h>
Public Member Functions | |
vpLuminancePCA () | |
virtual | ~vpLuminancePCA () |
vpLuminancePCA (const std::shared_ptr< vpMatrix > &basis, const std::shared_ptr< vpColVector > &mean, const vpColVector &explainedVariance) | |
vpLuminancePCA (const vpLuminancePCA &other) | |
vpLuminancePCA & | operator= (const vpLuminancePCA &other) |
void | init (const std::shared_ptr< vpMatrix > &basis, const std::shared_ptr< vpColVector > &mean, const vpColVector &variance) |
std::shared_ptr< vpMatrix > | getBasis () const |
std::shared_ptr< vpColVector > | getMean () const |
vpColVector | getExplainedVariance () const |
void | map (const vpImage< unsigned char > &I, vpColVector &s) VP_OVERRIDE |
void | inverse (const vpColVector &s, vpImage< unsigned char > &I) VP_OVERRIDE |
void | interaction (const vpImage< unsigned char > &I, const vpMatrix &LI, const vpColVector &s, vpMatrix &L) VP_OVERRIDE |
void | save (const std::string &basisFilename, const std::string &meanFileName, const std::string &explainedVarianceFile) const |
unsigned int | getProjectionSize () const |
unsigned int | getBorder () const |
void | setBorder (unsigned border) |
Static Public Member Functions | |
static vpLuminancePCA | load (const std::string &basisFilename, const std::string &meanFileName, const std::string &explainedVarianceFile) |
static vpLuminancePCA | learn (const std::vector< vpImage< unsigned char >> &images, const unsigned int projectionSize, const unsigned int imageBorder=0) |
static vpLuminancePCA | learn (const vpMatrix &images, const unsigned int projectionSize) |
static void | imageAsVector (const vpImage< unsigned char > &I, vpColVector &Ivec, unsigned border) |
static void | imageAsMatrix (const vpImage< unsigned char > &I, vpMatrix &Imat, unsigned border) |
Protected Attributes | |
unsigned | m_mappingSize |
unsigned | m_border |
Implementation of [35].
Projects an image onto an orthogonal subspace, obtained via Principal Component Analysis (PCA).
The orthogonal basis is obtained through Singular Value Decomposition of a dataset of images (see vpLuminancePCA::learn) where the first basis vectors that explain the most variance are kept.
an image is projected to the representation with:
with the subspace projection matrix ( ) and is the average image computed from the dataset.
Definition at line 150 of file vpFeatureLuminanceMapping.h.
|
inline |
Definition at line 153 of file vpFeatureLuminanceMapping.h.
|
inlinevirtual |
Destructor.
Definition at line 158 of file vpFeatureLuminanceMapping.h.
vpLuminancePCA::vpLuminancePCA | ( | const std::shared_ptr< vpMatrix > & | basis, |
const std::shared_ptr< vpColVector > & | mean, | ||
const vpColVector & | explainedVariance | ||
) |
Build a new PCA object.
basis | a k x dim(I) matrix |
mean | the mean image represented as a vector |
explainedVariance | The explained variance for each of the k vectors. |
Definition at line 76 of file vpFeatureLuminanceMapping.cpp.
References init().
vpLuminancePCA::vpLuminancePCA | ( | const vpLuminancePCA & | other | ) |
Copy constructor: does not make a deep copy of the basis and mean.
Definition at line 98 of file vpFeatureLuminanceMapping.cpp.
|
inline |
Get , the subspace projection matrix ( )
Definition at line 191 of file vpFeatureLuminanceMapping.h.
|
inlineinherited |
Returns the number of pixels that are removed by the photometric VS computation.
Definition at line 114 of file vpFeatureLuminanceMapping.h.
|
inline |
Get the values of explained variance by each of the eigen vectors.
When all eigenvectors of the dataset are considered, the explained variance total is 1. When they are not all considered (as should be the case), their sum should be below 1.
Definition at line 205 of file vpFeatureLuminanceMapping.h.
|
inline |
Get , the mean image computed from the dataset.
Definition at line 196 of file vpFeatureLuminanceMapping.h.
|
inlineinherited |
Returns the size of the space to which an image is mapped to.
Definition at line 107 of file vpFeatureLuminanceMapping.h.
|
staticinherited |
Definition at line 59 of file vpFeatureLuminanceMapping.cpp.
References vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpArray2D< Type >::resize().
Referenced by vpLuminanceDCT::map().
|
staticinherited |
Definition at line 43 of file vpFeatureLuminanceMapping.cpp.
References vpException::dimensionError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpColVector::resize().
Referenced by map().
void vpLuminancePCA::init | ( | const std::shared_ptr< vpMatrix > & | basis, |
const std::shared_ptr< vpColVector > & | mean, | ||
const vpColVector & | variance | ||
) |
Initialize the PCA object with a basis, mean and explained variance vector.
basis | |
mean | |
variance |
Definition at line 83 of file vpFeatureLuminanceMapping.cpp.
References vpFeatureLuminance::DEFAULT_BORDER, vpException::dimensionError, vpArray2D< Type >::getRows(), vpLuminanceMapping::m_border, and vpLuminanceMapping::m_mappingSize.
Referenced by vpLuminancePCA().
|
virtual |
Compute the interaction matrix associated with the representation s
.
I | input image used to compute s |
LI | Photometric interaction matrix associated to I (see vpFeatureLuminance) |
s | the already computed representation |
L | The output interaction matrix, of dimensions getProjectionSize() x 6 |
Implements vpLuminanceMapping.
Definition at line 139 of file vpFeatureLuminanceMapping.cpp.
|
virtual |
Reconstruct I
from a representation s
.
s | the representation |
I | Output lossy reconstruction |
Implements vpLuminanceMapping.
Definition at line 127 of file vpFeatureLuminanceMapping.cpp.
References vpImage< Type >::resize().
|
static |
Compute a new Principal Component Analysis on set of images.
images | The list of images used to compute the PCA |
projectionSize | the number of eigenvectors that are kept for the final projection |
imageBorder | The number of pixels to crop on each side of the image before adding it to the image set, effectively taking the center crop. Useful when the images do not have the correct dimensions. Typically, the input image to PCA is smaller than the one used when computing luminance features, since the latter step requires crops the image. |
if | the images do not have the same dimensions |
Definition at line 188 of file vpFeatureLuminanceMapping.cpp.
References vpException::badValue, vpArray2D< Type >::getCols(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpArray2D< Type >::resize(), and vpMatrix::transpose().
|
static |
Compute a new Principal Component Analysis on dataset.
images | The data matrix, where each column represents a single data point (image) |
projectionSize | the number of eigenvectors that are kept for the final projection |
Definition at line 232 of file vpFeatureLuminanceMapping.cpp.
References vpException::badValue, vpMatrix::getCol(), vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), vpColVector::sum(), vpMatrix::svd(), vpMatrix::t(), and vpLuminancePCA().
|
static |
Save the PCA basis to multiple text files, for later use via the load function.
basisFilename | The file in which is stored |
meanFileName | The file in which is stored |
explainedVarianceFile | The file containing the explained variance. |
if | files cannot be read, or if basis and mean dimensions are incorrect. |
Definition at line 144 of file vpFeatureLuminanceMapping.cpp.
References vpException::dimensionError, vpArray2D< Type >::getCols(), vpMatrix::loadMatrix(), and vpLuminancePCA().
|
virtual |
Map an image I
to a representation s
. This representation s has getProjectionSize() rows.
Note that when combined with vpFeatureLuminanceMapping, The image I
does not have the same size as the image input of vpFeatureLuminanceMapping::build. I
is the center crop of this image.
I | The input image |
s | The resulting representation that will serve as visual servoing features. |
Implements vpLuminanceMapping.
Definition at line 117 of file vpFeatureLuminanceMapping.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpLuminanceMapping::imageAsVector(), and vpLuminanceMapping::m_border.
vpLuminancePCA & vpLuminancePCA::operator= | ( | const vpLuminancePCA & | other | ) |
Definition at line 103 of file vpFeatureLuminanceMapping.cpp.
References vpLuminanceMapping::m_border, and vpLuminanceMapping::m_mappingSize.
void vpLuminancePCA::save | ( | const std::string & | basisFilename, |
const std::string & | meanFileName, | ||
const std::string & | explainedVarianceFile | ||
) | const |
Save the PCA basis to multiple text files, for later use via the load function.
basisFilename | The file in which is stored |
meanFileName | The file in which is stored |
explainedVarianceFile | The file containing the explained variance. |
if | the basis is null or mean is null |
Definition at line 173 of file vpFeatureLuminanceMapping.cpp.
References vpException::dimensionError, vpException::notInitialized, and vpMatrix::saveMatrix().
|
inlineinherited |
Set the number of pixels that are removed by the photometric VS computation This function should be called by vpFeatureLuminanceMapping.
border |
Definition at line 122 of file vpFeatureLuminanceMapping.h.
|
protectedinherited |
Final vector size.
Definition at line 129 of file vpFeatureLuminanceMapping.h.
Referenced by init(), map(), vpLuminanceDCT::map(), and operator=().
|
protectedinherited |
Definition at line 128 of file vpFeatureLuminanceMapping.h.
Referenced by init(), vpLuminanceDCT::interaction(), vpLuminanceDCT::map(), and operator=().