├── .gitignore ├── ImageStitching ├── CImg.h ├── Input │ ├── 1.bmp │ ├── 2.bmp │ ├── 3.bmp │ └── 4.bmp ├── MyBlending.cpp ├── MyBlending.h ├── MyMatching.cpp ├── MyMatching.h ├── MySift.cpp ├── MySift.h ├── main.cpp ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── README.md └── figures ├── blend.png ├── blended.png ├── blendedImg.png ├── blendedImg0.png ├── kps.png ├── kps_real.png ├── mixImg.png ├── mixImgWithLine.png ├── mixImgWithLine_fixed.png ├── ransac.png └── singles.png /.gitignore: -------------------------------------------------------------------------------- 1 | # ===================================== # 2 | # Visual Studio generated # 3 | # ===================================== # 4 | ExportedObj/ 5 | *.svd 6 | *.userprefs 7 | *.csproj 8 | *.pidb 9 | *.suo 10 | *.user 11 | *.unityproj 12 | *.booproj 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Dd]ebugPublic/ 17 | [Rr]elease/ 18 | [Rr]eleases/ 19 | x64/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | .vs/ 26 | 27 | # Visual C++ cache files 28 | ipch/ 29 | *.aps 30 | *.ncb 31 | *.opensdf 32 | *.sdf 33 | *.cachefile 34 | *.VC.opendb 35 | *.VC.db 36 | 37 | # Visual Studio profiler 38 | *.psess 39 | *.vsp 40 | *.vspx 41 | *.sln 42 | 43 | *.vcxproj 44 | *.filters 45 | *.user 46 | 47 | Output/ 48 | TrainedModels/ -------------------------------------------------------------------------------- /ImageStitching/Input/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/Input/1.bmp -------------------------------------------------------------------------------- /ImageStitching/Input/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/Input/2.bmp -------------------------------------------------------------------------------- /ImageStitching/Input/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/Input/3.bmp -------------------------------------------------------------------------------- /ImageStitching/Input/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/Input/4.bmp -------------------------------------------------------------------------------- /ImageStitching/MyBlending.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MyBlending.cpp -------------------------------------------------------------------------------- /ImageStitching/MyBlending.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MyBlending.h -------------------------------------------------------------------------------- /ImageStitching/MyMatching.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MyMatching.cpp -------------------------------------------------------------------------------- /ImageStitching/MyMatching.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MyMatching.h -------------------------------------------------------------------------------- /ImageStitching/MySift.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MySift.cpp -------------------------------------------------------------------------------- /ImageStitching/MySift.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/MySift.h -------------------------------------------------------------------------------- /ImageStitching/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "MyMatching.h" 3 | #include "MyBlending.h" 4 | 5 | int main() { 6 | char* inputAddr1 = "Input/1.bmp"; 7 | char* inputAddr2 = "Input/2.bmp"; 8 | 9 | MySift mySift1(inputAddr1, 1); 10 | mySift1.SiftMainProcess(); 11 | mySift1.saveImgWithKeypoint("Output/1-2/1_kp.bmp"); 12 | 13 | MySift mySift2(inputAddr2, 1); 14 | mySift2.SiftMainProcess(); 15 | mySift2.saveImgWithKeypoint("Output/1-2/2_kp.bmp"); 16 | 17 | MyMatching myMatching(mySift1.getKeyPointsCount(), mySift1.getFirstKeyDescriptors(), 18 | mySift2.getKeyPointsCount(), mySift2.getFirstKeyDescriptors()); 19 | myMatching.featureMatchMainProcess(); 20 | myMatching.drawOriKeypointOnImg(inputAddr1, inputAddr2, "Output/1-2/1_kp_real.bmp", "Output/1-2/2_kp_real.bmp"); 21 | myMatching.mixImageAndDrawPairLine("Output/1-2/mixImg.bmp", "Output/1-2/mixImgWithLine.bmp"); 22 | myMatching.myRANSACtoFindKpTransAndDrawOut("Output/1-2/mixImgWithLine_fixed.bmp"); 23 | 24 | MyBlending myBlending(myMatching.getMatchVec().col, myMatching.getMatchVec().row); 25 | myBlending.blendingMainProcess(inputAddr1, inputAddr2); 26 | myBlending.saveBlendedImg("Output/1-2/blendedImg.bmp"); 27 | 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /ImageStitching/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/stdafx.cpp -------------------------------------------------------------------------------- /ImageStitching/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/stdafx.h -------------------------------------------------------------------------------- /ImageStitching/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/ImageStitching/targetver.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageStitching 2 | 3 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/singles.png) 4 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/blendedImg0.png) 5 | 6 | 7 | ## 1. Requirements 8 | - Windows10 + VS2015 9 | - C++ 10 | - cimg library : http://www.cimg.eu/ 11 | - opencv (For extracting features of images) 12 | 13 | --- 14 | 15 | ## 2. Main Procedure 16 | 1. Image **feature extraction** with `SIFT` algorithm 17 | 1. Image feature points **matching** with `RANSAC` algorithm 18 | 1. Image **blending** with matched feature points 19 | 20 | --- 21 | 22 | ## 3. Intermediate Results 23 | 24 | #### 1) Image feature extraction with `SIFT` algorithm 25 | > relevant code: `MySift.h` and `MySift.cpp` 26 | - results of key feature points (each with a feature descriptor of 128 dimention) of two images: 27 | 28 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/kps.png) 29 | 30 | #### 2) Image feature points **matching** with `RANSAC` algorithm 31 | > relevant code: `MyMatching.h` and `MyMatching.cpp` 32 | - First do a *coarse-grained* feature points matching by calculating the distance of two feature descriptors, and regard the two points as matched if the distance is lower than some threshold. The matched points are lined together as shown below: 33 | 34 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/kps_real.png) 35 | 36 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/mixImgWithLine.png) 37 | 38 | - Clearly there exist many outliers, which can be removed by `RANSAC` algorithm as shown below. The algorithm works on selecting the main transforming direction with most inliers: 39 | 40 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/ransac.png) 41 | 42 | - Removed the outliers which are conflicted with the selected transforming direction: 43 | 44 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/mixImgWithLine_fixed.png) 45 | 46 | #### 3) Image **blending** with matched feature points 47 | > relevant code: `MyBlending.h` and `MyBlending.cpp` 48 | - First use a simple translation method: 49 | 50 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/mixImg.png) 51 | 52 | becomes 53 | 54 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/blended.png) 55 | 56 | - Then apply a RGB interpolation at fusion region `A/B`: 57 | 58 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/blend.png) 59 | 60 | - Stitched Result of two images 61 | 62 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/blendedImg.png) 63 | 64 | - Repeat this procedure and get the stitched Result of all images 65 | 66 | ![Image text](https://github.com/MarkMoHR/ImageStitching/raw/master/figures/blendedImg0.png) 67 | 68 | -------------------------------------------------------------------------------- /figures/blend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/blend.png -------------------------------------------------------------------------------- /figures/blended.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/blended.png -------------------------------------------------------------------------------- /figures/blendedImg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/blendedImg.png -------------------------------------------------------------------------------- /figures/blendedImg0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/blendedImg0.png -------------------------------------------------------------------------------- /figures/kps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/kps.png -------------------------------------------------------------------------------- /figures/kps_real.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/kps_real.png -------------------------------------------------------------------------------- /figures/mixImg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/mixImg.png -------------------------------------------------------------------------------- /figures/mixImgWithLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/mixImgWithLine.png -------------------------------------------------------------------------------- /figures/mixImgWithLine_fixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/mixImgWithLine_fixed.png -------------------------------------------------------------------------------- /figures/ransac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/ransac.png -------------------------------------------------------------------------------- /figures/singles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMoHR/ImageStitching/8cb1f1af16871b9ff1ebce9d108df8aefa9f0f8d/figures/singles.png --------------------------------------------------------------------------------