Converts an NN-field to its Similarity Matrix.
This is a MATLAB implementation of converting nn-field obtained from Patchmatch(@patchmatch) to its similarity matrix.
Salient Features:
- Runs on int32 NN-field.
- Handles different types of weights (0/1 and exponential)
- Handles texture-based weights
- External thresholding passed as an argument.
- Works with any given mask passed as an argument.
Format:
The command line format is as follows. sm = nnfield2similarity(nnf, wttype, sigma, normalized, make_symm, patchsize, alpha, threshold, mask, ref_img_size)nnf - nearest neighbour field
wttype- 0 - one-type (default) , 1 - gaussian(exp)
sigma - exponential wt sigma (default - 256)
normalized - 0/1 (default - 0)
make_symm - 0/1 (default - 0)
patchsize - size of search patch (default - 1)
alpha - for diagonal elements (default - 1.0)
threshold - for limiting similar patches (default - DBL_MAX)
mask - patch weight mask (default - center dot)
ref_img_size - reference image size (2X1) (default - same as nnf)
sm - output similarity matrix
Examples:
img = double(imresize(imread('lena.png'),0.25));
patchsize = 5; nn = 10;
cnn = patchmatch(img, [], patchsize, nn, 20, [], 1, [], [], [], 2);
sm = nnfield2similarity(cnn, 1, 10, [], [], patchsize);

Authors and Contributors
Sk. Mohammadul Haque (@mohammadul).
Support or Contact
Check out the files in the repository for more details.