Speed up your image registration (template matching) code in MATLAB

Recently, I’ve encounter the problem of finding a template in an image, which is a common issue in image registration or computer vision.

With the built-in function “normxcorr2″ in MATLAB, it is rather easy to write a program to do this. However, the performance is not that great.

Luckily, I came across the following discussion by Daniel Eaton:
“How to do Normalized Cross-Correlation Fast”

By wrapping the C++ code from OpenCV project and making it available as a MATLAB MEX-file, Daniel claims that he achieved a huge performance boost.

I was a bit suspicious at first, but decided to give it a shot. As I am using a n Apple PowerMac G5, I found out that I need to compile the MEX-file on Mac OS X, which turns out not be a trivial task (see my dedicated post).

Anyway, the outcome really surprised me. I can assure you now, that it is well worth the time and trouble to compile the MEX-file!

By embedding a random grayscale pattern in a larger image, I was able to benchmark the performance on an Apple PowerMac G5 (Dual 2.5GHz PowerPC CPUs). Take a look:


The template stays the same (100×100 pixels), while the size of search image is increasing (from 200×200 to 800×800, indicated by the X-axis). The Y-axis shows the cpu time. Clearly, there is a speedup of 15x – 20x, using the compiled MEX-file over the built-in “normxcorr2″!

Life is better, right? :)

71 Responses to “Speed up your image registration (template matching) code in MATLAB”

  1. anc Says:

    ya its very good n more efficient.

  2. saarah ahmed Says:

    i need to align face images of different subjects so that the centerpoints of eyes are at same fixed location in all images.
    some faces are not frontal but at a slight angle (eg. 20 degrees) and i need them all to be frontal.
    can you help me?

  3. computer repair Says:

    computer repair…

    Backing up files continuously is the first defense against data loss, but the software will recover lost, fragmented, deleted, or destroyed files before they are written over with new ones. If you lose an important file, data recovery software can find…

  4. Mason Parker Says:

    Data Recovery is a very costly option that is why you should always check your storage media for any signs of wear and tear.”";

  5. Haywood Maysonet Says:

    This page is very helpful for me to choose the viable product.

  6. Caroline Bryant Says:

    data recovery is a very costly option, always make a regular backups.-.’

  7. Evie Roberts Says:

    data recovery is very very expensive so do make regular backups of important files;.;

  8. spokane data recovery Says:

    Perfect! this fixed our problem on the job. I can’t wait to read more =D

  9. Isaiah Roberts Says:

    data entry jobs are very common on the internet but the paying rate is quite small .-’

  10. Zachary Evans Says:

    data recovery is a serious task and cost a hell lot of dollars too”`,

  11. Towel Rails Says:

    of course data entry services are very expensive that is why always make a backup of your files ;”.

  12. Penus Enlargement Says:

    If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

  13. heated towel rails for bathrooms Says:

    Usually I don’t learn article on blogs, however I wish to say that this write-up very compelled me to try and do so! Your writing taste has been amazed me. Thank you, quite nice post.

  14. website builder Says:

    I will right away clutch your rss as I can not find your e-mail subscription link or newsletter service. Do you have any? Kindly allow me understand in order that I may subscribe. Thanks.

  15. produccion madrid barata Says:

    Woah this kind of weblog is definitely great i prefer studying your articles. Keep up to date the excellent paintings! You now know, many need close to just for this info, you could potentially help all of them considerably.

  16. John Smith Says:

    I wanted to write a little comment to support you.
    John Smith http://dumm1.co.uk

  17. freecreditscore.com Says:

    Unfortunately, especially in today’s real estate market where foreclosures and short sales are on the rise,
    the rules have changed and to ensure you protect yourself during
    the home buying experience, these five tips will guarantee the process goes a little
    easier. Many company’s offer free email accounts and this
    will save you from cleaning up hundreds of junk messages in your primary
    email account. it might be wise to get a report before and after
    these major events.

  18. https://Howaboutwe.zendesk.com/entries/47276274-Get-Huge-Variety-Of-Guys-Footwear-Online-In-Dubai Says:

    Hello i am kavin, its my first time to commenting anyplace, when i read this piece
    oof writing i thought i could also make comment due to this good piece of writing.

  19. hazelton drug rehab Says:

    It’s hard to come by educated people for this topic, however, you sound like
    you know what you’re talking about! Thanks

    My blog :: hazelton drug rehab

  20. recovery toronto process Says:

    Great article.

  21. spanish property investments Says:

    Quality content is the important to attract the viewers to visit
    the web site, that’s what thiks site is providing.

  22. bathroom remodeling Buffalo NY Says:

    Incredible points. Great arguments. Keep up the good work.

    My page bathroom remodeling Buffalo NY

  23. Lauri Stenroth Says:

    Hi, I have problems compiling Daniel Eaton’s normxcorr2 code for OS X. Could you kindly send me the compiled normxcorr2_mex.mexmaci64 for me if you happen to have that.


  24. telewizja naziemna lista kanałów kielce Says:

    I pay a quick visit each day some blogs and sites to read articles or
    reviews, but this webpage offers feature based articles.

  25. http://pringsewu.kemenag.go.id/halkomentar-162-prestasi-tiada-henti-dua-siswa-berhasil-harumkan-m... Says:

    Aw, this was an extremely nice post. Finding the time and actual effort to make a very good article?
    but what can I say? I hesitate a lot and never seem to get anything done.

  26. Jonah Says:

    Eu achei muito completo e também recomendaria para quem está à procura de respostas para se
    livrar DEFINIVAMENTE das estrias.

  27. Kitchen Design Says:

    I loved as much as you’ll receive carried out right here.

    The sketch is tasteful, your authored material stylish.
    nonetheless, you command get bought an edginess over that you
    wish be delivering the following. unwell unquestionably
    come further formerly again as exactly the same nearly a
    lot often inside case you shield this increase.

  28. read me Says:

    Good day I am so glad I found your web site, I really found you by mistake, while I was researching on Aol for something else, Regardless I am here now and would
    just like to say many thanks for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t have time to read through it
    all at the minute but I have bookmarked it and also
    added in your RSS feeds, so when I have time I will be back to
    read more, Please do keep up the fantastic work.

  29. hdmi cord At walmart Says:

    Hence, always insist about the high-quality and affordable hdmi cord At walmart cables.

    Toshiba Regza 42AV635DB 42-inch Widescreen Full HD 1080p LCD TV
    with Freeview and Resolution +. Hdmi to rca cable
    walmart Buying ideas: Element Video Cables Pick the premier quality
    connections amongst parts for max signal transfer.

    That’s larger than most laptop screens just being a quick comparison. This is merely the second calendar year Vizio has manufactured Blu-ray

  30. rca cable best buy made Says:

    This software enables the operator to look at current and
    archive video (approximately 64 video channels), supports alarm outputs
    and PTZ-cameras operation control. WTR-XLPE insulation materials lead with a much longer in-service
    life for power cables. Dvi to hdmi rca cable best buy made review Which means you
    might connect both equally HDMI Outputs to varied visual
    shows in a similar time and in many cases configured the crooks to unique video resolutions.

    Panasonic have really put thought into your TXP50VT30 to supply you with
    the best image quality possible. We think it can be money wisely spent because the very first product we’ve sold features a 4.

  31. best poket pussy Says:

    Once you happen to be ready, your significant other should
    cover their finger inside the lubricant and slowly insert it into the anus.
    hard to define, at least it can be difficult to define for me.
    What type of pussy is the best poket pussy
    When I walked onto her, to determine what she wanted,
    she got really near me, and started squeezing my penis.

    There are lots of more other varieties and brand new
    ones keep coming all any time. To increase the chances of
    having a newborn girl, your pregnant Sim will ought to eat 3 watermelons.

  32. outdoor ip camera review 2016 Says:

    Though this can be an important thing to
    get noted that every one of the registry cleaner usually are not same and hardly
    any of them work fine and perform their intended task successfully.
    Starting which has a traditional candy-bar form factor that may be sure to be a classic, the E62
    is available in two corporate-savvy colors: metal grey and golden aluminum.
    Also, this gives overall flexibility to hide the
    digital outdoor ip camera review 2016 thus
    thieves isn’t going to notice you have a cellular home home security camera

    Setting up a Wi-Fi connection to some network is effortless and is usually completed in below two minutes on many
    older Android devices. Chinavasion sells Wi – Fi Baby Monitor,
    Wireless Security Camera System and Rugged Phone from China.

  33. still Says:

    Be advised that some mods and hacks will disrupt other aspects of one’s game sometimes
    too, so always know the way to disable or uninstall something
    before installing it for your game. And when you’re nihilistic, it seems like closer
    in our reality than other epic fantasies, a truer reflection from the ugly emotions and attitudes obtained in everyday life.
    Do pocket pussys work Also it reflect that persons accepted five finger
    footwear as regular shoes.

    But Davis was in a position to use the filibuster to propel her into your Democratic nomination for governor of Texas.
    By being familiar with what’s out there, you are
    going to feel considerably more comfortable in a adult store keep that
    at heart, each of the people in you’ll find there with the same

    my blog – still

  34. เสาเข็มเจาะ กับเสาเข็มตอก Says:

    Thank you for the auspicious writeup. It actually was once a leisure account it.
    Glance advanced to more introduced agreeable from you!
    However, how could we be in contact?

  35. Lindsey Says:

    Très satisfait du service, rendez-vous en jours et explications très claires lors de l’intervention à
    mon domicile je recommande vivement Franck Dépannage!

  36. http://www.activityhack.com/ Says:

    It is truly a nice and useful piece of information.
    I am happy that you just shared this helpful info with
    us. Please stay us informed like this. Thanks for sharing.

  37. Latest Bank Jobs Says:

    I am really enjoying the theme/design of your web
    site. Do you ever run into any browser compatibility issues?
    A few of my blog readers have complained about my website not working correctly
    in Explorer but looks great in Firefox. Do you have any ideas to help fix this issue?

  38. jouets et jeux en ligne Says:

    Sauf, ce que je préfère, c’est les jouets.

  39. จำหน่ายเครื่องมือมากมายหลากหลาย สว่านไฟฟ้า สว่านไฟฟ้าไร้สาย เครื่องขัดกระดาษทราย เครื่อ Says:

    It’s actually a cool and helpful piece of info. I’m satisfied that you simply shared this useful info with us.
    Please keep us up to date like this. Thank you for sharing.

  40. จำหน่ายเครื่องมือมากมายหลากหลาย สว่านไฟฟ้า สว่านไฟฟ้าไร้สาย เครื่องขัดกระดาษทราย เครื่อ Says:

    Hi, i feel that i noticed you visited my blog thus i
    came to return the choose?.I’m attempting to in finding things to enhance my
    web site!I guess its adequate to use a few of your

  41. istgah.com Says:

    Good day very cool website!! Man .. Excellent ..
    Superb .. I will bookmark your website and take the feeds additionally?
    I’m happy to seek out numerous helpful info here within the publish, we’d
    like work out extra techniques in this regard, thank
    you for sharing. . . . . .

  42. Lila Says:

    Excellent blog you have here.. It’s hard to find excellent writing like yours nowadays.
    I really appreciate individuals like you! Take care!!

  43. Blair Says:

    certainly like your web site but you need to test the spelling on several of your posts.
    Several of them are rife with spelling problems and I find it very
    bothersome to tell the truth nevertheless I’ll surely come back again.

  44. Desentupidora São Braz Curitiba Says:

    Its not my first time to pay a quick visit this website, i am visiting this
    website dailly and get good information from here every day.

  45. www.beezeen.com Says:

    Super locksmith tamla (http://www.beezeen.com)
    10833 Sakonnet River Dr, Tampa, FL 33615
    (813) 285-7477

  46. Logodesignsepanta.Sunblog.ir Says:

    This is my first time visit at here and i am in fact pleassant to read everthing at alone

  47. in.pinterest.com Says:

    Excellent website you have here but I was wanting to know
    if you knew of any community forums that cover the same topics discussed
    here? I’d really like to be a part of community where I can get feedback from other
    knowledgeable individuals that share the same interest.
    If you have any recommendations, please let me know.

    Thank you!

    my blog – commercial locksmith houston (in.pinterest.com)

  48. a Says:

    I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an shakiness over that you wish be delivering the following.
    unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this increase.

  49. الکترونیک فروشگاه Says:

    The Electronic tools Cost is offered in four colors; black,
    slate, blue, and burgundy.

    my homepage: الکترونیک فروشگاه

  50. Rivasland.Com Says:

    Hallo zusammdn I melden Siie sich an Ihree neue Slideshows täglich.
    Ihree Erzähl Stil iist witzig, it up!

  51. Sarah Says:

    Es ist diee besten Zeit, ein paar Pläne für die Zukunft zu machen und es ist es Zeit, um glücklich zzu sein.Ich habe lesen diesen Beitrag und wenn
    ich könnte Wunsch, schlage vor, Sie einige interessante Dinge oder Beratung.

    Vielleicht kann schreiben nächsten Artikel, diee sich auf diesen Artikel.
    I Wunsch, noch Dinge über sie!

  52. bookletdownload Says:

    interesting ! Thanks for information !

  53. scam thai Says:

    scammer in thailand scam thai restaurant thailand taxi scam scam in thai
    scam thai https://siam-shipping.com/

  54. 파워볼 Says:

    낯선 지역에 방문했을 때 근처의 로또 판매점을 찾기란 쉽지가 않습니다.

    로또 판매소나 복권방 등이 눈에 띈다면 쉽게 구매할 수가 있겠지만 낯선 지역에서는 평소에 잘
    보이던 곳도 안보이기 십상이죠. 근처에 GS25 편의점이나 CU 편의점이 있다면 로또를 판매하고 있을 수도 있겠지만 정확하게 판매하고
    있을지는 모르죠. 이럴 경우 쉽게 로또 판매점을 찾는 방법이 있습니다.
    우선 기본적으로 로또 판매점을 인터넷 상에서 조회를 할 수가 있습니다.
    현재는 Lotto6/45, 연금복권520, 즉석복권 스피또가 동행복권으로 통합되어 운영중인데 동행복권 홈페이지에 방문하시면 판매점
    조회가 가능합니다. 동행복권 사이트 하단에 보시면 판매점이라는 메뉴가 있는데 이
    메뉴를 통해 판매점 위치 확인이 가능하죠.
    하지만 불편한 점이 위치 조회만 가능할 뿐 주변에 있는 판매점을
    바로 알려주지는 않는다는 점입니다.

    위에 보시다시피 해당 지역에 있는 로또 판매점을 나열해 주는 정도만 가능합니다.
    당장 근처에 있는 로또 판매점을 찾고 싶은데 일일이 주소를 검색 하면서 찾기란 쉽지가 않죠.
    주변에 있는 로또 판매점의 위치를 한 눈에 볼 수만 있다면
    찾기가 훨씬 쉬워질 것입니다. 이런 기능을
    동행복권 모바일앱에서 제공하고 있습니다.
    동행복권 모바일앱은 구글플레이 또는 애플 앱스토어에서 동행복권을 검색하면 쉽게 찾을 수가 있습니다.
    동행복권 앱을 설치하시면 최초 카메라와 사용자 위치
    정보에 대한 사용 권한을 요구합니다. 카메라의 경우에는 당첨확인과 자신의 로또번호를 저장하기 위한 용도이고 사용자 위치 정보는 앞서
    언급했던 근처 로또 판매점을 찾기 위하여 요구되는 기능입니다.

  55. Lace Wigs Says:

    Lace Wigs…

    The Geeky Junkyard of kingler…

  56. Sybil Says:

    An experienced mind traumatic brain injury attorney florida (Sybil) attorney might have the ability to assist.

  57. Floor Tile Grout Cleaning Machine Rental Says:

    Floor Tile Grout Cleaning Machine Rental…

    The Geeky Junkyard of kingler » Blog Archive » Speed up your image registration (template matching) code in MATLAB…

  58. Tasha Says:

    I think that what you posted was actually very logical.
    But, what about this? suppose you added a little content?
    I am not suggesting your content is not good,
    however suppose you added a title that grabbed a person’s attention? I mean The Geeky Junkyard of kingler »
    Blog Archive » Speed up your image registration (template matching)
    code in MATLAB is a little boring. You might look at Yahoo’s front page and
    note how they create news headlines to grab viewers to open the links.
    You might add a video or a related picture or two to get people excited about what you’ve written. Just my opinion, it could
    bring your posts a little livelier.

  59. German courses Says:

    We do agree with all the principles you might have made available with your posting. They can be extremely effective and may undoubtedly function. Even now, the actual articles are so shorter instructor can. Could you please increase these folks a bit coming from pursuing time period? Information submit. We do agree with all the principles you might have made available with your posting. They can be extremely effective and may undoubtedly function. Even now, the actual articles are so shorter instructor can. Could you please increase these folks a bit coming from pursuing time period? Information submit.

  60. www.nouenko.free.fr Says:

    An impressive share! I have just forwarded this onto a
    colleague who was conducting a little research on this.

    And he in fact ordered me breakfast simply because I found it for him…
    lol. So allow me to reword this…. Thank YOU for the
    meal!! But yeah, thanx for spending time to discuss this issue here on your blog.http://www.nouenko.free.fr/forums/profile.php?id=379160

  61. tips and tricks Says:

    tips and tricks…

    The Geeky Junkyard of kingler » Blog Archive » Speed up your image registration (template matching) code in MATLAB…

  62. Dalton Says:

    An impressive share! I’ve just forwarded this onto a colleague who had been conducting
    a little homework on this. And he in fact ordered
    me lunch because I stumbled upon it for him…
    lol. So let me reword this…. Thank YOU for the
    meal!! But yeah, thanks for spending some
    time to discuss this topic here on your blog.

  63. m88 Says:


    The Geeky Junkyard of kingler » Blog Archive » Speed up your image registration (template matching) code in MATLAB…

  64. gpuhub render 3d giá rẻ Says:

    I was recommended this web site by means of my cousin. I’m no longer positive whether this submit is written by him as nobody else understand such distinctive approximately my problem.
    You’re wonderful! Thank you!

  65. nhấp vào bài viết sắp tới Says:

    nhấp vào bài viết sắp tới…

    The Geeky Junkyard of kingler » Blog Archive » Speed up your image registration (template matching) code in MATLAB…

  66. https://triberr.com/yudianto Says:

    Please let me know if you’re looking for a article author for your blog.
    You have some really great articles and I think I
    would be a good asset. If you ever want to take some of the load off, I’d love to
    write some material for your blog in exchange for a link back to mine.
    Please blast me an e-mail if interested. Regards!

  67. https://meunicanggih.blogspot.com Says:

    What’s up it’s me, I am also visiting this web page regularly, this site is really good and the viewers are really sharing fastidious thoughts.

  68. credit repair Says:

    My brother recommended I may like this blog. He was once entirely
    right. This put up actually made my day. You can not consider just
    how much time I had spent for this info! Thank you!

  69. Micheal Says:

    great put up, very informative. I wonder why the other
    experts of this sector don’t realize this. You must proceed your writing.
    I am confident, you’ve a huge readers’ base already!

  70. Homer Baynes Says:

    You have a really great website. Let’s connect:

  71. Lavonda Says:

    The media control along with a stylish Keyboard turn it
    into a class aside from other laptops when it comes to
    looks and design. Accsense Product Manager Dana Kennedy
    explains his enthusiasm: “Increasingly we’re centering on expanding the capacity of our Accsense systems towards the market’s specific needs, in order that we’re now storing the servers ourselves and offering direct support. Keep all your household in the loop by using your Smart – Phone along with a video streaming application to reside stream important events.

    my website Lavonda

Leave a Reply