Package 'SparseVFC'

Title: Sparse Vector Field Consensus for Vector Field Learning
Description: The sparse vector field consensus (SparseVFC) algorithm (Ma et al., 2013 <doi:10.1016/j.patcog.2013.05.017>) for robust vector field learning. Largely translated from the Matlab functions in <https://github.com/jiayi-ma/VFC>.
Authors: Jingmeng Cui [aut, cre]
Maintainer: Jingmeng Cui <[email protected]>
License: GPL (>= 3)
Version: 0.1.2
Built: 2024-11-09 03:21:48 UTC
Source: https://github.com/sciurus365/sparsevfc

Help Index


The Church Photos

Description

A dataset containing the vectors for the church photos.

Usage

church

Format

A list with three components:

X

The position of points in the first photo.

Y

The position of points in the second photo.

CorrectIndex

The indices for the correct point pairs.

Source

https://github.com/jiayi-ma/VFC

References

Ma et al. (2013) doi:10.1016/j.patcog.2013.05.017; Zhao et al. (2011) doi:10.1109/CVPR.2011.5995336


Normalize (a matrix of) vectors

Description

Normalize the data so that the mean of the vectors is 0 and the variance of the vectors is 1. Here the variance of vectors is calculated by interpreting the deviation as the Euclidean distance, which means the trace of the (population) covariance matrix is 1.

Usage

norm_vecs(x)

Arguments

x

The matrix to be normalized. Each row of x represent a vector.

Value

The normalized matrix with two attributions scale and mean, which are used for normalization.

Examples

norm_vecs(matrix(seq(1, 100), ncol = 2))

Predict method for VFC fits

Description

Predicted values based on VFC objects.

Usage

## S3 method for class 'VFC'
predict(object, newdata, ...)

Arguments

object

A VFC object generated by SparseVFC().

newdata

A vector specifying the position.

...

Not in use.

Value

A vector.

See Also

SparseVFC()


Sparse Vector Field Consensus

Description

The main function for the SparseVFC algorithm. See References for more information.

Usage

SparseVFC(
  X,
  Y,
  M = 16,
  MaxIter = 500,
  gamma = 0.9,
  beta = 0.1,
  lambda = 3,
  theta = 0.75,
  a = 10,
  ecr = 1e-05,
  minP = 1e-05,
  silent = TRUE
)

Arguments

X

The position of the vectors.

Y

The value of the vectors.

M

The number of the basis functions used for sparse approximation. Default value is 16.

MaxIter

Maximum iteration times. Default value is 500.

gamma

Percentage of inliers in the samples. This is an initial value for EM iteration, and it is not important. Default value is 0.9.

beta

Parameter of Gaussian Kernel, k(x,y)=exp(betaxy2)k(x, y) = exp(-beta*||x-y||^2). Default value is 0.1.

lambda

Represents the trade-off between the goodness of data fit and smoothness of the field. Default value is 3.

theta

If the posterior probability of a sample being an inlier is larger than theta, then it will be regarded as an inlier. Default value is 0.75.

a

Parameter of the uniform distribution. We assume that the outliers obey a uniform distribution 1/a1/a. Default Value is 10.

ecr

The minimum limitation of the energy change rate in the iteration process. Default value is 1e-5.

minP

The posterior probability Matrix P may be singular for matrix inversion. We set the minimum value of P as minP. Default value is 1e-5.

silent

Should the messages be suppressed? Default value is TRUE.

Value

A VFC object, which is a list containing the following elements:

X

A matrix of the positions of kernels.

Y

A matrix of the input vectors.

beta

The input value of beta.

V

A matrix of the estimated vectors.

C

A matrix of the coefficients of each kernel.

P

A vector of the posterior probability of the input vectors (Y) being an inlier.

VFCIndex

A vector of indices of the inliers.

sigma2

The σ2\sigma^2 of the estimations weighted by P.

References

The algorithm is described in Ma et al. (2013) doi:10.1016/j.patcog.2013.05.017. This function is translated with permission from Jiayi Ma's Matlab function at https://github.com/jiayi-ma/VFC. Also see Zhao et al. (2011) doi:10.1109/CVPR.2011.5995336 for the earlier VFC algorithm.

Examples

data(church)
set.seed(1614)
VecFld <- SparseVFC(norm_vecs(church$X), norm_vecs(church$Y) - norm_vecs(church$X))
predict(VecFld, c(0, 0))