Efros-Leung
Exemplar-basedtexturesynthesis(Efros-Leung)
Functions
inc/pca.h File Reference

PCA (Principal Components Analysis) functions. More...

#include "auxiliary.h"
#include "linear_algebra.h"
#include "svd.h"

Go to the source code of this file.

Functions

float * pca_generate_base (float *X, int m, int n, int k)
 Generate the matrix of $k$ PCA axis.
float * pca_project (float *X, float *W, int k, int m, int n)
 Project the data on some axis.
float * pca_project_vector (float *x, float *W, float *mean, int m, int k)
 Project a vector on some axis.
void pca_generate_matrix (ImageF w, int t, float *gauss_wg, float **dictionaryU_out, float **dictionaryD_out, float **dictionaryR_out, float **dictionaryL_out, float **meanU, float **meanD, float **meanR, float **meanL)
 Extract all half-patches from the image.
void pca (ImageF w, int t, int k, float *gauss_wg, float **WU, float **WD, float **WR, float **WL, float **YU, float **YD, float **YR, float **YL, float **meanU, float **meanD, float **meanR, float **meanL)
 Decompose all half-patches of the image in a PCA basis.
void construct_dictionary_pca (ImageF w, float *gauss_wg_pca, int t, int k, float *YU, float *YD, float *YR, float *YL, float **dictionaryR, float **dictionaryL, float **dictionaryU, float **dictionaryD)
 Extract dictionaries and PCA projections from the image.
ImageF pca_rgb (Cimage w)
 Convert a color image into a gray-scale image using a PCA on RGB channels.

Detailed Description

PCA (Principal Components Analysis) functions.


Function Documentation

void construct_dictionary_pca ( ImageF  w,
float *  gauss_wg_pca,
int  t,
int  k,
float *  YU,
float *  YD,
float *  YR,
float *  YL,
float **  dictionaryR,
float **  dictionaryL,
float **  dictionaryU,
float **  dictionaryD 
)

Extract dictionaries and PCA projections from the image.

Parameters:
wthe image
thalf-size of the patch (full size is $T=2\cdot t+1$)
gauss_wg_pcaGaussian weights
knumber of PCA components to be kept
YUpointer to the output projected data from all the upper half-patches
YDthe same with the down part of patches
YRthe same with the right part of patches
YLthe same with the left part of patches
dictionaryUpointer to the output dictionary, dictionary will be extracted from all the upper half-patches
dictionaryDthe same with the down part of patches
dictionaryRthe same with the right part of patches
dictionaryLthe same with the left part of patches
void pca ( ImageF  w,
int  t,
int  k,
float *  gauss_wg,
float **  WU,
float **  WD,
float **  WR,
float **  WL,
float **  YU,
float **  YD,
float **  YR,
float **  YL,
float **  meanU,
float **  meanD,
float **  meanR,
float **  meanL 
)

Decompose all half-patches of the image in a PCA basis.

Parameters:
wthe image
thalf-size of the patch (full size is $T=2\cdot t+1$)
knumber of PCA components to be kept
gauss_wgGaussian weights
WUpointer to the output data, extracted from all the upper half-patches
WDthe same with the down part of patches
WRthe same with the right part of patches
WLthe same with the left part of patches
YUpointer to the output projected data from all the upper half-patches
YDthe same with the down part of patches
YRthe same with the right part of patches
YLthe same with the left part of patches
meanUpointer to the output mean for the upper parts
meanDpointer to the output mean for the down parts
meanRpointer to the output mean for the right parts
meanLpointer to the output mean for the left parts
See also:
pca_generate_base, pca_project
float* pca_generate_base ( float *  X,
int  m,
int  n,
int  k 
)

Generate the matrix of $k$ PCA axis.

Compute the PCA axis--i.e. the eigenvectors of $XX^t$ and also the $W$ matrix of size $m\times m$ in the SVD of $X=WSV^t$.

Select the $k$ eigenvectors with the largest eigenvalues.

Parameters:
Xdata matrix, size $m\times n$, centered
mdimension of the data
nnumber of data
knumber of components to be kept
Warning:
$X$ is assumed centered
Returns:
Matrix of size $m\times k$: the $k$ PVA axis, normalized.
void pca_generate_matrix ( ImageF  w,
int  t,
float *  gauss_wg,
float **  dictionaryU_out,
float **  dictionaryD_out,
float **  dictionaryR_out,
float **  dictionaryL_out,
float **  meanU,
float **  meanD,
float **  meanR,
float **  meanL 
)

Extract all half-patches from the image.

Built dictionaries will be matrices of size $m\cdot n$ containing $n$ patches of dimensions $m=t\cdot T$ .

Consecutive values are all the components of a same patch (the columns of the dictionaries) with respect to Lapack column major order.

Parameters:
wthe image
thalf-size of the patch (full size is $T=2\cdot t+1$)
gauss_wgGaussian weights
dictionaryU_outpointer to the output dictionary, dictionary will be extracted from all the upper half-patches
dictionaryD_outthe same with the down part of patches
dictionaryR_outthe same with the right part of patches
dictionaryL_outthe same with the left part of patches
meanUpointer to the output mean, computed on all the upper half-patches
meanDthe same with the down part of patches
meanRthe same with the right part of patches
meanLthe same with the left part of patches
float* pca_project ( float *  X,
float *  W,
int  k,
int  m,
int  n 
)

Project the data on some axis.

Parameters:
Xdata matrix, size $m\times n$, centered
Wprojection axis, size $m\times k$, normalized columns
knumber of dimension kept by PCA
mdimension of the data
nnumber of data
Warning:
$X$ is assumed centered
Returns:
Projection $Y=W^tX$, size $m\times n$
float* pca_project_vector ( float *  x,
float *  W,
float *  mean,
int  m,
int  k 
)

Project a vector on some axis.

Parameters:
xdata vector, size $m$
meanmean vector to use for $x$, size $m$
Wprojection axis, size $m\times k$, normalized columns
knumber of dimension kept by PCA
mdimension of the data
Returns:
Projection $y=W^tx$, size $k$

Convert a color image into a gray-scale image using a PCA on RGB channels.

Parameters:
wcolor image
Returns:
gray-scale image
 All Classes Files Functions Variables