├── ciratefi ├── stdafx.h ├── ReadMe.txt ├── stdafx.cpp ├── ciratefi.rc ├── ciratefiApp.h ├── ciratefiDlg.h ├── targetver.h ├── ciratefi.vcproj ├── ciratefiApp.cpp ├── ciratefiDlg.cpp ├── res │ ├── ciratefi.ico │ └── ciratefi.rc2 ├── ciratefiAlgorithm.cpp ├── Resource.h └── ciratefiAlgorithm.h ├── README.md ├── ciratefi.sln └── .gitignore /ciratefi/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/stdafx.h -------------------------------------------------------------------------------- /ciratefi/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ReadMe.txt -------------------------------------------------------------------------------- /ciratefi/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/stdafx.cpp -------------------------------------------------------------------------------- /ciratefi/ciratefi.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefi.rc -------------------------------------------------------------------------------- /ciratefi/ciratefiApp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefiApp.h -------------------------------------------------------------------------------- /ciratefi/ciratefiDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefiDlg.h -------------------------------------------------------------------------------- /ciratefi/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/targetver.h -------------------------------------------------------------------------------- /ciratefi/ciratefi.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefi.vcproj -------------------------------------------------------------------------------- /ciratefi/ciratefiApp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefiApp.cpp -------------------------------------------------------------------------------- /ciratefi/ciratefiDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefiDlg.cpp -------------------------------------------------------------------------------- /ciratefi/res/ciratefi.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/res/ciratefi.ico -------------------------------------------------------------------------------- /ciratefi/res/ciratefi.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/res/ciratefi.rc2 -------------------------------------------------------------------------------- /ciratefi/ciratefiAlgorithm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andy79923/ciratefi/HEAD/ciratefi/ciratefiAlgorithm.cpp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ciratefi 2 | ======== 3 | 4 | Ciratefi (Circular, Radial and Template-Matching Filter) is a template matching technique invariant to rotation, scale, translation, brightness and contrast. 5 | -------------------------------------------------------------------------------- /ciratefi.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ciratefi", "ciratefi\ciratefi.vcproj", "{8D211BEE-FF07-4FFE-94F9-65861203FFF3}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {8D211BEE-FF07-4FFE-94F9-65861203FFF3}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {8D211BEE-FF07-4FFE-94F9-65861203FFF3}.Debug|Win32.Build.0 = Debug|Win32 14 | {8D211BEE-FF07-4FFE-94F9-65861203FFF3}.Release|Win32.ActiveCfg = Release|Win32 15 | {8D211BEE-FF07-4FFE-94F9-65861203FFF3}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /ciratefi/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ciratefi.rc 4 | // 5 | #define IDM_ABOUTBOX 0x0010 6 | #define IDD_ABOUTBOX 100 7 | #define IDS_ABOUTBOX 101 8 | #define IDD_CIRATEFI_DIALOG 102 9 | #define IDR_MAINFRAME 128 10 | #define IDC_BUTTONLOADSOURCE 1000 11 | #define IDC_PICTURESOURCEIMAGE 1001 12 | #define IDC_BUTTONLOADTEMPLATE 1002 13 | #define IDC_PICTURETEMPLATE 1003 14 | #define IDC_BUTTON1 1004 15 | #define IDC_BUTTONMATCH 1004 16 | 17 | // Next default values for new objects 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 129 22 | #define _APS_NEXT_COMMAND_VALUE 32771 23 | #define _APS_NEXT_CONTROL_VALUE 1005 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | *.pubxml 98 | 99 | # NuGet Packages Directory 100 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 101 | #packages/ 102 | 103 | # Windows Azure Build Output 104 | csx 105 | *.build.csdef 106 | 107 | # Windows Store app package directory 108 | AppPackages/ 109 | 110 | # Others 111 | sql/ 112 | *.Cache 113 | ClientBin/ 114 | [Ss]tyle[Cc]op.* 115 | ~$* 116 | *~ 117 | *.dbmdl 118 | *.[Pp]ublish.xml 119 | *.pfx 120 | *.publishsettings 121 | 122 | # RIA/Silverlight projects 123 | Generated_Code/ 124 | 125 | # Backup & report files from converting an old project file to a newer 126 | # Visual Studio version. Backup files are not needed, because we have git ;-) 127 | _UpgradeReport_Files/ 128 | Backup*/ 129 | UpgradeLog*.XML 130 | UpgradeLog*.htm 131 | 132 | # SQL Server files 133 | App_Data/*.mdf 134 | App_Data/*.ldf 135 | 136 | # ========================= 137 | # Windows detritus 138 | # ========================= 139 | 140 | # Windows image file caches 141 | Thumbs.db 142 | ehthumbs.db 143 | 144 | # Folder config file 145 | Desktop.ini 146 | 147 | # Recycle Bin used on file shares 148 | $RECYCLE.BIN/ 149 | 150 | # Mac crap 151 | .DS_Store 152 | -------------------------------------------------------------------------------- /ciratefi/ciratefiAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef __CIRATEFIALGORITHM_H__ 2 | #define __CIRATEFIALGORITHM_H__ 3 | 4 | 5 | 6 | namespace Ciratefi 7 | { 8 | class CorrData 9 | { 10 | public: 11 | CorrData(int row, int col, int scale, int angle, double coefficient):_row(row),_col(col),_scale(scale),_angle(angle),_coefficient(coefficient){} 12 | double GetCoefficient(){return _coefficient;} 13 | int GetScale(){return _scale;} 14 | int GetAngle(){return _angle;} 15 | int GetRow(){return _row;} 16 | int GetCol(){return _col;} 17 | private: 18 | double _coefficient; 19 | int _scale; 20 | int _angle; 21 | int _row; 22 | int _col; 23 | }; 24 | class CiratefiData 25 | { 26 | public: 27 | CiratefiData():_scaleNum(5),_initialScale(0.5),_finalScale(1.0),_angleNum(36),_scaleThreshold(0.95),_angleThreshold(0.8),_nccThreshold(0.9) 28 | ,_isMatchNegative(false),_circleNum(16),_initialRadius(0),_finalRadius(-1),_tefiTolerance(1){} 29 | void CountParameter(cv::Mat& templateImage); 30 | double scale(double s){ return _initialScale*pow(_passoesc,s);} 31 | void SetScaleNum(int scaleNum){_scaleNum=scaleNum;} 32 | void SetInitialScale(double initialScale){_initialScale=initialScale;} 33 | void SetFinalScale(double finalScale){_finalScale=finalScale;} 34 | void SetAngleNum(int angleNum){_angleNum=angleNum;} 35 | void SetScaleThreshold(double scaleThreshold){_scaleThreshold=scaleThreshold;} 36 | void SetAngleThreshold(double angleThreshold){_angleThreshold=angleThreshold;} 37 | void SetNccThreshold(double nccThreshold){_nccThreshold=nccThreshold;} 38 | void SetMatchNegative(bool isMatchNegative){_isMatchNegative=isMatchNegative;} 39 | void SetCircleNum(int circleNum){_circleNum=circleNum;} 40 | void SetInitialRadius(double initialRadius){_initialRadius=initialRadius;} 41 | void SetTefiTolerance(int tefiTolerance){_tefiTolerance=tefiTolerance;} 42 | 43 | template 44 | T clip(const T val, const T lower, const T upper){return std::max(lower, std::min(val, upper));} 45 | double CircularSample(cv::Mat& image, int y, int x, int radius); 46 | void Cisssa(cv::Mat& sourceImage); 47 | cv::Mat quadradaimpar(cv::Mat& image); 48 | void Cissq(cv::Mat& templateImage); 49 | void Cifi(cv::Mat& sourceImage); 50 | cv::Mat DrawCifiResult(cv::Mat& sourceImage); 51 | 52 | double RadialSample(cv::Mat& image, int centerY, int centerX, double angle, double radius); 53 | void Rassq(cv::Mat& templateImage); 54 | void Rafi(cv::Mat& sourceImage); 55 | cv::Mat DrawRafiResult(cv::Mat& sourceImage); 56 | 57 | void CiratefiData::Tefi(cv::Mat& sourceImage, cv::Mat& templateImage); 58 | cv::Mat DrawTefiResult(cv::Mat& sourceImage, double sampleRatio=1); 59 | 60 | private: 61 | int _scaleNum; 62 | double _initialScale; 63 | double _finalScale; 64 | int _angleNum; 65 | double _scaleThreshold; 66 | double _angleThreshold; 67 | double _nccThreshold; 68 | bool _isMatchNegative; 69 | int _circleNum; 70 | double _initialRadius; 71 | double _finalRadius; 72 | int _tefiTolerance; 73 | double _circleDistance; 74 | double _passoesc; 75 | double _angleDegree; 76 | double _angleRadian; 77 | double _templateRadius; 78 | std::vector _ca; 79 | std::vector _cq; 80 | std::vector _rq; 81 | std::vector _cis; 82 | std::vector _ras; 83 | std::vector _tes; 84 | }; 85 | 86 | inline double round(double val, int precision=0) 87 | { 88 | double mul=pow(10, (double)precision); 89 | val*=mul; 90 | val=(val<0.0)?ceil(val-0.5):floor(val+0.5); 91 | return val/mul; 92 | } 93 | } 94 | 95 | 96 | #endif --------------------------------------------------------------------------------