Learn R Programming

Bagidis (version 1.0)

semimetric.BAGIDIS_2D: The BAGIDIS semi-distance for datasets of images

Description

Function for computing the Bagidis semidistance between images.

Usage

semimetric.BAGIDIS_2D(Data1, Data2 = Data1, NbROW = NULL, wk=NULL,
 lambdaV = NULL, lambdaH = NULL, Type = c( "Array","Vector", "BD", "Flex"))

Arguments

Data1
A dataset of images. The way this dataset is encoded depend on Type. See Details. There must be at least two images.
Data2
A dataset of images encoded in the same way as Data1.
NbROW
If Type = "Vector", the number of row of the matrix representation associated to the image. Otherwise ignored.
wk
The weight function. For images of size N*M, this is a vector of length N*M-1 if Type in c("Vector", "Array", "BD") and a matrix of N*M-1 row and 6 columns if Type ="Flex". In the latter case, the columns refer to the weights a
lambdaV
If Type in c("Vector", "Array", "BD"), the scaling parameter in the vertical direction. Otherwise ignored. It must be in [0,1] with lambdaV+ lambdaH
lambdaH
If Type in c("Vector", "Array", "BD"), the scaling parameter in the vertical direction. Otherwise ignored. It must be in [0,1] with lambdaV+ lambdaH
Type
One amongst ( "Array","Vector" "BD","Flex"). This indicates the way Data1 and Data2 encode the images to be compared. It also accounts for the specific form used for the BAGIDIS semidistance. See Details below.

Value

  • The matrix of Bagidis semidistances between the nrow(DATA1) ima ges of DATA1 and the nrow(DATA2) images of DATA2. Dimensions: nrow(DATA1) x nrow(DATA2) .

Details

if Type="Vector" , the images are stored as vector of values encoded by row in the matrix Data1 (and Data2. There is one row per image and one column per pixel. The parameter NROW is required to specify the shape of the image (which is then a matrix constructed row by row). If Type= "Array" , the images are stored as matrices along the third dimension of the array Data1 (or Data2). For instance, the first image is Data1[,,1]. If Type= "BD" or "Flex" , the images are encoded through their signatures (obtained from Signature_2D). Data1 (or Data2) is a list of signatures. If Type in c("Vector", "Array", "BD"), the BAGIDIS semi-distance is used in its constrained form, with a vector weight function and three scaling parameters (lambdaV along the vertical direction, lambdaH along the horizontal diirection and a scaling parameter along the detail direction) which sum to 1. See References for more details, in particular Timmermans (2012), Chapter 4, and Timmermans and Fryzlewicz (2012). The values of lambdaV and lambdaH fix the scaling in the detail direction as 1 - lambdaV - lambdaH, which must remain nonnegative. Default values are provided if wk, lambdaV and lambdaH are nonspecified, as follows: wk = log(N+1-(1:N))/log(N+1) with N the number of pixels - 1, lambdaV=lambdaH=1/3 if both are nonspecified, lambdaH= (1-lambdaV)/2 or lambdaV= (1-lambdaH)/2 if only one is supplied. If Type ="Flex", the BAGIDIS semi-distance is used in its general form with the matrix wk encoding a matrix weighting specifying the components of the signature at each rank. See References below, in particular Timmermans (2012), Chapter 4, and Timmermans and Fryzlewicz (2012). The absolute value of the detail is included in the signature, but can be ignored by defining the 6th column of wk as a vector of 0. If only two images have to be compared to each other, both must be in Data1, and Data2 = Data1.

References

The main references are
  • Timmermans C., 2012, Bases Giving Distances. A new paradigm for investigating functional data with applications for spectroscopy. PhD thesis, Universite catholique de Louvain.http://hdl.handle.net/2078.1/112451
  • Timmermans C. and von Sachs R., 2015, A novel semi-distance for investigating dissimilarities of curves with sharp local patterns, Journal of Statistical Planning and Inference, 160, 35-50.http://hdl.handle.net/2078.1/154928
  • Fryzlewicz P. and Timmermans C., 2015, SHAH: Shape Adaptive Haar wavelets for image processing. Journal of Computational and Graphical Statistics. (accepted - published online 27 May 2015)http://stats.lse.ac.uk/fryzlewicz/shah/shah.pdf
  • Timmermans C., Delsol L. and von Sachs R., 2013, Using BAGIDIS in nonparametric functional data analysis: predicting from curves with sharp local features, Journal of Multivariate Analysis, 115, p. 421-444.http://hdl.handle.net/2078.1/118369
Other references include
  • Girardi M. and Sweldens W., 1997,A new class of unbalanced Haar wavelets that form an unconditional basis for Lp on general measure spaces, J. Fourier Anal. Appl. 3, 457-474
  • Fryzlewicz P., 2007,Unbalanced Haar Technique for Non Parametric Function Estimation, Journal of the American Statistical Association, 102, 1318-1327.
  • Timmermans C., von Sachs, R. , 2010,BAGIDIS, a new method for statistical analysis of differences between curves with sharp patterns(ISBA Discussion Paper 2010/30). Url :http://hdl.handle.net/2078.1/91090
  • Timmermans, C. , Fryzlewicz, P., 2012,SHAH: Shape-Adaptive Haar Wavelet Transform For Images With Application To Classification(ISBA Discussion Paper 2012/15). Url:http://hdl.handle.net/2078.1/110529

See Also

BUUHWE_2D, SHAH, semimetric.BAGIDIS.

Examples

Run this code
im = rbind(c(1,2,3), c(5,3,2), c(1,1,2))
im2 = rbind(c(1,1,5), c(5,5,2), c(1,0,0))

Data1= rbind(as.numeric(im),as.numeric(im2))
semimetric.BAGIDIS_2D(Data1, NbROW= 3, Type= 'Vector')

Data1= abind(im,im2, along=3)
semimetric.BAGIDIS_2D(Data1, Type= 'Array')

Data1= list(Signature_2D(SHAH(im)),Signature_2D(SHAH(im2)))
semimetric.BAGIDIS_2D(Data1, Type= 'BD')

Data1= list(Signature_2D(SHAH(im)),Signature_2D(SHAH(im2)))
wk = matrix(0, nrow=nrow(Data1[[1]]), ncol=ncol(Data1[[1]]))
wk[1:2,1:5] = rep(1,10)
semimetric.BAGIDIS_2D(Data1, Type= 'Flex', wk=wk)

Run the code above in your browser using DataLab