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:

compare

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? :)

34 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:

    hi!
    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.

    Thanks,
    Lauri

  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
    Players.

  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
    program.

    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
    reason.

    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?

Leave a Reply