Template Matching with Deformable Diversity Similarity
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Template Matching with Deformable Diversity Similarity

Itamar Talmi, Roey Mechrez, Lihi Zelnik-Manor. to appear in CVPR 2017 (spotlight)

[The Project Page]

DDIS - MATLAB Mex Version 1.0 (2017-02-21) Copyright 2006-2017 Itamar Talmi and Roey Mechrez Licensed for noncommercial research use only.


This code implements a fast Template Matching in the wild algorithm.

The algorithm solves the following problem: for each image I and a template T we calculate likelihood map of the template location in the image. We calculate the map using a raster scan over the image. DDIS (Deformable Diversity Similarity) used as the similarity measure between each sub window and the template. For more information see:

  title={Template Matching with Deformable Diversity Similarity},
  author={Talmi, Itamar and Mechrez, Roey and Zelnik-Manor, Lihi},
  journal={arXiv preprint arXiv:1612.02190},

[arXiv] Please cite these paper if you use this code in an academic publication.


DDIS mex/C++ code: We provide rebuild mex functions in the bin folder, tested using MATLAB 2016a and VS12 (2013) If you need to rebuild and compile see Installation.txt inside the DDIS_code folder


  • TreeCANN: kd tree Coherence Approximate Nearest Neighbor algorithm see [TreeCANN code] (provided under utils)

(optional) for deep features


To run one pair of images use


to run on the entire dataset use


core functions:

  • computeDDIS.m - using RGB patches
  • computeDDIS_deep.m - using deep features patches


This software is provided under the provisions of the Lesser GNU Public License (LGPL). see: http://www.gnu.org/copyleft/lesser.html.

This software can be used only for research purposes, you should cite the aforementioned papers in any resulting publication.

The Software is provided "as is", without warranty of any kind.

Code References

[1] Dekel, Tali, Shaul Oron, Michael Rubinstein, Shai Avidan, and William T. Freeman. "Best-buddies similarity for robust template matching." In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2021-2029. 2015. url

[2] Olonetsky, Igor, and Shai Avidan. "Treecann-kd tree coherence approximate nearest neighbor algorithm." In European Conference on Computer Vision, pp. 602-615. Springer Berlin Heidelberg, 2012. url

[3] uja, Marius, and David G. Lowe. "Fast approximate nearest neighbors with automatic algorithm configuration." VISAPP (1) 2, no. 331-340 (2009): 2. url

[4] MatConvNet: CNNs for MATLAB. url

Version History

  • Wish list (to be added soon): Scale and aspect ratio

  • Version 1.0 (2017-02-21) Initial Release