{"id":18947146,"url":"https://github.com/qedsoftware/masked_normxcorr","last_synced_at":"2025-04-15T22:31:32.740Z","repository":{"id":10931701,"uuid":"13235968","full_name":"qedsoftware/masked_normxcorr","owner":"qedsoftware","description":"Computes masked cross-correlation of two images using fast Fourier methods. Compatible with OpenCV!","archived":false,"fork":false,"pushed_at":"2015-10-22T05:18:07.000Z","size":352,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"github","last_synced_at":"2025-03-29T03:51:17.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qedsoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-01T05:52:56.000Z","updated_at":"2024-04-17T13:58:01.000Z","dependencies_parsed_at":"2022-09-03T00:11:48.850Z","dependency_job_id":null,"html_url":"https://github.com/qedsoftware/masked_normxcorr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Fmasked_normxcorr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Fmasked_normxcorr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Fmasked_normxcorr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qedsoftware%2Fmasked_normxcorr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qedsoftware","download_url":"https://codeload.github.com/qedsoftware/masked_normxcorr/tar.gz/refs/heads/github","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249166102,"owners_count":21223384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T13:09:04.703Z","updated_at":"2025-04-15T22:31:27.727Z","avatar_url":"https://github.com/qedsoftware.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"DESCRIPTION\n===============\n\n[![Build Status][branch_github]][repo]\n\n[repo]: https://travis-ci.org/themathpath/masked_normxcorr\n[branch_github]: https://travis-ci.org/themathpath/masked_normxcorr.svg?branch=github\n\nmasked_normxcorr efficiently computes the cross-correlation between two images, each of \nwhich can be independently masked, using fast Fourier techniques. In simple signal\nprocessing terms, we are computing the cross-correlation of a 2D discrete signal with\na larger 2D discrete signal, while also allowing the user to specify arbitrarily shaped\nsupports --- henceforth referred to as masks --- for each signal. This computation\ncan be executed directly in the spatial domain, but the Fourier Transform makes it\npossible to do this computation much faster. Our procedure follows the algorithms \ndescribed in the following paper:\n\n    Dirk Padfield. \"Masked Object Registration in the Fourier Domain\". \n    IEEE Transactions on Image Processing, vol.21(5), pp. 2706-2718, 2012. \n\nDr. Padfield provides implementations in ITK and MATLAB. Our contribution is to \nprovide an implementation that is compatible with OpenCV, and we hope to integrate\nthis code within OpenCV, as it addresses a need that is currently unmet.\n\n\nINSTALLATION\n===============\nRequirements: opencv, boost, cmake \n\nOn Mac OS X:\n\n    # Homebrew installation: http://brew.sh/\n    brew tap homebrew/science\n    brew install opencv boost cmake\n\nOn Debian systems:\n\n    # OpenCV installation: https://help.ubuntu.com/community/OpenCV\n    sudo apt-get install libopencv-dev cmake\n    sudo apt-get install libboost-program-options-dev\n    sudo apt-get install libboost-system-dev\n    sudo apt-get install libboost-filesystem-dev\n\nOn Windows systems:\n\n    Download the latest stable version of OpenCV library from official site http://opencv.org/ and install it.\n    Download and install boost from http://www.boost.org/.\n    Add CMake option `CMAKE_PREFIX_PATH` or `OpenCV_DIR` to locate OpenCV:\n      -DCMAKE_PREFIX_PATH=\u003c...\u003e\\opencv\\build\n    Add CMake options `BOOST_ROOT` to locate Boost:\n      -DBOOST_ROOT=\u003c...\u003e\n\nProcedure for building code using CMake:\n\n    [masked_normxcorr]$ cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release\n    [masked_normxcorr]$ cmake --build build --config Release\n\nAfterwards, the tree structure should look like this:\n\n    [~/masked_normxcorr]$ tree -L 2\n    .\n    ├── CMakeLists.txt\n    ├── README.md\n    ├── build\n    │   ├── CMakeCache.txt\n    │   ├── CMakeFiles\n    │   ├── Makefile\n    │   ├── cmake_install.cmake\n    │   └── src\n    └── src\n        ├── CMakeLists.txt\n        ├── Doxyfile\n        ├── masked_normxcorr.cpp\n        ├── normxcorr2_masked.cpp\n        └── normxcorr2_masked.hpp\n\n(For more information on using CMake, check out http://www.cmake.org/cmake/help/cmake_tutorial.html)\n\nEXAMPLES\n===============\nIn this example, we will use maximization of masked cross-correlations to locate the Batman logo in a scene.\nThe images we will use for this example are shown below, and can be found in data folder.\n\nRun result executable masked_normxcorr with test images from data folder by ctest:\n\n    [masked_normxcorr]$ cd build\n    [masked_normxcorr/build]$ ctest -VV -C Release\n\nThis is equivalent to:\n\n    [masked_normxcorr/build]$ ./masked_normxcorr -F ../data/fixedImage.jpg -f ../data/fixedMask.png -M ../data/movingImage.jpg -m ../data/movingMask.png\n\nType ./masked_normxcorr -h for a full help menu.\n\n\nfixedImage.jpg (scene):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/fixedImage.jpg)\n\nfixedMask.png (scene mask):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/fixedMask.png)\n\nmovingImage.jpg (template):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/movingImage.jpg)\n\nmovingMask.png (template mask):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/movingMask.png)\n\nNote that the Batman logo in the template does not exactly match the logo on Batman's chest in the scene.\nAlso, the Batman logo in the template is red outside of the oval logo, which would throw off a standard cross-correlator that uses rectangular supports.\nThe oval template mask allows us to ignore this red area.\n\nMasked normalized cross-correlation using Fourier methods:\n\n    Fixed image (scene): fixedImage.jpg: [690 x 800]\n    Fixed mask (scene mask): fixedMask.png: [690 x 800]\n    Moving image (template): movingImage.jpg: [104 x 63]\n    Moving mask (template mask): movingMask.png: [104 x 63]\n    Dimensions of combined image: 862 x 793\n    Optimal larger dimensions for fast DFT: 864 x 800\n        Calculated cross-correlation for one channel in 806.512 ms\n        Calculated cross-correlation for one channel in 776.407 ms\n        Calculated cross-correlation for one channel in 768.965 ms\n    Total cross-correlation time for all channels: 2451.68 ms\n\n    Results for channel 0 ...\n    #1: 0.750705 (220,404)\n    #2: 0.746034 (219,404)\n    #3: 0.727210 (219,405)\n    #4: 0.720789 (219,403)\n    #5: 0.719367 (220,405)\n    maximum value: 0.750705 @ (y,x)=(404,220)\n    minimum value: -0.383996 @ (y,x)=(398,349)\n    Writing image xcorr_0.jpg ... \n    Writing numerical matrices xcorr_0_correlation_matrix.tsv and xcorr_0_overlap_matrix.tsv ... \n\n    Results for channel 1 ...\n    #1: 0.858291 (219,404)\n    #2: 0.840575 (219,405)\n    #3: 0.825339 (220,404)\n    #4: 0.821008 (219,403)\n    #5: 0.803989 (220,405)\n    maximum value: 0.858291 @ (y,x)=(404,219)\n    minimum value: -0.482819 @ (y,x)=(389,197)\n    Writing image xcorr_1.jpg ... \n    Writing numerical matrices xcorr_1_correlation_matrix.tsv and xcorr_1_overlap_matrix.tsv ... \n\n    Results for channel 2 ...\n    #1: 0.877009 (219,404)\n    #2: 0.853381 (219,405)\n    #3: 0.848980 (220,404)\n    #4: 0.841817 (219,403)\n    #5: 0.824849 (220,405)\n    maximum value: 0.877009 @ (y,x)=(404,219)\n    minimum value: -0.552982 @ (y,x)=(390,200)\n    Writing image xcorr_2.jpg ... \n    Writing numerical matrices xcorr_2_correlation_matrix.tsv and xcorr_2_overlap_matrix.tsv ... \n\n    Writing blended correlation matrix xcorr.jpg ...\n    #1: 0.827111 (219,404)\n    #2: 0.808342 (220,404)\n    #3: 0.807056 (219,405)\n    #4: 0.794538 (219,403)\n    #5: 0.782735 (220,405)\n    maximum value: 0.827111 @ (y,x)=(404,219)\n    minimum value: -0.441289 @ (y,x)=(398,347)\n\nThe resulting output images are shown below. Note that we ignore all areas where the intersection of the template mask with the scene mask has an area smaller than that of the template mask. \n\nxcorr_0.jpg (cross-correlation for blue channel):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/xcorr_0.jpg)\n\nxcorr_1.jpg (cross-correlation for green channel):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/xcorr_1.jpg)\n\nxcorr_2.jpg (cross-correlation for red channel):\n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/xcorr_2.jpg)\n\nLastly, here is a composite image that averages the cross-correlation images from all three color channels:\n\nxcorr.jpg (average of cross-correlation matrix from all 3 channels) \n\n![Screenshot](http://qe-design.com/masked_normxcorr/images/xcorr.jpg)\n\n\nLICENSE \n===============\n/***********************************************************************\n * Software License Agreement (BSD License)\n *\n * (c) 2013 Quantitative Engineering Design (http://qed.ai)\n * Authors: William Wu, Jiehua Chen, Zhang Zhiming, Michał Łazowik\n * Primary Contact: William Wu (w@qed.ai)\n *\n * THE BSD LICENSE\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *************************************************************************/\n\n\n\nAUTHORS\n===============\nWilliam Wu, Jiehua Chen, Zhang Zhiming, Michał Łazowik\n\nPrimary contact: w@qed.ai \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedsoftware%2Fmasked_normxcorr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqedsoftware%2Fmasked_normxcorr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedsoftware%2Fmasked_normxcorr/lists"}