├── README.md ├── _config.yml ├── code ├── .gitignore ├── CMakeCache.txt ├── CMakeFiles │ ├── 3.11.1 │ │ ├── CMakeCCompiler.cmake │ │ ├── CMakeCXXCompiler.cmake │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ ├── CMakeSystem.cmake │ │ ├── CompilerIdC │ │ │ ├── CMakeCCompilerId.c │ │ │ └── a.out │ │ └── CompilerIdCXX │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ └── a.out │ ├── CMakeOutput.log │ ├── cmake.check_cache │ ├── feature_tests.bin │ ├── feature_tests.c │ └── feature_tests.cxx ├── CMakeLists.txt ├── ImageCompletionGUI.zip ├── Makefile ├── cow-mask.png ├── cow.png ├── final_out.png ├── im_complete.cpp ├── im_complete_another.cpp ├── im_complete_new.cpp ├── im_complete_opencv.cpp ├── im_complete_opencv_constraint.cpp ├── man_const.png └── pm_minimal.cpp ├── gui ├── PatchMatch.fig ├── PatchMatch.m └── Untitled Document ├── index.md ├── report ├── image │ ├── constraint_illu.png │ ├── constraint_result.png │ ├── first_result.png │ ├── first_try.png │ ├── image1.png │ ├── image2.png │ ├── image3.png │ ├── image4.png │ ├── image5.png │ ├── image6.png │ ├── image7.png │ ├── image8.png │ ├── image9.png │ ├── man_dog.png │ ├── multi_algo.png │ ├── multi_result.png │ ├── result1.png │ ├── result2.png │ ├── result3.png │ ├── result4.png │ ├── result5.png │ └── task_def.png └── tmp.txt ├── simulation-results ├── Image_Completion_Ex1 │ ├── a.png │ ├── a_completion.jpg │ ├── a_hole.jpg │ └── a_hole_mask.jpg ├── Image_Completion_Ex2 │ ├── test7.jpg │ ├── test7h.png │ ├── test7m.png │ └── test7m_completion.jpg ├── Image_Reconstruction_Ex1 │ ├── Source Image.png │ ├── Target Image.png │ ├── a_restructed.jpg │ ├── ann.jpg │ └── annd.jpg └── Untitled Document └── test-images ├── Image_Completion ├── bmp │ ├── test2.bmp │ ├── test2h.bmp │ ├── test2m.bmp │ ├── test3.bmp │ ├── test3h.bmp │ ├── test3m.bmp │ ├── test7.bmp │ ├── test7h.bmp │ ├── test7m.bmp │ ├── test8.bmp │ ├── test8h.bmp │ └── test8m.bmp ├── createHole.m ├── jpg │ ├── test1.jpg │ ├── test1h.jpg │ ├── test1m.jpg │ ├── test4.jpg │ ├── test4h.jpg │ ├── test4m.jpg │ ├── test5.jpg │ ├── test5h.jpg │ ├── test5m.jpg │ ├── test6.jpg │ ├── test6h.jpg │ └── test6m.jpg └── png │ ├── test1.png │ ├── test1m.png │ ├── test2.png │ ├── test2m.png │ ├── test3.png │ ├── test3m.png │ ├── test4.png │ └── test4m.png ├── Image_Reconstruction ├── a.png └── b.png ├── Image_Retargeting ├── ours_10_aaa.jpg ├── ours_17_aaa.jpg ├── ours_19_aaa.jpg ├── ours_1_aaa.jpg ├── ours_20_aaa.jpg ├── ours_21_aaa.jpg ├── ours_23_aaa.jpg ├── ours_24_aaa.jpg ├── ours_26_aaa.jpg ├── ours_27_aaa.jpg ├── ours_28_aaa.jpg ├── ours_29_aaa.jpg ├── ours_2_aaa.jpg ├── ours_30_aaa.jpg ├── ours_32_aaa.jpg ├── ours_35_aaa.jpg ├── ours_4_aaa.jpg ├── ours_5_aaa.jpg ├── ours_6_aaa.jpg ├── ours_8_aaa.jpg └── ours_9_aaa.jpg ├── a.png ├── a_hole.jpg ├── a_hole_mask.jpg └── b.png /README.md: -------------------------------------------------------------------------------- 1 | # CS-766-Computer-Vision -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman 2 | title: "Interactive PatchMatch-Based
Image Completion" 3 | description: 4 | "CS 766: Computer Vision, Spring 2018

Wen-Fu Lee (wlee256@wisc.edu)
Yuan-Ting Hsieh (yhsieh28@wisc.edu)
Zubeyr Furkan Eryilmaz (eryilmaz@wisc.edu)" 5 | -------------------------------------------------------------------------------- /code/.gitignore: -------------------------------------------------------------------------------- 1 | r*.png 2 | -------------------------------------------------------------------------------- /code/CMakeCache.txt: -------------------------------------------------------------------------------- 1 | # This is the CMakeCache file. 2 | # For build in directory: /Users/yuantinghsieh/CS-766-Computer-Vision/code 3 | # It was generated by CMake: /usr/local/Cellar/cmake/3.11.1/bin/cmake 4 | # You can edit this file to change values found and used by cmake. 5 | # If you do not want to change any of the values, simply exit the editor. 6 | # If you do want to change a value, simply edit, save, and exit the editor. 7 | # The syntax for the file is as follows: 8 | # KEY:TYPE=VALUE 9 | # KEY is the name of a variable in the cache. 10 | # TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. 11 | # VALUE is the current value for the KEY. 12 | 13 | ######################## 14 | # EXTERNAL cache entries 15 | ######################## 16 | 17 | //Path to a program. 18 | CMAKE_AR:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ar 19 | 20 | //Choose the type of build, options are: None Debug Release RelWithDebInfo 21 | // MinSizeRel ... 22 | CMAKE_BUILD_TYPE:STRING= 23 | 24 | //Enable/Disable color output during build. 25 | CMAKE_COLOR_MAKEFILE:BOOL=ON 26 | 27 | //CXX compiler 28 | CMAKE_CXX_COMPILER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/c++ 29 | 30 | //Flags used by the CXX compiler during all build types. 31 | CMAKE_CXX_FLAGS:STRING= 32 | 33 | //Flags used by the CXX compiler during DEBUG builds. 34 | CMAKE_CXX_FLAGS_DEBUG:STRING=-g 35 | 36 | //Flags used by the CXX compiler during MINSIZEREL builds. 37 | CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG 38 | 39 | //Flags used by the CXX compiler during RELEASE builds. 40 | CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG 41 | 42 | //Flags used by the CXX compiler during RELWITHDEBINFO builds. 43 | CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG 44 | 45 | //C compiler 46 | CMAKE_C_COMPILER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/cc 47 | 48 | //Flags used by the C compiler during all build types. 49 | CMAKE_C_FLAGS:STRING= 50 | 51 | //Flags used by the C compiler during DEBUG builds. 52 | CMAKE_C_FLAGS_DEBUG:STRING=-g 53 | 54 | //Flags used by the C compiler during MINSIZEREL builds. 55 | CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG 56 | 57 | //Flags used by the C compiler during RELEASE builds. 58 | CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG 59 | 60 | //Flags used by the C compiler during RELWITHDEBINFO builds. 61 | CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG 62 | 63 | //Flags used by the linker during all build types. 64 | CMAKE_EXE_LINKER_FLAGS:STRING= 65 | 66 | //Flags used by the linker during DEBUG builds. 67 | CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= 68 | 69 | //Flags used by the linker during MINSIZEREL builds. 70 | CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= 71 | 72 | //Flags used by the linker during RELEASE builds. 73 | CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= 74 | 75 | //Flags used by the linker during RELWITHDEBINFO builds. 76 | CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= 77 | 78 | //Enable/Disable output of compile commands during generation. 79 | CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF 80 | 81 | //Path to a program. 82 | CMAKE_INSTALL_NAME_TOOL:FILEPATH=/usr/bin/install_name_tool 83 | 84 | //Install path prefix, prepended onto install directories. 85 | CMAKE_INSTALL_PREFIX:PATH=/usr/local 86 | 87 | //Path to a program. 88 | CMAKE_LINKER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ld 89 | 90 | //Path to a program. 91 | CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make 92 | 93 | //Flags used by the linker during the creation of modules during 94 | // all build types. 95 | CMAKE_MODULE_LINKER_FLAGS:STRING= 96 | 97 | //Flags used by the linker during the creation of modules during 98 | // DEBUG builds. 99 | CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= 100 | 101 | //Flags used by the linker during the creation of modules during 102 | // MINSIZEREL builds. 103 | CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= 104 | 105 | //Flags used by the linker during the creation of modules during 106 | // RELEASE builds. 107 | CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= 108 | 109 | //Flags used by the linker during the creation of modules during 110 | // RELWITHDEBINFO builds. 111 | CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= 112 | 113 | //Path to a program. 114 | CMAKE_NM:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/nm 115 | 116 | //Path to a program. 117 | CMAKE_OBJCOPY:FILEPATH=CMAKE_OBJCOPY-NOTFOUND 118 | 119 | //Path to a program. 120 | CMAKE_OBJDUMP:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/objdump 121 | 122 | //Build architectures for OSX 123 | CMAKE_OSX_ARCHITECTURES:STRING= 124 | 125 | //Minimum OS X version to target for deployment (at runtime); newer 126 | // APIs weak linked. Set to empty string for default value. 127 | CMAKE_OSX_DEPLOYMENT_TARGET:STRING= 128 | 129 | //The product will be built against the headers and libraries located 130 | // inside the indicated SDK. 131 | CMAKE_OSX_SYSROOT:STRING= 132 | 133 | //Value Computed by CMake 134 | CMAKE_PROJECT_NAME:STATIC=ImageComplete 135 | 136 | //Path to a program. 137 | CMAKE_RANLIB:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ranlib 138 | 139 | //Flags used by the linker during the creation of shared libraries 140 | // during all build types. 141 | CMAKE_SHARED_LINKER_FLAGS:STRING= 142 | 143 | //Flags used by the linker during the creation of shared libraries 144 | // during DEBUG builds. 145 | CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= 146 | 147 | //Flags used by the linker during the creation of shared libraries 148 | // during MINSIZEREL builds. 149 | CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= 150 | 151 | //Flags used by the linker during the creation of shared libraries 152 | // during RELEASE builds. 153 | CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= 154 | 155 | //Flags used by the linker during the creation of shared libraries 156 | // during RELWITHDEBINFO builds. 157 | CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= 158 | 159 | //If set, runtime paths are not added when installing shared libraries, 160 | // but are added when building. 161 | CMAKE_SKIP_INSTALL_RPATH:BOOL=NO 162 | 163 | //If set, runtime paths are not added when using shared libraries. 164 | CMAKE_SKIP_RPATH:BOOL=NO 165 | 166 | //Flags used by the linker during the creation of static libraries 167 | // during all build types. 168 | CMAKE_STATIC_LINKER_FLAGS:STRING= 169 | 170 | //Flags used by the linker during the creation of static libraries 171 | // during DEBUG builds. 172 | CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING= 173 | 174 | //Flags used by the linker during the creation of static libraries 175 | // during MINSIZEREL builds. 176 | CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING= 177 | 178 | //Flags used by the linker during the creation of static libraries 179 | // during RELEASE builds. 180 | CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING= 181 | 182 | //Flags used by the linker during the creation of static libraries 183 | // during RELWITHDEBINFO builds. 184 | CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= 185 | 186 | //Path to a program. 187 | CMAKE_STRIP:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/strip 188 | 189 | //If this value is on, makefiles will be generated without the 190 | // .SILENT directive, and all commands will be echoed to the console 191 | // during the make. This is useful for debugging only. With Visual 192 | // Studio IDE projects all commands are done without /nologo. 193 | CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE 194 | 195 | //Value Computed by CMake 196 | ImageComplete_BINARY_DIR:STATIC=/Users/yuantinghsieh/CS-766-Computer-Vision/code 197 | 198 | //Value Computed by CMake 199 | ImageComplete_SOURCE_DIR:STATIC=/Users/yuantinghsieh/CS-766-Computer-Vision/code 200 | 201 | //The directory containing a CMake configuration file for OpenCV. 202 | OpenCV_DIR:PATH=/usr/local/share/OpenCV 203 | 204 | 205 | ######################## 206 | # INTERNAL cache entries 207 | ######################## 208 | 209 | //ADVANCED property for variable: CMAKE_AR 210 | CMAKE_AR-ADVANCED:INTERNAL=1 211 | //This is the directory where this CMakeCache.txt was created 212 | CMAKE_CACHEFILE_DIR:INTERNAL=/Users/yuantinghsieh/CS-766-Computer-Vision/code 213 | //Major version of cmake used to create the current loaded cache 214 | CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3 215 | //Minor version of cmake used to create the current loaded cache 216 | CMAKE_CACHE_MINOR_VERSION:INTERNAL=11 217 | //Patch version of cmake used to create the current loaded cache 218 | CMAKE_CACHE_PATCH_VERSION:INTERNAL=1 219 | //ADVANCED property for variable: CMAKE_COLOR_MAKEFILE 220 | CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 221 | //Path to CMake executable. 222 | CMAKE_COMMAND:INTERNAL=/usr/local/Cellar/cmake/3.11.1/bin/cmake 223 | //Path to cpack program executable. 224 | CMAKE_CPACK_COMMAND:INTERNAL=/usr/local/Cellar/cmake/3.11.1/bin/cpack 225 | //Path to ctest program executable. 226 | CMAKE_CTEST_COMMAND:INTERNAL=/usr/local/Cellar/cmake/3.11.1/bin/ctest 227 | //ADVANCED property for variable: CMAKE_CXX_COMPILER 228 | CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1 229 | //ADVANCED property for variable: CMAKE_CXX_FLAGS 230 | CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1 231 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG 232 | CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1 233 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL 234 | CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 235 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE 236 | CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1 237 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO 238 | CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 239 | //ADVANCED property for variable: CMAKE_C_COMPILER 240 | CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 241 | //ADVANCED property for variable: CMAKE_C_FLAGS 242 | CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 243 | //ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG 244 | CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 245 | //ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL 246 | CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 247 | //ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE 248 | CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 249 | //ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO 250 | CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 251 | //Path to cache edit program executable. 252 | CMAKE_EDIT_COMMAND:INTERNAL=/usr/local/Cellar/cmake/3.11.1/bin/ccmake 253 | //Executable file format 254 | CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown 255 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS 256 | CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 257 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG 258 | CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 259 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL 260 | CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 261 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE 262 | CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 263 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO 264 | CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 265 | //ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS 266 | CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1 267 | //Name of external makefile project generator. 268 | CMAKE_EXTRA_GENERATOR:INTERNAL= 269 | //Name of generator. 270 | CMAKE_GENERATOR:INTERNAL=Unix Makefiles 271 | //Generator instance identifier. 272 | CMAKE_GENERATOR_INSTANCE:INTERNAL= 273 | //Name of generator platform. 274 | CMAKE_GENERATOR_PLATFORM:INTERNAL= 275 | //Name of generator toolset. 276 | CMAKE_GENERATOR_TOOLSET:INTERNAL= 277 | //Source directory with the top level CMakeLists.txt file for this 278 | // project 279 | CMAKE_HOME_DIRECTORY:INTERNAL=/Users/yuantinghsieh/CS-766-Computer-Vision/code 280 | //ADVANCED property for variable: CMAKE_INSTALL_NAME_TOOL 281 | CMAKE_INSTALL_NAME_TOOL-ADVANCED:INTERNAL=1 282 | //ADVANCED property for variable: CMAKE_LINKER 283 | CMAKE_LINKER-ADVANCED:INTERNAL=1 284 | //ADVANCED property for variable: CMAKE_MAKE_PROGRAM 285 | CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 286 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS 287 | CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 288 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG 289 | CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 290 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL 291 | CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 292 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE 293 | CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 294 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO 295 | CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 296 | //ADVANCED property for variable: CMAKE_NM 297 | CMAKE_NM-ADVANCED:INTERNAL=1 298 | //number of local generators 299 | CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1 300 | //ADVANCED property for variable: CMAKE_OBJCOPY 301 | CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 302 | //ADVANCED property for variable: CMAKE_OBJDUMP 303 | CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 304 | //Platform information initialized 305 | CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1 306 | //ADVANCED property for variable: CMAKE_RANLIB 307 | CMAKE_RANLIB-ADVANCED:INTERNAL=1 308 | //Path to CMake installation. 309 | CMAKE_ROOT:INTERNAL=/usr/local/Cellar/cmake/3.11.1/share/cmake 310 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS 311 | CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 312 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG 313 | CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 314 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL 315 | CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 316 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE 317 | CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 318 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO 319 | CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 320 | //ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH 321 | CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1 322 | //ADVANCED property for variable: CMAKE_SKIP_RPATH 323 | CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 324 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS 325 | CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1 326 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG 327 | CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 328 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL 329 | CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 330 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE 331 | CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 332 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO 333 | CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 334 | //ADVANCED property for variable: CMAKE_STRIP 335 | CMAKE_STRIP-ADVANCED:INTERNAL=1 336 | //uname command 337 | CMAKE_UNAME:INTERNAL=/usr/bin/uname 338 | //ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE 339 | CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 340 | //Details about finding OpenCV 341 | FIND_PACKAGE_MESSAGE_DETAILS_OpenCV:INTERNAL=[/usr/local][v3.4.1()] 342 | 343 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/Library/Developer/CommandLineTools/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "AppleClang") 4 | set(CMAKE_C_COMPILER_VERSION "9.1.0.9020039") 5 | set(CMAKE_C_COMPILER_VERSION_INTERNAL "") 6 | set(CMAKE_C_COMPILER_WRAPPER "") 7 | set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") 8 | set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert") 9 | set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") 10 | set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") 11 | set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") 12 | 13 | set(CMAKE_C_PLATFORM_ID "Darwin") 14 | set(CMAKE_C_SIMULATE_ID "") 15 | set(CMAKE_C_SIMULATE_VERSION "") 16 | 17 | 18 | 19 | set(CMAKE_AR "/Library/Developer/CommandLineTools/usr/bin/ar") 20 | set(CMAKE_C_COMPILER_AR "") 21 | set(CMAKE_RANLIB "/Library/Developer/CommandLineTools/usr/bin/ranlib") 22 | set(CMAKE_C_COMPILER_RANLIB "") 23 | set(CMAKE_LINKER "/Library/Developer/CommandLineTools/usr/bin/ld") 24 | set(CMAKE_COMPILER_IS_GNUCC ) 25 | set(CMAKE_C_COMPILER_LOADED 1) 26 | set(CMAKE_C_COMPILER_WORKS TRUE) 27 | set(CMAKE_C_ABI_COMPILED TRUE) 28 | set(CMAKE_COMPILER_IS_MINGW ) 29 | set(CMAKE_COMPILER_IS_CYGWIN ) 30 | if(CMAKE_COMPILER_IS_CYGWIN) 31 | set(CYGWIN 1) 32 | set(UNIX 1) 33 | endif() 34 | 35 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 36 | 37 | if(CMAKE_COMPILER_IS_MINGW) 38 | set(MINGW 1) 39 | endif() 40 | set(CMAKE_C_COMPILER_ID_RUN 1) 41 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 42 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 43 | set(CMAKE_C_LINKER_PREFERENCE 10) 44 | 45 | # Save compiler ABI information. 46 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 47 | set(CMAKE_C_COMPILER_ABI "") 48 | set(CMAKE_C_LIBRARY_ARCHITECTURE "") 49 | 50 | if(CMAKE_C_SIZEOF_DATA_PTR) 51 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 52 | endif() 53 | 54 | if(CMAKE_C_COMPILER_ABI) 55 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 56 | endif() 57 | 58 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 59 | set(CMAKE_LIBRARY_ARCHITECTURE "") 60 | endif() 61 | 62 | set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") 63 | if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) 64 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") 65 | endif() 66 | 67 | 68 | 69 | 70 | 71 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "") 72 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib;/usr/local/lib") 73 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "/Library/Frameworks;/System/Library/Frameworks") 74 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CMakeCXXCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c++") 2 | set(CMAKE_CXX_COMPILER_ARG1 "") 3 | set(CMAKE_CXX_COMPILER_ID "AppleClang") 4 | set(CMAKE_CXX_COMPILER_VERSION "9.1.0.9020039") 5 | set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "") 6 | set(CMAKE_CXX_COMPILER_WRAPPER "") 7 | set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "98") 8 | set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17") 9 | set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters") 10 | set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") 11 | set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates") 12 | set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17") 13 | 14 | set(CMAKE_CXX_PLATFORM_ID "Darwin") 15 | set(CMAKE_CXX_SIMULATE_ID "") 16 | set(CMAKE_CXX_SIMULATE_VERSION "") 17 | 18 | 19 | 20 | set(CMAKE_AR "/Library/Developer/CommandLineTools/usr/bin/ar") 21 | set(CMAKE_CXX_COMPILER_AR "") 22 | set(CMAKE_RANLIB "/Library/Developer/CommandLineTools/usr/bin/ranlib") 23 | set(CMAKE_CXX_COMPILER_RANLIB "") 24 | set(CMAKE_LINKER "/Library/Developer/CommandLineTools/usr/bin/ld") 25 | set(CMAKE_COMPILER_IS_GNUCXX ) 26 | set(CMAKE_CXX_COMPILER_LOADED 1) 27 | set(CMAKE_CXX_COMPILER_WORKS TRUE) 28 | set(CMAKE_CXX_ABI_COMPILED TRUE) 29 | set(CMAKE_COMPILER_IS_MINGW ) 30 | set(CMAKE_COMPILER_IS_CYGWIN ) 31 | if(CMAKE_COMPILER_IS_CYGWIN) 32 | set(CYGWIN 1) 33 | set(UNIX 1) 34 | endif() 35 | 36 | set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") 37 | 38 | if(CMAKE_COMPILER_IS_MINGW) 39 | set(MINGW 1) 40 | endif() 41 | set(CMAKE_CXX_COMPILER_ID_RUN 1) 42 | set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) 43 | set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) 44 | set(CMAKE_CXX_LINKER_PREFERENCE 30) 45 | set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) 46 | 47 | # Save compiler ABI information. 48 | set(CMAKE_CXX_SIZEOF_DATA_PTR "8") 49 | set(CMAKE_CXX_COMPILER_ABI "") 50 | set(CMAKE_CXX_LIBRARY_ARCHITECTURE "") 51 | 52 | if(CMAKE_CXX_SIZEOF_DATA_PTR) 53 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") 54 | endif() 55 | 56 | if(CMAKE_CXX_COMPILER_ABI) 57 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") 58 | endif() 59 | 60 | if(CMAKE_CXX_LIBRARY_ARCHITECTURE) 61 | set(CMAKE_LIBRARY_ARCHITECTURE "") 62 | endif() 63 | 64 | set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "") 65 | if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX) 66 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}") 67 | endif() 68 | 69 | 70 | 71 | 72 | 73 | set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "c++") 74 | set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib;/usr/local/lib") 75 | set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "/Library/Frameworks;/System/Library/Frameworks") 76 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/CMakeFiles/3.11.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/CMakeFiles/3.11.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-17.5.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "17.5.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-17.5.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "17.5.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CompilerIdC/CMakeCCompilerId.c: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | # error "A C++ compiler has been selected for C." 3 | #endif 4 | 5 | #if defined(__18CXX) 6 | # define ID_VOID_MAIN 7 | #endif 8 | #if defined(__CLASSIC_C__) 9 | /* cv-qualifiers did not exist in K&R C */ 10 | # define const 11 | # define volatile 12 | #endif 13 | 14 | 15 | /* Version number components: V=Version, R=Revision, P=Patch 16 | Version date components: YYYY=Year, MM=Month, DD=Day */ 17 | 18 | #if defined(__INTEL_COMPILER) || defined(__ICC) 19 | # define COMPILER_ID "Intel" 20 | # if defined(_MSC_VER) 21 | # define SIMULATE_ID "MSVC" 22 | # endif 23 | /* __INTEL_COMPILER = VRP */ 24 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 25 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 26 | # if defined(__INTEL_COMPILER_UPDATE) 27 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) 28 | # else 29 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 30 | # endif 31 | # if defined(__INTEL_COMPILER_BUILD_DATE) 32 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 33 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 34 | # endif 35 | # if defined(_MSC_VER) 36 | /* _MSC_VER = VVRR */ 37 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 38 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 39 | # endif 40 | 41 | #elif defined(__PATHCC__) 42 | # define COMPILER_ID "PathScale" 43 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 44 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 45 | # if defined(__PATHCC_PATCHLEVEL__) 46 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 47 | # endif 48 | 49 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 50 | # define COMPILER_ID "Embarcadero" 51 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 52 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 53 | # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) 54 | 55 | #elif defined(__BORLANDC__) 56 | # define COMPILER_ID "Borland" 57 | /* __BORLANDC__ = 0xVRR */ 58 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 59 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 60 | 61 | #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 62 | # define COMPILER_ID "Watcom" 63 | /* __WATCOMC__ = VVRR */ 64 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 65 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 66 | # if (__WATCOMC__ % 10) > 0 67 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 68 | # endif 69 | 70 | #elif defined(__WATCOMC__) 71 | # define COMPILER_ID "OpenWatcom" 72 | /* __WATCOMC__ = VVRP + 1100 */ 73 | # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) 74 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 75 | # if (__WATCOMC__ % 10) > 0 76 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 77 | # endif 78 | 79 | #elif defined(__SUNPRO_C) 80 | # define COMPILER_ID "SunPro" 81 | # if __SUNPRO_C >= 0x5100 82 | /* __SUNPRO_C = 0xVRRP */ 83 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) 84 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) 85 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 86 | # else 87 | /* __SUNPRO_CC = 0xVRP */ 88 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) 89 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) 90 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 91 | # endif 92 | 93 | #elif defined(__HP_cc) 94 | # define COMPILER_ID "HP" 95 | /* __HP_cc = VVRRPP */ 96 | # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) 97 | # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) 98 | # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) 99 | 100 | #elif defined(__DECC) 101 | # define COMPILER_ID "Compaq" 102 | /* __DECC_VER = VVRRTPPPP */ 103 | # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) 104 | # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) 105 | # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) 106 | 107 | #elif defined(__IBMC__) && defined(__COMPILER_VER__) 108 | # define COMPILER_ID "zOS" 109 | # if defined(__ibmxl__) 110 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 111 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 112 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 113 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 114 | # else 115 | /* __IBMC__ = VRP */ 116 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 117 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 118 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 119 | # endif 120 | 121 | 122 | #elif defined(__ibmxl__) || (defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800) 123 | # define COMPILER_ID "XL" 124 | # if defined(__ibmxl__) 125 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 126 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 127 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 128 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 129 | # else 130 | /* __IBMC__ = VRP */ 131 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 132 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 133 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 134 | # endif 135 | 136 | 137 | #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 138 | # define COMPILER_ID "VisualAge" 139 | # if defined(__ibmxl__) 140 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 141 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 142 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 143 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 144 | # else 145 | /* __IBMC__ = VRP */ 146 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 147 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 148 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 149 | # endif 150 | 151 | 152 | #elif defined(__PGI) 153 | # define COMPILER_ID "PGI" 154 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 155 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 156 | # if defined(__PGIC_PATCHLEVEL__) 157 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 158 | # endif 159 | 160 | #elif defined(_CRAYC) 161 | # define COMPILER_ID "Cray" 162 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) 163 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 164 | 165 | #elif defined(__TI_COMPILER_VERSION__) 166 | # define COMPILER_ID "TI" 167 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 168 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 169 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 170 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 171 | 172 | #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) 173 | # define COMPILER_ID "Fujitsu" 174 | 175 | #elif defined(__TINYC__) 176 | # define COMPILER_ID "TinyCC" 177 | 178 | #elif defined(__BCC__) 179 | # define COMPILER_ID "Bruce" 180 | 181 | #elif defined(__SCO_VERSION__) 182 | # define COMPILER_ID "SCO" 183 | 184 | #elif defined(__clang__) && defined(__apple_build_version__) 185 | # define COMPILER_ID "AppleClang" 186 | # if defined(_MSC_VER) 187 | # define SIMULATE_ID "MSVC" 188 | # endif 189 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 190 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 191 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 192 | # if defined(_MSC_VER) 193 | /* _MSC_VER = VVRR */ 194 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 195 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 196 | # endif 197 | # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) 198 | 199 | #elif defined(__clang__) 200 | # define COMPILER_ID "Clang" 201 | # if defined(_MSC_VER) 202 | # define SIMULATE_ID "MSVC" 203 | # endif 204 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 205 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 206 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 207 | # if defined(_MSC_VER) 208 | /* _MSC_VER = VVRR */ 209 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 210 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 211 | # endif 212 | 213 | #elif defined(__GNUC__) 214 | # define COMPILER_ID "GNU" 215 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 216 | # if defined(__GNUC_MINOR__) 217 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 218 | # endif 219 | # if defined(__GNUC_PATCHLEVEL__) 220 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 221 | # endif 222 | 223 | #elif defined(_MSC_VER) 224 | # define COMPILER_ID "MSVC" 225 | /* _MSC_VER = VVRR */ 226 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 227 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 228 | # if defined(_MSC_FULL_VER) 229 | # if _MSC_VER >= 1400 230 | /* _MSC_FULL_VER = VVRRPPPPP */ 231 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 232 | # else 233 | /* _MSC_FULL_VER = VVRRPPPP */ 234 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 235 | # endif 236 | # endif 237 | # if defined(_MSC_BUILD) 238 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 239 | # endif 240 | 241 | #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 242 | # define COMPILER_ID "ADSP" 243 | #if defined(__VISUALDSPVERSION__) 244 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 245 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 246 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 247 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 248 | #endif 249 | 250 | #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) 251 | # define COMPILER_ID "IAR" 252 | # if defined(__VER__) 253 | # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) 254 | # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) 255 | # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) 256 | # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) 257 | # endif 258 | 259 | #elif defined(__ARMCC_VERSION) 260 | # define COMPILER_ID "ARMCC" 261 | #if __ARMCC_VERSION >= 1000000 262 | /* __ARMCC_VERSION = VRRPPPP */ 263 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) 264 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) 265 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 266 | #else 267 | /* __ARMCC_VERSION = VRPPPP */ 268 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) 269 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) 270 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 271 | #endif 272 | 273 | 274 | #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) 275 | # define COMPILER_ID "SDCC" 276 | # if defined(__SDCC_VERSION_MAJOR) 277 | # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) 278 | # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) 279 | # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) 280 | # else 281 | /* SDCC = VRP */ 282 | # define COMPILER_VERSION_MAJOR DEC(SDCC/100) 283 | # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) 284 | # define COMPILER_VERSION_PATCH DEC(SDCC % 10) 285 | # endif 286 | 287 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 288 | # define COMPILER_ID "MIPSpro" 289 | # if defined(_SGI_COMPILER_VERSION) 290 | /* _SGI_COMPILER_VERSION = VRP */ 291 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 292 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 293 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 294 | # else 295 | /* _COMPILER_VERSION = VRP */ 296 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 297 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 298 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 299 | # endif 300 | 301 | 302 | /* These compilers are either not known or too old to define an 303 | identification macro. Try to identify the platform and guess that 304 | it is the native compiler. */ 305 | #elif defined(__sgi) 306 | # define COMPILER_ID "MIPSpro" 307 | 308 | #elif defined(__hpux) || defined(__hpua) 309 | # define COMPILER_ID "HP" 310 | 311 | #else /* unknown compiler */ 312 | # define COMPILER_ID "" 313 | #endif 314 | 315 | /* Construct the string literal in pieces to prevent the source from 316 | getting matched. Store it in a pointer rather than an array 317 | because some compilers will just produce instructions to fill the 318 | array rather than assigning a pointer to a static array. */ 319 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 320 | #ifdef SIMULATE_ID 321 | char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; 322 | #endif 323 | 324 | #ifdef __QNXNTO__ 325 | char const* qnxnto = "INFO" ":" "qnxnto[]"; 326 | #endif 327 | 328 | #if defined(__CRAYXE) || defined(__CRAYXC) 329 | char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; 330 | #endif 331 | 332 | #define STRINGIFY_HELPER(X) #X 333 | #define STRINGIFY(X) STRINGIFY_HELPER(X) 334 | 335 | /* Identify known platforms by name. */ 336 | #if defined(__linux) || defined(__linux__) || defined(linux) 337 | # define PLATFORM_ID "Linux" 338 | 339 | #elif defined(__CYGWIN__) 340 | # define PLATFORM_ID "Cygwin" 341 | 342 | #elif defined(__MINGW32__) 343 | # define PLATFORM_ID "MinGW" 344 | 345 | #elif defined(__APPLE__) 346 | # define PLATFORM_ID "Darwin" 347 | 348 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 349 | # define PLATFORM_ID "Windows" 350 | 351 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 352 | # define PLATFORM_ID "FreeBSD" 353 | 354 | #elif defined(__NetBSD__) || defined(__NetBSD) 355 | # define PLATFORM_ID "NetBSD" 356 | 357 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 358 | # define PLATFORM_ID "OpenBSD" 359 | 360 | #elif defined(__sun) || defined(sun) 361 | # define PLATFORM_ID "SunOS" 362 | 363 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 364 | # define PLATFORM_ID "AIX" 365 | 366 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 367 | # define PLATFORM_ID "IRIX" 368 | 369 | #elif defined(__hpux) || defined(__hpux__) 370 | # define PLATFORM_ID "HP-UX" 371 | 372 | #elif defined(__HAIKU__) 373 | # define PLATFORM_ID "Haiku" 374 | 375 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 376 | # define PLATFORM_ID "BeOS" 377 | 378 | #elif defined(__QNX__) || defined(__QNXNTO__) 379 | # define PLATFORM_ID "QNX" 380 | 381 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 382 | # define PLATFORM_ID "Tru64" 383 | 384 | #elif defined(__riscos) || defined(__riscos__) 385 | # define PLATFORM_ID "RISCos" 386 | 387 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 388 | # define PLATFORM_ID "SINIX" 389 | 390 | #elif defined(__UNIX_SV__) 391 | # define PLATFORM_ID "UNIX_SV" 392 | 393 | #elif defined(__bsdos__) 394 | # define PLATFORM_ID "BSDOS" 395 | 396 | #elif defined(_MPRAS) || defined(MPRAS) 397 | # define PLATFORM_ID "MP-RAS" 398 | 399 | #elif defined(__osf) || defined(__osf__) 400 | # define PLATFORM_ID "OSF1" 401 | 402 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 403 | # define PLATFORM_ID "SCO_SV" 404 | 405 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 406 | # define PLATFORM_ID "ULTRIX" 407 | 408 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 409 | # define PLATFORM_ID "Xenix" 410 | 411 | #elif defined(__WATCOMC__) 412 | # if defined(__LINUX__) 413 | # define PLATFORM_ID "Linux" 414 | 415 | # elif defined(__DOS__) 416 | # define PLATFORM_ID "DOS" 417 | 418 | # elif defined(__OS2__) 419 | # define PLATFORM_ID "OS2" 420 | 421 | # elif defined(__WINDOWS__) 422 | # define PLATFORM_ID "Windows3x" 423 | 424 | # else /* unknown platform */ 425 | # define PLATFORM_ID 426 | # endif 427 | 428 | #else /* unknown platform */ 429 | # define PLATFORM_ID 430 | 431 | #endif 432 | 433 | /* For windows compilers MSVC and Intel we can determine 434 | the architecture of the compiler being used. This is because 435 | the compilers do not have flags that can change the architecture, 436 | but rather depend on which compiler is being used 437 | */ 438 | #if defined(_WIN32) && defined(_MSC_VER) 439 | # if defined(_M_IA64) 440 | # define ARCHITECTURE_ID "IA64" 441 | 442 | # elif defined(_M_X64) || defined(_M_AMD64) 443 | # define ARCHITECTURE_ID "x64" 444 | 445 | # elif defined(_M_IX86) 446 | # define ARCHITECTURE_ID "X86" 447 | 448 | # elif defined(_M_ARM64) 449 | # define ARCHITECTURE_ID "ARM64" 450 | 451 | # elif defined(_M_ARM) 452 | # if _M_ARM == 4 453 | # define ARCHITECTURE_ID "ARMV4I" 454 | # elif _M_ARM == 5 455 | # define ARCHITECTURE_ID "ARMV5I" 456 | # else 457 | # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) 458 | # endif 459 | 460 | # elif defined(_M_MIPS) 461 | # define ARCHITECTURE_ID "MIPS" 462 | 463 | # elif defined(_M_SH) 464 | # define ARCHITECTURE_ID "SHx" 465 | 466 | # else /* unknown architecture */ 467 | # define ARCHITECTURE_ID "" 468 | # endif 469 | 470 | #elif defined(__WATCOMC__) 471 | # if defined(_M_I86) 472 | # define ARCHITECTURE_ID "I86" 473 | 474 | # elif defined(_M_IX86) 475 | # define ARCHITECTURE_ID "X86" 476 | 477 | # else /* unknown architecture */ 478 | # define ARCHITECTURE_ID "" 479 | # endif 480 | 481 | #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) 482 | # if defined(__ICCARM__) 483 | # define ARCHITECTURE_ID "ARM" 484 | 485 | # elif defined(__ICCAVR__) 486 | # define ARCHITECTURE_ID "AVR" 487 | 488 | # else /* unknown architecture */ 489 | # define ARCHITECTURE_ID "" 490 | # endif 491 | #else 492 | # define ARCHITECTURE_ID 493 | #endif 494 | 495 | /* Convert integer to decimal digit literals. */ 496 | #define DEC(n) \ 497 | ('0' + (((n) / 10000000)%10)), \ 498 | ('0' + (((n) / 1000000)%10)), \ 499 | ('0' + (((n) / 100000)%10)), \ 500 | ('0' + (((n) / 10000)%10)), \ 501 | ('0' + (((n) / 1000)%10)), \ 502 | ('0' + (((n) / 100)%10)), \ 503 | ('0' + (((n) / 10)%10)), \ 504 | ('0' + ((n) % 10)) 505 | 506 | /* Convert integer to hex digit literals. */ 507 | #define HEX(n) \ 508 | ('0' + ((n)>>28 & 0xF)), \ 509 | ('0' + ((n)>>24 & 0xF)), \ 510 | ('0' + ((n)>>20 & 0xF)), \ 511 | ('0' + ((n)>>16 & 0xF)), \ 512 | ('0' + ((n)>>12 & 0xF)), \ 513 | ('0' + ((n)>>8 & 0xF)), \ 514 | ('0' + ((n)>>4 & 0xF)), \ 515 | ('0' + ((n) & 0xF)) 516 | 517 | /* Construct a string literal encoding the version number components. */ 518 | #ifdef COMPILER_VERSION_MAJOR 519 | char const info_version[] = { 520 | 'I', 'N', 'F', 'O', ':', 521 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 522 | COMPILER_VERSION_MAJOR, 523 | # ifdef COMPILER_VERSION_MINOR 524 | '.', COMPILER_VERSION_MINOR, 525 | # ifdef COMPILER_VERSION_PATCH 526 | '.', COMPILER_VERSION_PATCH, 527 | # ifdef COMPILER_VERSION_TWEAK 528 | '.', COMPILER_VERSION_TWEAK, 529 | # endif 530 | # endif 531 | # endif 532 | ']','\0'}; 533 | #endif 534 | 535 | /* Construct a string literal encoding the internal version number. */ 536 | #ifdef COMPILER_VERSION_INTERNAL 537 | char const info_version_internal[] = { 538 | 'I', 'N', 'F', 'O', ':', 539 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', 540 | 'i','n','t','e','r','n','a','l','[', 541 | COMPILER_VERSION_INTERNAL,']','\0'}; 542 | #endif 543 | 544 | /* Construct a string literal encoding the version number components. */ 545 | #ifdef SIMULATE_VERSION_MAJOR 546 | char const info_simulate_version[] = { 547 | 'I', 'N', 'F', 'O', ':', 548 | 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', 549 | SIMULATE_VERSION_MAJOR, 550 | # ifdef SIMULATE_VERSION_MINOR 551 | '.', SIMULATE_VERSION_MINOR, 552 | # ifdef SIMULATE_VERSION_PATCH 553 | '.', SIMULATE_VERSION_PATCH, 554 | # ifdef SIMULATE_VERSION_TWEAK 555 | '.', SIMULATE_VERSION_TWEAK, 556 | # endif 557 | # endif 558 | # endif 559 | ']','\0'}; 560 | #endif 561 | 562 | /* Construct the string literal in pieces to prevent the source from 563 | getting matched. Store it in a pointer rather than an array 564 | because some compilers will just produce instructions to fill the 565 | array rather than assigning a pointer to a static array. */ 566 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 567 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 568 | 569 | 570 | 571 | 572 | #if !defined(__STDC__) 573 | # if (defined(_MSC_VER) && !defined(__clang__)) \ 574 | || (defined(__ibmxl__) || defined(__IBMC__)) 575 | # define C_DIALECT "90" 576 | # else 577 | # define C_DIALECT 578 | # endif 579 | #elif __STDC_VERSION__ >= 201000L 580 | # define C_DIALECT "11" 581 | #elif __STDC_VERSION__ >= 199901L 582 | # define C_DIALECT "99" 583 | #else 584 | # define C_DIALECT "90" 585 | #endif 586 | const char* info_language_dialect_default = 587 | "INFO" ":" "dialect_default[" C_DIALECT "]"; 588 | 589 | /*--------------------------------------------------------------------------*/ 590 | 591 | #ifdef ID_VOID_MAIN 592 | void main() {} 593 | #else 594 | # if defined(__CLASSIC_C__) 595 | int main(argc, argv) int argc; char *argv[]; 596 | # else 597 | int main(int argc, char* argv[]) 598 | # endif 599 | { 600 | int require = 0; 601 | require += info_compiler[argc]; 602 | require += info_platform[argc]; 603 | require += info_arch[argc]; 604 | #ifdef COMPILER_VERSION_MAJOR 605 | require += info_version[argc]; 606 | #endif 607 | #ifdef COMPILER_VERSION_INTERNAL 608 | require += info_version_internal[argc]; 609 | #endif 610 | #ifdef SIMULATE_ID 611 | require += info_simulate[argc]; 612 | #endif 613 | #ifdef SIMULATE_VERSION_MAJOR 614 | require += info_simulate_version[argc]; 615 | #endif 616 | #if defined(__CRAYXE) || defined(__CRAYXC) 617 | require += info_cray[argc]; 618 | #endif 619 | require += info_language_dialect_default[argc]; 620 | (void)argv; 621 | return require; 622 | } 623 | #endif 624 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/CMakeFiles/3.11.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CompilerIdCXX/CMakeCXXCompilerId.cpp: -------------------------------------------------------------------------------- 1 | /* This source file must have a .cpp extension so that all C++ compilers 2 | recognize the extension without flags. Borland does not know .cxx for 3 | example. */ 4 | #ifndef __cplusplus 5 | # error "A C compiler has been selected for C++." 6 | #endif 7 | 8 | 9 | /* Version number components: V=Version, R=Revision, P=Patch 10 | Version date components: YYYY=Year, MM=Month, DD=Day */ 11 | 12 | #if defined(__COMO__) 13 | # define COMPILER_ID "Comeau" 14 | /* __COMO_VERSION__ = VRR */ 15 | # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) 16 | # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) 17 | 18 | #elif defined(__INTEL_COMPILER) || defined(__ICC) 19 | # define COMPILER_ID "Intel" 20 | # if defined(_MSC_VER) 21 | # define SIMULATE_ID "MSVC" 22 | # endif 23 | /* __INTEL_COMPILER = VRP */ 24 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 25 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 26 | # if defined(__INTEL_COMPILER_UPDATE) 27 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) 28 | # else 29 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 30 | # endif 31 | # if defined(__INTEL_COMPILER_BUILD_DATE) 32 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 33 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 34 | # endif 35 | # if defined(_MSC_VER) 36 | /* _MSC_VER = VVRR */ 37 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 38 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 39 | # endif 40 | 41 | #elif defined(__PATHCC__) 42 | # define COMPILER_ID "PathScale" 43 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 44 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 45 | # if defined(__PATHCC_PATCHLEVEL__) 46 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 47 | # endif 48 | 49 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 50 | # define COMPILER_ID "Embarcadero" 51 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 52 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 53 | # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) 54 | 55 | #elif defined(__BORLANDC__) 56 | # define COMPILER_ID "Borland" 57 | /* __BORLANDC__ = 0xVRR */ 58 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 59 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 60 | 61 | #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 62 | # define COMPILER_ID "Watcom" 63 | /* __WATCOMC__ = VVRR */ 64 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 65 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 66 | # if (__WATCOMC__ % 10) > 0 67 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 68 | # endif 69 | 70 | #elif defined(__WATCOMC__) 71 | # define COMPILER_ID "OpenWatcom" 72 | /* __WATCOMC__ = VVRP + 1100 */ 73 | # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) 74 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 75 | # if (__WATCOMC__ % 10) > 0 76 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 77 | # endif 78 | 79 | #elif defined(__SUNPRO_CC) 80 | # define COMPILER_ID "SunPro" 81 | # if __SUNPRO_CC >= 0x5100 82 | /* __SUNPRO_CC = 0xVRRP */ 83 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) 84 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) 85 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 86 | # else 87 | /* __SUNPRO_CC = 0xVRP */ 88 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) 89 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) 90 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 91 | # endif 92 | 93 | #elif defined(__HP_aCC) 94 | # define COMPILER_ID "HP" 95 | /* __HP_aCC = VVRRPP */ 96 | # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) 97 | # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) 98 | # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) 99 | 100 | #elif defined(__DECCXX) 101 | # define COMPILER_ID "Compaq" 102 | /* __DECCXX_VER = VVRRTPPPP */ 103 | # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) 104 | # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) 105 | # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) 106 | 107 | #elif defined(__IBMCPP__) && defined(__COMPILER_VER__) 108 | # define COMPILER_ID "zOS" 109 | # if defined(__ibmxl__) 110 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 111 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 112 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 113 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 114 | # else 115 | /* __IBMCPP__ = VRP */ 116 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 117 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 118 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 119 | # endif 120 | 121 | 122 | #elif defined(__ibmxl__) || (defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800) 123 | # define COMPILER_ID "XL" 124 | # if defined(__ibmxl__) 125 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 126 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 127 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 128 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 129 | # else 130 | /* __IBMCPP__ = VRP */ 131 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 132 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 133 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 134 | # endif 135 | 136 | 137 | #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 138 | # define COMPILER_ID "VisualAge" 139 | # if defined(__ibmxl__) 140 | # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) 141 | # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) 142 | # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) 143 | # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) 144 | # else 145 | /* __IBMCPP__ = VRP */ 146 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 147 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 148 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 149 | # endif 150 | 151 | 152 | #elif defined(__PGI) 153 | # define COMPILER_ID "PGI" 154 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 155 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 156 | # if defined(__PGIC_PATCHLEVEL__) 157 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 158 | # endif 159 | 160 | #elif defined(_CRAYC) 161 | # define COMPILER_ID "Cray" 162 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) 163 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 164 | 165 | #elif defined(__TI_COMPILER_VERSION__) 166 | # define COMPILER_ID "TI" 167 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 168 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 169 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 170 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 171 | 172 | #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) 173 | # define COMPILER_ID "Fujitsu" 174 | 175 | #elif defined(__SCO_VERSION__) 176 | # define COMPILER_ID "SCO" 177 | 178 | #elif defined(__clang__) && defined(__apple_build_version__) 179 | # define COMPILER_ID "AppleClang" 180 | # if defined(_MSC_VER) 181 | # define SIMULATE_ID "MSVC" 182 | # endif 183 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 184 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 185 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 186 | # if defined(_MSC_VER) 187 | /* _MSC_VER = VVRR */ 188 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 189 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 190 | # endif 191 | # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) 192 | 193 | #elif defined(__clang__) 194 | # define COMPILER_ID "Clang" 195 | # if defined(_MSC_VER) 196 | # define SIMULATE_ID "MSVC" 197 | # endif 198 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 199 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 200 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 201 | # if defined(_MSC_VER) 202 | /* _MSC_VER = VVRR */ 203 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 204 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 205 | # endif 206 | 207 | #elif defined(__GNUC__) || defined(__GNUG__) 208 | # define COMPILER_ID "GNU" 209 | # if defined(__GNUC__) 210 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 211 | # else 212 | # define COMPILER_VERSION_MAJOR DEC(__GNUG__) 213 | # endif 214 | # if defined(__GNUC_MINOR__) 215 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 216 | # endif 217 | # if defined(__GNUC_PATCHLEVEL__) 218 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 219 | # endif 220 | 221 | #elif defined(_MSC_VER) 222 | # define COMPILER_ID "MSVC" 223 | /* _MSC_VER = VVRR */ 224 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 225 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 226 | # if defined(_MSC_FULL_VER) 227 | # if _MSC_VER >= 1400 228 | /* _MSC_FULL_VER = VVRRPPPPP */ 229 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 230 | # else 231 | /* _MSC_FULL_VER = VVRRPPPP */ 232 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 233 | # endif 234 | # endif 235 | # if defined(_MSC_BUILD) 236 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 237 | # endif 238 | 239 | #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 240 | # define COMPILER_ID "ADSP" 241 | #if defined(__VISUALDSPVERSION__) 242 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 243 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 244 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 245 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 246 | #endif 247 | 248 | #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) 249 | # define COMPILER_ID "IAR" 250 | # if defined(__VER__) 251 | # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) 252 | # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) 253 | # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) 254 | # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) 255 | # endif 256 | 257 | #elif defined(__ARMCC_VERSION) 258 | # define COMPILER_ID "ARMCC" 259 | #if __ARMCC_VERSION >= 1000000 260 | /* __ARMCC_VERSION = VRRPPPP */ 261 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) 262 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) 263 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 264 | #else 265 | /* __ARMCC_VERSION = VRPPPP */ 266 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) 267 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) 268 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 269 | #endif 270 | 271 | 272 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 273 | # define COMPILER_ID "MIPSpro" 274 | # if defined(_SGI_COMPILER_VERSION) 275 | /* _SGI_COMPILER_VERSION = VRP */ 276 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 277 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 278 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 279 | # else 280 | /* _COMPILER_VERSION = VRP */ 281 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 282 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 283 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 284 | # endif 285 | 286 | 287 | /* These compilers are either not known or too old to define an 288 | identification macro. Try to identify the platform and guess that 289 | it is the native compiler. */ 290 | #elif defined(__sgi) 291 | # define COMPILER_ID "MIPSpro" 292 | 293 | #elif defined(__hpux) || defined(__hpua) 294 | # define COMPILER_ID "HP" 295 | 296 | #else /* unknown compiler */ 297 | # define COMPILER_ID "" 298 | #endif 299 | 300 | /* Construct the string literal in pieces to prevent the source from 301 | getting matched. Store it in a pointer rather than an array 302 | because some compilers will just produce instructions to fill the 303 | array rather than assigning a pointer to a static array. */ 304 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 305 | #ifdef SIMULATE_ID 306 | char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; 307 | #endif 308 | 309 | #ifdef __QNXNTO__ 310 | char const* qnxnto = "INFO" ":" "qnxnto[]"; 311 | #endif 312 | 313 | #if defined(__CRAYXE) || defined(__CRAYXC) 314 | char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; 315 | #endif 316 | 317 | #define STRINGIFY_HELPER(X) #X 318 | #define STRINGIFY(X) STRINGIFY_HELPER(X) 319 | 320 | /* Identify known platforms by name. */ 321 | #if defined(__linux) || defined(__linux__) || defined(linux) 322 | # define PLATFORM_ID "Linux" 323 | 324 | #elif defined(__CYGWIN__) 325 | # define PLATFORM_ID "Cygwin" 326 | 327 | #elif defined(__MINGW32__) 328 | # define PLATFORM_ID "MinGW" 329 | 330 | #elif defined(__APPLE__) 331 | # define PLATFORM_ID "Darwin" 332 | 333 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 334 | # define PLATFORM_ID "Windows" 335 | 336 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 337 | # define PLATFORM_ID "FreeBSD" 338 | 339 | #elif defined(__NetBSD__) || defined(__NetBSD) 340 | # define PLATFORM_ID "NetBSD" 341 | 342 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 343 | # define PLATFORM_ID "OpenBSD" 344 | 345 | #elif defined(__sun) || defined(sun) 346 | # define PLATFORM_ID "SunOS" 347 | 348 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 349 | # define PLATFORM_ID "AIX" 350 | 351 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 352 | # define PLATFORM_ID "IRIX" 353 | 354 | #elif defined(__hpux) || defined(__hpux__) 355 | # define PLATFORM_ID "HP-UX" 356 | 357 | #elif defined(__HAIKU__) 358 | # define PLATFORM_ID "Haiku" 359 | 360 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 361 | # define PLATFORM_ID "BeOS" 362 | 363 | #elif defined(__QNX__) || defined(__QNXNTO__) 364 | # define PLATFORM_ID "QNX" 365 | 366 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 367 | # define PLATFORM_ID "Tru64" 368 | 369 | #elif defined(__riscos) || defined(__riscos__) 370 | # define PLATFORM_ID "RISCos" 371 | 372 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 373 | # define PLATFORM_ID "SINIX" 374 | 375 | #elif defined(__UNIX_SV__) 376 | # define PLATFORM_ID "UNIX_SV" 377 | 378 | #elif defined(__bsdos__) 379 | # define PLATFORM_ID "BSDOS" 380 | 381 | #elif defined(_MPRAS) || defined(MPRAS) 382 | # define PLATFORM_ID "MP-RAS" 383 | 384 | #elif defined(__osf) || defined(__osf__) 385 | # define PLATFORM_ID "OSF1" 386 | 387 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 388 | # define PLATFORM_ID "SCO_SV" 389 | 390 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 391 | # define PLATFORM_ID "ULTRIX" 392 | 393 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 394 | # define PLATFORM_ID "Xenix" 395 | 396 | #elif defined(__WATCOMC__) 397 | # if defined(__LINUX__) 398 | # define PLATFORM_ID "Linux" 399 | 400 | # elif defined(__DOS__) 401 | # define PLATFORM_ID "DOS" 402 | 403 | # elif defined(__OS2__) 404 | # define PLATFORM_ID "OS2" 405 | 406 | # elif defined(__WINDOWS__) 407 | # define PLATFORM_ID "Windows3x" 408 | 409 | # else /* unknown platform */ 410 | # define PLATFORM_ID 411 | # endif 412 | 413 | #else /* unknown platform */ 414 | # define PLATFORM_ID 415 | 416 | #endif 417 | 418 | /* For windows compilers MSVC and Intel we can determine 419 | the architecture of the compiler being used. This is because 420 | the compilers do not have flags that can change the architecture, 421 | but rather depend on which compiler is being used 422 | */ 423 | #if defined(_WIN32) && defined(_MSC_VER) 424 | # if defined(_M_IA64) 425 | # define ARCHITECTURE_ID "IA64" 426 | 427 | # elif defined(_M_X64) || defined(_M_AMD64) 428 | # define ARCHITECTURE_ID "x64" 429 | 430 | # elif defined(_M_IX86) 431 | # define ARCHITECTURE_ID "X86" 432 | 433 | # elif defined(_M_ARM64) 434 | # define ARCHITECTURE_ID "ARM64" 435 | 436 | # elif defined(_M_ARM) 437 | # if _M_ARM == 4 438 | # define ARCHITECTURE_ID "ARMV4I" 439 | # elif _M_ARM == 5 440 | # define ARCHITECTURE_ID "ARMV5I" 441 | # else 442 | # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) 443 | # endif 444 | 445 | # elif defined(_M_MIPS) 446 | # define ARCHITECTURE_ID "MIPS" 447 | 448 | # elif defined(_M_SH) 449 | # define ARCHITECTURE_ID "SHx" 450 | 451 | # else /* unknown architecture */ 452 | # define ARCHITECTURE_ID "" 453 | # endif 454 | 455 | #elif defined(__WATCOMC__) 456 | # if defined(_M_I86) 457 | # define ARCHITECTURE_ID "I86" 458 | 459 | # elif defined(_M_IX86) 460 | # define ARCHITECTURE_ID "X86" 461 | 462 | # else /* unknown architecture */ 463 | # define ARCHITECTURE_ID "" 464 | # endif 465 | 466 | #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) 467 | # if defined(__ICCARM__) 468 | # define ARCHITECTURE_ID "ARM" 469 | 470 | # elif defined(__ICCAVR__) 471 | # define ARCHITECTURE_ID "AVR" 472 | 473 | # else /* unknown architecture */ 474 | # define ARCHITECTURE_ID "" 475 | # endif 476 | #else 477 | # define ARCHITECTURE_ID 478 | #endif 479 | 480 | /* Convert integer to decimal digit literals. */ 481 | #define DEC(n) \ 482 | ('0' + (((n) / 10000000)%10)), \ 483 | ('0' + (((n) / 1000000)%10)), \ 484 | ('0' + (((n) / 100000)%10)), \ 485 | ('0' + (((n) / 10000)%10)), \ 486 | ('0' + (((n) / 1000)%10)), \ 487 | ('0' + (((n) / 100)%10)), \ 488 | ('0' + (((n) / 10)%10)), \ 489 | ('0' + ((n) % 10)) 490 | 491 | /* Convert integer to hex digit literals. */ 492 | #define HEX(n) \ 493 | ('0' + ((n)>>28 & 0xF)), \ 494 | ('0' + ((n)>>24 & 0xF)), \ 495 | ('0' + ((n)>>20 & 0xF)), \ 496 | ('0' + ((n)>>16 & 0xF)), \ 497 | ('0' + ((n)>>12 & 0xF)), \ 498 | ('0' + ((n)>>8 & 0xF)), \ 499 | ('0' + ((n)>>4 & 0xF)), \ 500 | ('0' + ((n) & 0xF)) 501 | 502 | /* Construct a string literal encoding the version number components. */ 503 | #ifdef COMPILER_VERSION_MAJOR 504 | char const info_version[] = { 505 | 'I', 'N', 'F', 'O', ':', 506 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 507 | COMPILER_VERSION_MAJOR, 508 | # ifdef COMPILER_VERSION_MINOR 509 | '.', COMPILER_VERSION_MINOR, 510 | # ifdef COMPILER_VERSION_PATCH 511 | '.', COMPILER_VERSION_PATCH, 512 | # ifdef COMPILER_VERSION_TWEAK 513 | '.', COMPILER_VERSION_TWEAK, 514 | # endif 515 | # endif 516 | # endif 517 | ']','\0'}; 518 | #endif 519 | 520 | /* Construct a string literal encoding the internal version number. */ 521 | #ifdef COMPILER_VERSION_INTERNAL 522 | char const info_version_internal[] = { 523 | 'I', 'N', 'F', 'O', ':', 524 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', 525 | 'i','n','t','e','r','n','a','l','[', 526 | COMPILER_VERSION_INTERNAL,']','\0'}; 527 | #endif 528 | 529 | /* Construct a string literal encoding the version number components. */ 530 | #ifdef SIMULATE_VERSION_MAJOR 531 | char const info_simulate_version[] = { 532 | 'I', 'N', 'F', 'O', ':', 533 | 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', 534 | SIMULATE_VERSION_MAJOR, 535 | # ifdef SIMULATE_VERSION_MINOR 536 | '.', SIMULATE_VERSION_MINOR, 537 | # ifdef SIMULATE_VERSION_PATCH 538 | '.', SIMULATE_VERSION_PATCH, 539 | # ifdef SIMULATE_VERSION_TWEAK 540 | '.', SIMULATE_VERSION_TWEAK, 541 | # endif 542 | # endif 543 | # endif 544 | ']','\0'}; 545 | #endif 546 | 547 | /* Construct the string literal in pieces to prevent the source from 548 | getting matched. Store it in a pointer rather than an array 549 | because some compilers will just produce instructions to fill the 550 | array rather than assigning a pointer to a static array. */ 551 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 552 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 553 | 554 | 555 | 556 | 557 | #if defined(_MSC_VER) && defined(_MSVC_LANG) 558 | #define CXX_STD _MSVC_LANG 559 | #else 560 | #define CXX_STD __cplusplus 561 | #endif 562 | 563 | const char* info_language_dialect_default = "INFO" ":" "dialect_default[" 564 | #if CXX_STD > 201402L 565 | "17" 566 | #elif CXX_STD >= 201402L 567 | "14" 568 | #elif CXX_STD >= 201103L 569 | "11" 570 | #else 571 | "98" 572 | #endif 573 | "]"; 574 | 575 | /*--------------------------------------------------------------------------*/ 576 | 577 | int main(int argc, char* argv[]) 578 | { 579 | int require = 0; 580 | require += info_compiler[argc]; 581 | require += info_platform[argc]; 582 | #ifdef COMPILER_VERSION_MAJOR 583 | require += info_version[argc]; 584 | #endif 585 | #ifdef COMPILER_VERSION_INTERNAL 586 | require += info_version_internal[argc]; 587 | #endif 588 | #ifdef SIMULATE_ID 589 | require += info_simulate[argc]; 590 | #endif 591 | #ifdef SIMULATE_VERSION_MAJOR 592 | require += info_simulate_version[argc]; 593 | #endif 594 | #if defined(__CRAYXE) || defined(__CRAYXC) 595 | require += info_cray[argc]; 596 | #endif 597 | require += info_language_dialect_default[argc]; 598 | (void)argv; 599 | return require; 600 | } 601 | -------------------------------------------------------------------------------- /code/CMakeFiles/3.11.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/CMakeFiles/3.11.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /code/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /code/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /code/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "C_FEATURE:" 4 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /code/CMakeFiles/feature_tests.cxx: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "CXX_FEATURE:" 4 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_aggregate_nsdmi) 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "cxx_aggregate_default_initializers\n" 10 | "CXX_FEATURE:" 11 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alias_templates) 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "cxx_alias_templates\n" 17 | "CXX_FEATURE:" 18 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alignas) 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "cxx_alignas\n" 24 | "CXX_FEATURE:" 25 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alignas) 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "cxx_alignof\n" 31 | "CXX_FEATURE:" 32 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_attributes) 33 | "1" 34 | #else 35 | "0" 36 | #endif 37 | "cxx_attributes\n" 38 | "CXX_FEATURE:" 39 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 40 | "1" 41 | #else 42 | "0" 43 | #endif 44 | "cxx_attribute_deprecated\n" 45 | "CXX_FEATURE:" 46 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_auto_type) 47 | "1" 48 | #else 49 | "0" 50 | #endif 51 | "cxx_auto_type\n" 52 | "CXX_FEATURE:" 53 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_binary_literals) 54 | "1" 55 | #else 56 | "0" 57 | #endif 58 | "cxx_binary_literals\n" 59 | "CXX_FEATURE:" 60 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_constexpr) 61 | "1" 62 | #else 63 | "0" 64 | #endif 65 | "cxx_constexpr\n" 66 | "CXX_FEATURE:" 67 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_contextual_conversions) 68 | "1" 69 | #else 70 | "0" 71 | #endif 72 | "cxx_contextual_conversions\n" 73 | "CXX_FEATURE:" 74 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_decltype) 75 | "1" 76 | #else 77 | "0" 78 | #endif 79 | "cxx_decltype\n" 80 | "CXX_FEATURE:" 81 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 82 | "1" 83 | #else 84 | "0" 85 | #endif 86 | "cxx_decltype_auto\n" 87 | "CXX_FEATURE:" 88 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_decltype_incomplete_return_types) 89 | "1" 90 | #else 91 | "0" 92 | #endif 93 | "cxx_decltype_incomplete_return_types\n" 94 | "CXX_FEATURE:" 95 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_default_function_template_args) 96 | "1" 97 | #else 98 | "0" 99 | #endif 100 | "cxx_default_function_template_args\n" 101 | "CXX_FEATURE:" 102 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_defaulted_functions) 103 | "1" 104 | #else 105 | "0" 106 | #endif 107 | "cxx_defaulted_functions\n" 108 | "CXX_FEATURE:" 109 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_defaulted_functions) 110 | "1" 111 | #else 112 | "0" 113 | #endif 114 | "cxx_defaulted_move_initializers\n" 115 | "CXX_FEATURE:" 116 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_delegating_constructors) 117 | "1" 118 | #else 119 | "0" 120 | #endif 121 | "cxx_delegating_constructors\n" 122 | "CXX_FEATURE:" 123 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_deleted_functions) 124 | "1" 125 | #else 126 | "0" 127 | #endif 128 | "cxx_deleted_functions\n" 129 | "CXX_FEATURE:" 130 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 131 | "1" 132 | #else 133 | "0" 134 | #endif 135 | "cxx_digit_separators\n" 136 | "CXX_FEATURE:" 137 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 138 | "1" 139 | #else 140 | "0" 141 | #endif 142 | "cxx_enum_forward_declarations\n" 143 | "CXX_FEATURE:" 144 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_explicit_conversions) 145 | "1" 146 | #else 147 | "0" 148 | #endif 149 | "cxx_explicit_conversions\n" 150 | "CXX_FEATURE:" 151 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 152 | "1" 153 | #else 154 | "0" 155 | #endif 156 | "cxx_extended_friend_declarations\n" 157 | "CXX_FEATURE:" 158 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 159 | "1" 160 | #else 161 | "0" 162 | #endif 163 | "cxx_extern_templates\n" 164 | "CXX_FEATURE:" 165 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_override_control) 166 | "1" 167 | #else 168 | "0" 169 | #endif 170 | "cxx_final\n" 171 | "CXX_FEATURE:" 172 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 173 | "1" 174 | #else 175 | "0" 176 | #endif 177 | "cxx_func_identifier\n" 178 | "CXX_FEATURE:" 179 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_generalized_initializers) 180 | "1" 181 | #else 182 | "0" 183 | #endif 184 | "cxx_generalized_initializers\n" 185 | "CXX_FEATURE:" 186 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 187 | "1" 188 | #else 189 | "0" 190 | #endif 191 | "cxx_generic_lambdas\n" 192 | "CXX_FEATURE:" 193 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_inheriting_constructors) 194 | "1" 195 | #else 196 | "0" 197 | #endif 198 | "cxx_inheriting_constructors\n" 199 | "CXX_FEATURE:" 200 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 201 | "1" 202 | #else 203 | "0" 204 | #endif 205 | "cxx_inline_namespaces\n" 206 | "CXX_FEATURE:" 207 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_lambdas) 208 | "1" 209 | #else 210 | "0" 211 | #endif 212 | "cxx_lambdas\n" 213 | "CXX_FEATURE:" 214 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_init_captures) 215 | "1" 216 | #else 217 | "0" 218 | #endif 219 | "cxx_lambda_init_captures\n" 220 | "CXX_FEATURE:" 221 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_local_type_template_args) 222 | "1" 223 | #else 224 | "0" 225 | #endif 226 | "cxx_local_type_template_args\n" 227 | "CXX_FEATURE:" 228 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 229 | "1" 230 | #else 231 | "0" 232 | #endif 233 | "cxx_long_long_type\n" 234 | "CXX_FEATURE:" 235 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_noexcept) 236 | "1" 237 | #else 238 | "0" 239 | #endif 240 | "cxx_noexcept\n" 241 | "CXX_FEATURE:" 242 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_nonstatic_member_init) 243 | "1" 244 | #else 245 | "0" 246 | #endif 247 | "cxx_nonstatic_member_init\n" 248 | "CXX_FEATURE:" 249 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_nullptr) 250 | "1" 251 | #else 252 | "0" 253 | #endif 254 | "cxx_nullptr\n" 255 | "CXX_FEATURE:" 256 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_override_control) 257 | "1" 258 | #else 259 | "0" 260 | #endif 261 | "cxx_override\n" 262 | "CXX_FEATURE:" 263 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_range_for) 264 | "1" 265 | #else 266 | "0" 267 | #endif 268 | "cxx_range_for\n" 269 | "CXX_FEATURE:" 270 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_raw_string_literals) 271 | "1" 272 | #else 273 | "0" 274 | #endif 275 | "cxx_raw_string_literals\n" 276 | "CXX_FEATURE:" 277 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_reference_qualified_functions) 278 | "1" 279 | #else 280 | "0" 281 | #endif 282 | "cxx_reference_qualified_functions\n" 283 | "CXX_FEATURE:" 284 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_relaxed_constexpr) 285 | "1" 286 | #else 287 | "0" 288 | #endif 289 | "cxx_relaxed_constexpr\n" 290 | "CXX_FEATURE:" 291 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_return_type_deduction) 292 | "1" 293 | #else 294 | "0" 295 | #endif 296 | "cxx_return_type_deduction\n" 297 | "CXX_FEATURE:" 298 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 299 | "1" 300 | #else 301 | "0" 302 | #endif 303 | "cxx_right_angle_brackets\n" 304 | "CXX_FEATURE:" 305 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_rvalue_references) 306 | "1" 307 | #else 308 | "0" 309 | #endif 310 | "cxx_rvalue_references\n" 311 | "CXX_FEATURE:" 312 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 313 | "1" 314 | #else 315 | "0" 316 | #endif 317 | "cxx_sizeof_member\n" 318 | "CXX_FEATURE:" 319 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_static_assert) 320 | "1" 321 | #else 322 | "0" 323 | #endif 324 | "cxx_static_assert\n" 325 | "CXX_FEATURE:" 326 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_strong_enums) 327 | "1" 328 | #else 329 | "0" 330 | #endif 331 | "cxx_strong_enums\n" 332 | "CXX_FEATURE:" 333 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 199711L 334 | "1" 335 | #else 336 | "0" 337 | #endif 338 | "cxx_template_template_parameters\n" 339 | "CXX_FEATURE:" 340 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_thread_local) 341 | "1" 342 | #else 343 | "0" 344 | #endif 345 | "cxx_thread_local\n" 346 | "CXX_FEATURE:" 347 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_trailing_return) 348 | "1" 349 | #else 350 | "0" 351 | #endif 352 | "cxx_trailing_return_types\n" 353 | "CXX_FEATURE:" 354 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_unicode_literals) 355 | "1" 356 | #else 357 | "0" 358 | #endif 359 | "cxx_unicode_literals\n" 360 | "CXX_FEATURE:" 361 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_generalized_initializers) 362 | "1" 363 | #else 364 | "0" 365 | #endif 366 | "cxx_uniform_initialization\n" 367 | "CXX_FEATURE:" 368 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_unrestricted_unions) 369 | "1" 370 | #else 371 | "0" 372 | #endif 373 | "cxx_unrestricted_unions\n" 374 | "CXX_FEATURE:" 375 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_user_literals) 376 | "1" 377 | #else 378 | "0" 379 | #endif 380 | "cxx_user_literals\n" 381 | "CXX_FEATURE:" 382 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_variable_templates) 383 | "1" 384 | #else 385 | "0" 386 | #endif 387 | "cxx_variable_templates\n" 388 | "CXX_FEATURE:" 389 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 390 | "1" 391 | #else 392 | "0" 393 | #endif 394 | "cxx_variadic_macros\n" 395 | "CXX_FEATURE:" 396 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_variadic_templates) 397 | "1" 398 | #else 399 | "0" 400 | #endif 401 | "cxx_variadic_templates\n" 402 | 403 | }; 404 | 405 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 406 | -------------------------------------------------------------------------------- /code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(OpenCV_DIR ~/opencv-3.4.1/build) 2 | cmake_minimum_required(VERSION 2.8) 3 | project( ImageComplete ) 4 | find_package( OpenCV REQUIRED ) 5 | add_executable( ImageComplete im_complete_opencv_constraint.cpp ) 6 | target_link_libraries( ImageComplete ${OpenCV_LIBS} ) 7 | set(CMAKE_CXX_FLAGS "-O6 -std=c++11 -Wall -ffast-math -msse2") 8 | -------------------------------------------------------------------------------- /code/ImageCompletionGUI.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/ImageCompletionGUI.zip -------------------------------------------------------------------------------- /code/Makefile: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.11 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | 7 | .PHONY : default_target 8 | 9 | # Allow only one "make -f Makefile2" at a time, but pass parallelism. 10 | .NOTPARALLEL: 11 | 12 | 13 | #============================================================================= 14 | # Special targets provided by cmake. 15 | 16 | # Disable implicit rules so canonical targets will work. 17 | .SUFFIXES: 18 | 19 | 20 | # Remove some rules from gmake that .SUFFIXES does not remove. 21 | SUFFIXES = 22 | 23 | .SUFFIXES: .hpux_make_needs_suffix_list 24 | 25 | 26 | # Suppress display of executed commands. 27 | $(VERBOSE).SILENT: 28 | 29 | 30 | # A target that is always out of date. 31 | cmake_force: 32 | 33 | .PHONY : cmake_force 34 | 35 | #============================================================================= 36 | # Set environment variables for the build. 37 | 38 | # The shell in which to execute make rules. 39 | SHELL = /bin/sh 40 | 41 | # The CMake executable. 42 | CMAKE_COMMAND = /usr/local/Cellar/cmake/3.11.1/bin/cmake 43 | 44 | # The command to remove a file. 45 | RM = /usr/local/Cellar/cmake/3.11.1/bin/cmake -E remove -f 46 | 47 | # Escaping for special characters. 48 | EQUALS = = 49 | 50 | # The top-level source directory on which CMake was run. 51 | CMAKE_SOURCE_DIR = /Users/yuantinghsieh/CS-766-Computer-Vision/code 52 | 53 | # The top-level build directory on which CMake was run. 54 | CMAKE_BINARY_DIR = /Users/yuantinghsieh/CS-766-Computer-Vision/code 55 | 56 | #============================================================================= 57 | # Targets provided globally by CMake. 58 | 59 | # Special rule for the target rebuild_cache 60 | rebuild_cache: 61 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." 62 | /usr/local/Cellar/cmake/3.11.1/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 63 | .PHONY : rebuild_cache 64 | 65 | # Special rule for the target rebuild_cache 66 | rebuild_cache/fast: rebuild_cache 67 | 68 | .PHONY : rebuild_cache/fast 69 | 70 | # Special rule for the target edit_cache 71 | edit_cache: 72 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." 73 | /usr/local/Cellar/cmake/3.11.1/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 74 | .PHONY : edit_cache 75 | 76 | # Special rule for the target edit_cache 77 | edit_cache/fast: edit_cache 78 | 79 | .PHONY : edit_cache/fast 80 | 81 | # The main all target 82 | all: cmake_check_build_system 83 | $(CMAKE_COMMAND) -E cmake_progress_start /Users/yuantinghsieh/CS-766-Computer-Vision/code/CMakeFiles /Users/yuantinghsieh/CS-766-Computer-Vision/code/CMakeFiles/progress.marks 84 | $(MAKE) -f CMakeFiles/Makefile2 all 85 | $(CMAKE_COMMAND) -E cmake_progress_start /Users/yuantinghsieh/CS-766-Computer-Vision/code/CMakeFiles 0 86 | .PHONY : all 87 | 88 | # The main clean target 89 | clean: 90 | $(MAKE) -f CMakeFiles/Makefile2 clean 91 | .PHONY : clean 92 | 93 | # The main clean target 94 | clean/fast: clean 95 | 96 | .PHONY : clean/fast 97 | 98 | # Prepare targets for installation. 99 | preinstall: all 100 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 101 | .PHONY : preinstall 102 | 103 | # Prepare targets for installation. 104 | preinstall/fast: 105 | $(MAKE) -f CMakeFiles/Makefile2 preinstall 106 | .PHONY : preinstall/fast 107 | 108 | # clear depends 109 | depend: 110 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 111 | .PHONY : depend 112 | 113 | #============================================================================= 114 | # Target rules for targets named ImageComplete 115 | 116 | # Build rule for target. 117 | ImageComplete: cmake_check_build_system 118 | $(MAKE) -f CMakeFiles/Makefile2 ImageComplete 119 | .PHONY : ImageComplete 120 | 121 | # fast build rule for target. 122 | ImageComplete/fast: 123 | $(MAKE) -f CMakeFiles/ImageComplete.dir/build.make CMakeFiles/ImageComplete.dir/build 124 | .PHONY : ImageComplete/fast 125 | 126 | im_complete_opencv_constraint.o: im_complete_opencv_constraint.cpp.o 127 | 128 | .PHONY : im_complete_opencv_constraint.o 129 | 130 | # target to build an object file 131 | im_complete_opencv_constraint.cpp.o: 132 | $(MAKE) -f CMakeFiles/ImageComplete.dir/build.make CMakeFiles/ImageComplete.dir/im_complete_opencv_constraint.cpp.o 133 | .PHONY : im_complete_opencv_constraint.cpp.o 134 | 135 | im_complete_opencv_constraint.i: im_complete_opencv_constraint.cpp.i 136 | 137 | .PHONY : im_complete_opencv_constraint.i 138 | 139 | # target to preprocess a source file 140 | im_complete_opencv_constraint.cpp.i: 141 | $(MAKE) -f CMakeFiles/ImageComplete.dir/build.make CMakeFiles/ImageComplete.dir/im_complete_opencv_constraint.cpp.i 142 | .PHONY : im_complete_opencv_constraint.cpp.i 143 | 144 | im_complete_opencv_constraint.s: im_complete_opencv_constraint.cpp.s 145 | 146 | .PHONY : im_complete_opencv_constraint.s 147 | 148 | # target to generate assembly for a file 149 | im_complete_opencv_constraint.cpp.s: 150 | $(MAKE) -f CMakeFiles/ImageComplete.dir/build.make CMakeFiles/ImageComplete.dir/im_complete_opencv_constraint.cpp.s 151 | .PHONY : im_complete_opencv_constraint.cpp.s 152 | 153 | # Help Target 154 | help: 155 | @echo "The following are some of the valid targets for this Makefile:" 156 | @echo "... all (the default if no target is provided)" 157 | @echo "... clean" 158 | @echo "... depend" 159 | @echo "... rebuild_cache" 160 | @echo "... edit_cache" 161 | @echo "... ImageComplete" 162 | @echo "... im_complete_opencv_constraint.o" 163 | @echo "... im_complete_opencv_constraint.i" 164 | @echo "... im_complete_opencv_constraint.s" 165 | .PHONY : help 166 | 167 | 168 | 169 | #============================================================================= 170 | # Special targets to cleanup operation of make. 171 | 172 | # Special rule to run CMake to check the build system integrity. 173 | # No rule that depends on this can have commands that come from listfiles 174 | # because they might be regenerated. 175 | cmake_check_build_system: 176 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 177 | .PHONY : cmake_check_build_system 178 | 179 | -------------------------------------------------------------------------------- /code/cow-mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/cow-mask.png -------------------------------------------------------------------------------- /code/cow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/cow.png -------------------------------------------------------------------------------- /code/final_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/final_out.png -------------------------------------------------------------------------------- /code/im_complete.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* ------------------------------------------------------------------------- 3 | Minimal (unoptimized) example of PatchMatch. Requires that ImageMagick be installed. 4 | 5 | To improve generality you can: 6 | - Use whichever distance function you want in dist(), e.g. compare SIFT descriptors computed densely. 7 | - Search over a larger search space, such as rotating+scaling patches (see MATLAB mex for examples of both) 8 | 9 | To improve speed you can: 10 | - Turn on optimizations (/Ox /Oi /Oy /fp:fast or -O6 -s -ffast-math -fomit-frame-pointer -fstrength-reduce -msse2 -funroll-loops) 11 | - Use the MATLAB mex which is already tuned for speed 12 | - Use multiple cores, tiling the input. See our publication "The Generalized PatchMatch Correspondence Algorithm" 13 | - Tune the distance computation: manually unroll loops for each patch size, use SSE instructions (see readme) 14 | - Precompute random search samples (to avoid using rand, and mod) 15 | - Move to the GPU 16 | -------------------------------------------------------------------------- */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #ifndef MAX 29 | #define MAX(a, b) ((a)>(b)?(a):(b)) 30 | #define MIN(a, b) ((a)<(b)?(a):(b)) 31 | #endif 32 | 33 | #define _DEBUG 34 | 35 | /* ------------------------------------------------------------------------- 36 | BITMAP: Minimal image class 37 | ------------------------------------------------------------------------- */ 38 | 39 | class BITMAP { public: 40 | int w, h; 41 | int *data; 42 | BITMAP(int w_, int h_) :w(w_), h(h_) { data = new int[w*h]; } 43 | BITMAP(BITMAP* bm) { 44 | w = bm->w; 45 | h = bm->h; 46 | data = new int[w*h]; 47 | for (int i = 0; i < w*h; ++i) { 48 | data[i] = bm->data[i]; 49 | } 50 | } 51 | ~BITMAP() { delete[] data; } 52 | int *operator[](int y) { return &data[y*w]; } 53 | }; 54 | 55 | void check_im() { 56 | int i; 57 | i = system("identify ../test-images/test1.jpg"); 58 | printf ("The value returned was: %d.\n",i); 59 | if (i != 0) { 60 | fprintf(stderr, "ImageMagick must be installed, and 'convert' and 'identify' must be in the path\n"); exit(1); 61 | } 62 | } 63 | 64 | BITMAP *load_bitmap(const char *filename) { 65 | // check_im(); 66 | char rawname[256], txtname[256]; 67 | strcpy(rawname, filename); 68 | strcpy(txtname, filename); 69 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error reading image '%s': no extension found\n", filename); exit(1); } 70 | sprintf(strstr(rawname, "."), ".raw"); 71 | sprintf(strstr(txtname, "."), ".txt"); 72 | char buf[256]; 73 | sprintf(buf, "convert %s rgba:%s", filename, rawname); 74 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 75 | sprintf(buf, "identify -format \"%%w %%h\" %s > %s", filename, txtname); 76 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick identify gave an error\n", filename); exit(1); } 77 | FILE *f = fopen(txtname, "rt"); 78 | if (!f) { fprintf(stderr, "Error reading image '%s': could not read output of ImageMagick identify\n", filename); exit(1); } 79 | int w = 0, h = 0; 80 | if (fscanf(f, "%d %d", &w, &h) != 2) { fprintf(stderr, "Error reading image '%s': could not get size from ImageMagick identify\n", filename); exit(1); } 81 | fclose(f); 82 | printf("(w, h) = (%d, %d)\n", w, h); 83 | f = fopen(rawname, "rb"); 84 | BITMAP *ans = new BITMAP(w, h); 85 | unsigned char *p = (unsigned char *) ans->data; 86 | for (int i = 0; i < w*h*4; i++) { 87 | int ch = fgetc(f); 88 | if (ch == EOF) { fprintf(stderr, "Error reading image '%s': raw file is smaller than expected size %dx%dx%d\n", filename, w, h, 4); exit(1); } 89 | *p++ = ch; 90 | } 91 | fclose(f); 92 | return ans; 93 | } 94 | 95 | void save_bitmap(BITMAP *bmp, const char *filename) { 96 | // check_im(); 97 | char rawname[256]; 98 | strcpy(rawname, filename); 99 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error writing image '%s': no extension found\n", filename); exit(1); } 100 | sprintf(strstr(rawname, "."), ".raw"); 101 | char buf[256]; 102 | //printf("rawname = %s\n", rawname); 103 | FILE *f = fopen(rawname, "wb"); 104 | if (!f) { fprintf(stderr, "Error writing image '%s': could not open raw temporary file\n", filename); exit(1); } 105 | unsigned char *p = (unsigned char *) bmp->data; 106 | for (int i = 0; i < bmp->w*bmp->h*4; i++) { 107 | fputc(*p++, f); 108 | } 109 | fclose(f); 110 | sprintf(buf, "convert -size %dx%d -depth 8 rgba:%s %s", bmp->w, bmp->h, rawname, filename); 111 | //printf("system returned value = %d\n", system(buf)); 112 | if (system(buf) != 0) { fprintf(stderr, "Error writing image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 113 | } 114 | 115 | /* ------------------------------------------------------------------------- 116 | PatchMatch, using L2 distance between upright patches that translate only 117 | ------------------------------------------------------------------------- */ 118 | 119 | int patch_w = 10; 120 | int pm_iters = 10; 121 | int rs_max = INT_MAX; // random search 122 | 123 | #define XY_TO_INT(x, y) (((y)<<12)|(x)) 124 | #define INT_TO_X(v) ((v)&((1<<12)-1)) 125 | #define INT_TO_Y(v) ((v)>>12) 126 | 127 | bool isHole(BITMAP *mask, int x, int y) { 128 | int c = (*mask)[y][x]; 129 | int r = c&255; 130 | int g = (c>>8)&255; 131 | int b = (c>>16)&255; 132 | 133 | // hole means non-black pixels in mask 134 | if (r != 0 || g != 0 || b != 0) { return true; } 135 | return false; 136 | } 137 | 138 | /* check if a pixel x, y is in the bounding box or not */ 139 | bool inBox(int x, int y, int box_xmin, int box_xmax, int box_ymin, int box_ymax) { 140 | if (x >= box_xmin && x <= box_xmax+patch_w && y >= box_ymin && y <= box_ymax+patch_w) { 141 | return true; 142 | } 143 | return false; 144 | } 145 | 146 | /* Measure distance between 2 patches with upper left corners (ax, ay) and (bx, by), terminating early if we exceed a cutoff distance. 147 | You could implement your own descriptor here. */ 148 | int dist(BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, BITMAP *mask, int cutoff=INT_MAX) { 149 | int ans = 0; 150 | int holeCount = 0; 151 | if (isHole(mask, ax, ay) && isHole(mask, ax+patch_w-1, ay+patch_w-1)) { return INT_MAX; } 152 | for (int dy = 0; dy < patch_w; dy++) { 153 | int *arow = &(*a)[ay+dy][ax]; 154 | int *brow = &(*b)[by+dy][bx]; 155 | for (int dx = 0; dx < patch_w; dx++) { 156 | if (isHole(mask, ax+dx, ay+dy)) { 157 | holeCount += 1; 158 | continue; 159 | } 160 | assert(!isHole(mask, bx+dx, by+dy)); 161 | int ac = arow[dx]; 162 | int bc = brow[dx]; 163 | int dr = (ac&255)-(bc&255); 164 | int dg = ((ac>>8)&255)-((bc>>8)&255); 165 | int db = (ac>>16)-(bc>>16); 166 | ans += dr*dr + dg*dg + db*db; 167 | } 168 | if (ans >= cutoff) { return cutoff; } 169 | } 170 | double percent = 1 - (double) holeCount / (patch_w*patch_w); 171 | ans = (int) (ans / percent); 172 | if (ans < 0) return INT_MAX; 173 | return ans; 174 | } 175 | 176 | void improve_guess(BITMAP *a, BITMAP *b, int ax, int ay, int &xbest, int &ybest, int &dbest, int bx, int by, BITMAP *mask, int type) { 177 | int d = dist(a, b, ax, ay, bx, by, mask, dbest); 178 | if ((d < dbest) && (ax != bx || ay != by) ) { 179 | #ifdef DEBUG 180 | if (type == 0) 181 | printf(" Prop x: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 182 | else if (type == 1) 183 | printf(" Prop y: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 184 | else 185 | printf(" Random: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 186 | #endif 187 | if (isHole(mask, ax, ay) && d == 0) { 188 | printf(" try improve (%d, %d) old dist %d new dist %d\n", ax, ay, dbest, d); 189 | printf(" try improve (%d, %d) old nn (%d, %d) new nn (%d, %d)\n", ax, ay, xbest, ybest, bx, by); 190 | return; 191 | } 192 | dbest = d; 193 | xbest = bx; 194 | ybest = by; 195 | } 196 | } 197 | 198 | /* Get the bounding box of hole */ 199 | void getBox(BITMAP *mask, int& xmin, int& xmax, int& ymin, int& ymax) { 200 | for (int h = 0; h < mask->h; h++) { 201 | for (int w = 0; w < mask->w; w++) { 202 | int c = (*mask)[h][w]; 203 | int r = c&255; 204 | int g = (c>>8)&255; 205 | int b = (c>>16)&255; 206 | // hole means non-black pixels in mask 207 | if (r != 0 || g != 0 || b != 0) { 208 | if (h < ymin) 209 | ymin = h; 210 | if (h > ymax) 211 | ymax = h; 212 | if (w < xmin) 213 | xmin = w; 214 | if (w > xmax) 215 | xmax = w; 216 | } 217 | } 218 | } 219 | xmin = xmin - patch_w + 1; 220 | ymin = ymin - patch_w + 1; 221 | xmin = (xmin < 0) ? 0 : xmin; 222 | ymin = (ymin < 0) ? 0 : ymin; 223 | 224 | xmax = (xmax > mask->w - patch_w + 1) ? mask->w - patch_w +1 : xmax; 225 | ymax = (ymax > mask->h - patch_w + 1) ? mask->h - patch_w +1 : ymax; 226 | 227 | printf("Hole's bounding box is x (%d, %d), y (%d, %d)\n", xmin, xmax, ymin, ymax); 228 | } 229 | 230 | BITMAP *norm_image(double *accum, int w, int h, BITMAP *ainit=NULL, BITMAP *mask=NULL) { 231 | BITMAP *ans = new BITMAP(w, h); 232 | for (int y = 0; y < h; y++) { 233 | int *row = (*ans)[y]; 234 | int *arow = NULL; 235 | if (ainit) 236 | arow = (*ainit)[y]; 237 | double *prow = &accum[4*(y*w)]; 238 | for (int x = 0; x < w; x++) { 239 | double *p = &prow[4*x]; 240 | int c = p[3] ? p[3]: 1; 241 | int c2 = c>>1; /* Changed: round() instead of floor. */ 242 | if (ainit) 243 | row[x] = p[3] ? int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24) : arow[x]; 244 | else 245 | row[x] = int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24); 246 | //if (mask && p[3] && isHole(mask, x, y)) 247 | // (*mask)[y][x] = 0; 248 | } 249 | } 250 | return ans; 251 | } 252 | 253 | /* Match image a to image b, returning the nearest neighbor field mapping a => b coords, stored in an RGB 24-bit image as (by<<12)|bx. */ 254 | void patchmatch(BITMAP *a, BITMAP *mask, BITMAP *&ans, BITMAP *&ann, BITMAP *&annd) { 255 | /* Initialize with random nearest neighbor field (NNF). */ 256 | ann = new BITMAP(a->w, a->h); 257 | annd = new BITMAP(a->w, a->h); 258 | //int aew = a->w - patch_w+1, aeh = a->h - patch_w + 1; /* Effective width and height (possible upper left corners of patches). */ 259 | int mew = mask->w - patch_w+1, meh = mask->h - patch_w + 1; 260 | memset(ann->data, 0, sizeof(int)*a->w*a->h); 261 | memset(annd->data, 0, sizeof(int)*a->w*a->h); 262 | 263 | 264 | int box_xmin, box_xmax, box_ymin, box_ymax; 265 | box_xmin = box_ymin = INT_MAX; 266 | box_xmax = box_ymax = 0; 267 | 268 | getBox(mask, box_xmin, box_xmax, box_ymin, box_ymax); 269 | 270 | // store original mask 271 | BITMAP *ori_mask = new BITMAP(mask); 272 | 273 | save_bitmap(ori_mask, "orimask.jpg"); 274 | 275 | int bx, by; 276 | // Initialization 277 | for (int ay = box_ymin; ay < box_ymax; ay++) { 278 | for (int ax = box_xmin; ax < box_xmax; ax++) { 279 | bool valid = false; 280 | while (!valid) { 281 | bx = rand()%mew; 282 | by = rand()%meh; 283 | // should find patches outside bounding box 284 | if (inBox(bx, by, box_xmin, box_xmax, box_ymin, box_ymax)) { 285 | // or outside the hole 286 | //if (isHole(mask, bx, by) && isHole(mask, bx+patch_w, by+patch_w)) { 287 | valid = false; 288 | } else { 289 | valid = true; 290 | } 291 | } 292 | (*ann)[ay][ax] = XY_TO_INT(bx, by); 293 | (*annd)[ay][ax] = dist(a, a, ax, ay, bx, by, mask); 294 | } 295 | } 296 | 297 | 298 | 299 | save_bitmap(ann, "ann_before.jpg"); 300 | save_bitmap(annd, "annd_before.jpg"); 301 | save_bitmap(mask, "mask_before.jpg"); 302 | //save_bitmap(a, "a_img_completion_initial.jpg"); 303 | 304 | // in each iter we have two mask, the old one and updated new one 305 | int w = 1; 306 | for (int iter = 0; iter < pm_iters; iter++) { 307 | // to store pixels in the new patch 308 | int sz = a->w*a->h; sz = sz << 2; // 4*w*h 309 | double* accum = new double[sz]; 310 | memset(accum, 0, sizeof(double)*sz ); 311 | 312 | BITMAP *new_mask = new BITMAP(mask); 313 | 314 | printf("iter = %d\n", iter); 315 | /* In each iteration, improve the NNF, by looping in scanline or reverse-scanline order. */ 316 | int ystart = box_ymin, yend = box_ymax, ychange = 1; 317 | int xstart = box_xmin, xend = box_xmax, xchange = 1; 318 | if (iter % 2 == 1) { 319 | xstart = box_xmax-1; xend = box_xmin-1; xchange = -1; 320 | ystart = box_ymax-1; yend = box_ymin-1; ychange = -1; 321 | } 322 | for (int ay = ystart; ay != yend; ay += ychange) { 323 | for (int ax = xstart; ax != xend; ax += xchange) { 324 | 325 | if (isHole(mask, ax, ay) && isHole(mask, ax + patch_w - 1, ay + patch_w - 1)) { 326 | continue; 327 | } 328 | 329 | /* Current (best) guess. */ 330 | int v = (*ann)[ay][ax]; 331 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 332 | int dbest = (*annd)[ay][ax]; 333 | 334 | /* Propagation: Improve current guess by trying instead correspondences from left and above (below and right on odd iterations). */ 335 | if ((unsigned) (ax - xchange) < (unsigned) mew) { 336 | //if (inBox(ax - xchange, ay, box_xmin, box_xmax, box_ymin, box_ymax)) { 337 | int vp = (*ann)[ay][ax-xchange]; 338 | int xp = INT_TO_X(vp) + xchange, yp = INT_TO_Y(vp); 339 | if (((unsigned) xp < (unsigned) mew) && !inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 340 | //if (((unsigned) xp < (unsigned) mew)) { 341 | //printf("Propagation x\n"); 342 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 0); 343 | } 344 | } 345 | 346 | if ((unsigned) (ay - ychange) < (unsigned) meh) { 347 | //if (inBox(ax, ay - ychange, box_xmin, box_xmax, box_ymin, box_ymax)) { 348 | int vp = (*ann)[ay-ychange][ax]; 349 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp) + ychange; 350 | if (((unsigned) yp < (unsigned) meh) && !inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 351 | //if (((unsigned) yp < (unsigned) meh)) { 352 | //printf("Propagation y\n"); 353 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 1); 354 | } 355 | } 356 | 357 | /* Random search: Improve current guess by searching in boxes of exponentially decreasing size around the current best guess. */ 358 | int rs_start = rs_max; 359 | if (rs_start > MAX(a->w, a->h)) { rs_start = MAX(a->w, a->h); } 360 | for (int mag = rs_start; mag >= 1; mag /= 2) { 361 | /* Sampling window */ 362 | int xmin = MAX(xbest-mag, 0), xmax = MIN(xbest+mag+1, mew); 363 | int ymin = MAX(ybest-mag, 0), ymax = MIN(ybest+mag+1, meh); 364 | int xp = xmin+rand()%(xmax-xmin); 365 | int yp = ymin+rand()%(ymax-ymin); 366 | if (!inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 367 | //printf("Random\n"); 368 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 2); 369 | } 370 | } 371 | 372 | (*ann)[ay][ax] = XY_TO_INT(xbest, ybest); 373 | (*annd)[ay][ax] = dbest; 374 | //if (isHole(mask, ax, ay)) 375 | // (*a)[ay][ax] = (*a)[ybest][xbest]; 376 | 377 | // fill pixels 378 | /* 379 | for (int dy = 0; dy < patch_w; dy++) { 380 | int* arow = (*a)[ay+dy] + ax; 381 | int* best_row = (*a)[ybest+dy] + xbest; 382 | for(int dx = 0; dx < patch_w; dx++) { 383 | if (!isHole(mask, ax+dx, ay+dy)) { continue; } 384 | arow[dx] = best_row[dx]; 385 | } 386 | } 387 | */ 388 | } 389 | } 390 | 391 | 392 | // fill in missing pixels 393 | for (int ay = box_ymin; ay < box_ymax; ay++) { 394 | for (int ax = box_xmin; ax < box_xmax; ax++) { 395 | 396 | if (isHole(mask, ax, ay) && isHole(mask, ax + patch_w - 1, ay + patch_w - 1)) { 397 | continue; 398 | } 399 | 400 | int vp = (*ann)[ay][ax]; 401 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp); 402 | for (int dy = 0; dy < patch_w; dy++) { 403 | int* arow = (*a)[yp+dy] + xp; 404 | double* prow = &accum[4*((ay+dy)*a->w + ax)]; 405 | for(int dx = 0; dx < patch_w; dx++) { 406 | if ((*annd)[yp+dy][xp+dx] == INT_MAX) { continue; } 407 | int c = arow[dx]; 408 | double* p = &prow[4*dx]; 409 | p[0] += (c&255)*w; 410 | p[1] += ((c>>8)&255)*w; 411 | p[2] += ((c>>16)&255)*w; 412 | p[3] += w; 413 | // change mask 414 | (*new_mask)[ay+dy][ax+dx] = 0; 415 | } 416 | } 417 | } 418 | } 419 | 420 | 421 | ans = norm_image(accum, a->w, a->h, NULL, mask); 422 | 423 | save_bitmap(ans, "ans.jpg"); 424 | 425 | // join with original picture 426 | for (int h = 0; h < a->h; h++) { 427 | for (int w = 0; w < a->w; w++) { 428 | if (!isHole(ori_mask, w, h)) { 429 | // if (!inBox(w, h, box_xmin, box_xmax, box_ymin, box_ymax)) { 430 | (*ans)[h][w] = 0 | (*a)[h][w]; 431 | } 432 | } 433 | } 434 | 435 | delete a; 436 | a = ans; 437 | 438 | // update distance (annd) 439 | for (int ay = box_ymin; ay < box_ymax; ay++) { 440 | for (int ax = box_xmin; ax < box_xmax; ax++) { 441 | int vp = (*ann)[ay][ax]; 442 | int bx = INT_TO_X(vp), by = INT_TO_Y(vp); 443 | (*annd)[ay][ax] = dist(a, a, ax, ay, bx, by, mask); 444 | } 445 | } 446 | 447 | 448 | std::stringstream ss; 449 | ss << iter; 450 | std::string a_file = "a_iter_" + ss.str() + ".jpg"; 451 | const char* a_ptr = a_file.c_str(); 452 | save_bitmap(a, a_ptr); 453 | 454 | std::string annd_file = "annd_iter_" + ss.str() + ".jpg"; 455 | const char* annd_ptr = annd_file.c_str(); 456 | save_bitmap(annd, annd_ptr); 457 | 458 | 459 | std::string mask_file = "mask_iter_" + ss.str() + ".jpg"; 460 | const char* mask_ptr = mask_file.c_str(); 461 | save_bitmap(mask, mask_ptr); 462 | 463 | 464 | delete mask; 465 | mask = new_mask; 466 | delete[] accum; 467 | } 468 | 469 | save_bitmap(a, "a_final.jpg"); 470 | save_bitmap(ann, "ann_after.jpg"); 471 | save_bitmap(annd, "annd_after.jpg"); 472 | 473 | 474 | } 475 | 476 | void tryIt(BITMAP* a, BITMAP *&ans, BITMAP *mask) { 477 | // fill in missing pixels 478 | //int ymin = 0, ymax = a->h - patch_w + 1; 479 | //int xmin = 0, xmax = a->w - patch_w + 1; 480 | int ymin = 200, ymax = 400; 481 | int xmin = 200, xmax = 400; 482 | // to store new pixels 483 | int sz = a->w*a->h; sz = sz << 2; // 4*w*h 484 | double* accum = new double[sz]; 485 | memset(accum, 0, sizeof(double)*sz ); 486 | 487 | int w = 1; 488 | for (int ay = ymin; ay < ymax; ay++) { 489 | for (int ax = xmin; ax < xmax; ax++) { 490 | int xp = ax - 200, yp = ay - 200; 491 | for (int dy = 0; dy < patch_w; dy++) { 492 | int* arow = (*a)[yp+dy] + xp; 493 | double* prow = &accum[4*((ay+dy)*a->w + ax)]; 494 | for(int dx = 0; dx < patch_w; dx++) { 495 | // if (!isHole(mask, ax+dx, ay+dy)) { continue; } 496 | int c = arow[dx]; 497 | double* p = &prow[4*dx]; 498 | p[0] += (c&255)*w; 499 | p[1] += ((c>>8)&255)*w; 500 | p[2] += ((c>>16)&255)*w; 501 | p[3] += w; 502 | // change mask 503 | // (*mask)[ay+dy][ax+dx] = 0; 504 | } 505 | } 506 | } 507 | } 508 | ans = norm_image(accum, a->w, a->h, a, mask); 509 | save_bitmap(ans, "try_ans.jpg"); 510 | 511 | // join with original picture 512 | for (int h = 0; h < a->h; h++) { 513 | for (int w = 0; w < a->w; w++) { 514 | if (!isHole(mask, w, h)) { 515 | //if (!inBox(w, h, box_xmin, box_xmax, box_ymin, box_ymax)) { 516 | (*ans)[h][w] = 0 | (*a)[h][w]; 517 | } 518 | } 519 | } 520 | save_bitmap(ans, "try_ans_join.jpg"); 521 | } 522 | 523 | void reconstruct(BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *&r) { 524 | r = new BITMAP(a->w, a->h); 525 | memset(r->data, 0, sizeof(int)*a->w*a->h); 526 | 527 | for (int h = 0; h < a->h; h++) 528 | { 529 | for (int w = 0; w < a->w; w++) 530 | { 531 | int v = (*ann)[h][w]; 532 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 533 | (*r)[h][w] = (*b)[ybest][xbest]; 534 | } 535 | } 536 | } 537 | 538 | 539 | int main(int argc, char *argv[]) { 540 | argc--; 541 | argv++; 542 | if (argc != 3) { fprintf(stderr, "im_complete a mask result\n" 543 | "Given input image a and mask outputs result\n" 544 | "These are stored as RGB 24-bit images, with a 24-bit int at every pixel. For the NNF we store (by<<12)|bx."); exit(1); } 545 | printf("(1) Loading input images\n"); 546 | BITMAP *a = load_bitmap(argv[0]); 547 | BITMAP *mask = load_bitmap(argv[1]); 548 | BITMAP *ans = NULL, *ann = NULL, *annd = NULL; 549 | 550 | //BITMAP *ans2 = NULL; 551 | //tryIt(a, ans2, mask); 552 | 553 | printf("\n(2) Running PatchMatch\n"); 554 | patchmatch(a, mask, ans, ann, annd); 555 | printf("\n(3) Saving output images: ans\n"); 556 | save_bitmap(ans, argv[2]); 557 | 558 | return 0; 559 | } 560 | -------------------------------------------------------------------------------- /code/im_complete_new.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* ------------------------------------------------------------------------- 3 | Minimal (unoptimized) example of PatchMatch. Requires that ImageMagick be installed. 4 | 5 | To improve generality you can: 6 | - Use whichever distance function you want in dist(), e.g. compare SIFT descriptors computed densely. 7 | - Search over a larger search space, such as rotating+scaling patches (see MATLAB mex for examples of both) 8 | 9 | To improve speed you can: 10 | - Turn on optimizations (/Ox /Oi /Oy /fp:fast or -O6 -s -ffast-math -fomit-frame-pointer -fstrength-reduce -msse2 -funroll-loops) 11 | - Use the MATLAB mex which is already tuned for speed 12 | - Use multiple cores, tiling the input. See our publication "The Generalized PatchMatch Correspondence Algorithm" 13 | - Tune the distance computation: manually unroll loops for each patch size, use SSE instructions (see readme) 14 | - Precompute random search samples (to avoid using rand, and mod) 15 | - Move to the GPU 16 | -------------------------------------------------------------------------- */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #ifndef MAX 29 | #define MAX(a, b) ((a)>(b)?(a):(b)) 30 | #define MIN(a, b) ((a)<(b)?(a):(b)) 31 | #endif 32 | 33 | #define _DEBUG 34 | 35 | /* ------------------------------------------------------------------------- 36 | BITMAP: Minimal image class 37 | ------------------------------------------------------------------------- */ 38 | 39 | class BITMAP { public: 40 | int w, h; 41 | int *data; 42 | BITMAP(int w_, int h_) :w(w_), h(h_) { data = new int[w*h]; } 43 | BITMAP(BITMAP* bm) { 44 | w = bm->w; 45 | h = bm->h; 46 | data = new int[w*h]; 47 | for (int i = 0; i < w*h; ++i) { 48 | data[i] = bm->data[i]; 49 | } 50 | } 51 | ~BITMAP() { delete[] data; } 52 | int *operator[](int y) { return &data[y*w]; } 53 | }; 54 | 55 | void check_im() { 56 | int i; 57 | i = system("identify ../test-images/test1.jpg"); 58 | printf ("The value returned was: %d.\n",i); 59 | if (i != 0) { 60 | fprintf(stderr, "ImageMagick must be installed, and 'convert' and 'identify' must be in the path\n"); exit(1); 61 | } 62 | } 63 | 64 | BITMAP *load_bitmap(const char *filename) { 65 | // check_im(); 66 | char rawname[256], txtname[256]; 67 | strcpy(rawname, filename); 68 | strcpy(txtname, filename); 69 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error reading image '%s': no extension found\n", filename); exit(1); } 70 | sprintf(strstr(rawname, "."), ".raw"); 71 | sprintf(strstr(txtname, "."), ".txt"); 72 | char buf[256]; 73 | sprintf(buf, "convert %s rgba:%s", filename, rawname); 74 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 75 | sprintf(buf, "identify -format \"%%w %%h\" %s > %s", filename, txtname); 76 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick identify gave an error\n", filename); exit(1); } 77 | FILE *f = fopen(txtname, "rt"); 78 | if (!f) { fprintf(stderr, "Error reading image '%s': could not read output of ImageMagick identify\n", filename); exit(1); } 79 | int w = 0, h = 0; 80 | if (fscanf(f, "%d %d", &w, &h) != 2) { fprintf(stderr, "Error reading image '%s': could not get size from ImageMagick identify\n", filename); exit(1); } 81 | fclose(f); 82 | printf("(w, h) = (%d, %d)\n", w, h); 83 | f = fopen(rawname, "rb"); 84 | BITMAP *ans = new BITMAP(w, h); 85 | unsigned char *p = (unsigned char *) ans->data; 86 | for (int i = 0; i < w*h*4; i++) { 87 | int ch = fgetc(f); 88 | if (ch == EOF) { fprintf(stderr, "Error reading image '%s': raw file is smaller than expected size %dx%dx%d\n", filename, w, h, 4); exit(1); } 89 | *p++ = ch; 90 | } 91 | fclose(f); 92 | return ans; 93 | } 94 | 95 | void save_bitmap(BITMAP *bmp, const char *filename) { 96 | // check_im(); 97 | char rawname[256]; 98 | strcpy(rawname, filename); 99 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error writing image '%s': no extension found\n", filename); exit(1); } 100 | sprintf(strstr(rawname, "."), ".raw"); 101 | char buf[256]; 102 | //printf("rawname = %s\n", rawname); 103 | FILE *f = fopen(rawname, "wb"); 104 | if (!f) { fprintf(stderr, "Error writing image '%s': could not open raw temporary file\n", filename); exit(1); } 105 | unsigned char *p = (unsigned char *) bmp->data; 106 | for (int i = 0; i < bmp->w*bmp->h*4; i++) { 107 | fputc(*p++, f); 108 | } 109 | fclose(f); 110 | sprintf(buf, "convert -size %dx%d -depth 8 rgba:%s %s", bmp->w, bmp->h, rawname, filename); 111 | //printf("system returned value = %d\n", system(buf)); 112 | if (system(buf) != 0) { fprintf(stderr, "Error writing image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 113 | } 114 | 115 | /* ------------------------------------------------------------------------- 116 | PatchMatch, using L2 distance between upright patches that translate only 117 | ------------------------------------------------------------------------- */ 118 | 119 | int patch_w = 7; 120 | int pm_iters = 6; 121 | int rs_max = INT_MAX; // random search 122 | 123 | #define XY_TO_INT(x, y) (((y)<<12)|(x)) 124 | #define INT_TO_X(v) ((v)&((1<<12)-1)) 125 | #define INT_TO_Y(v) ((v)>>12) 126 | 127 | bool isHole(BITMAP *mask, int x, int y) { 128 | int c = (*mask)[y][x]; 129 | int r = c&255; 130 | int g = (c>>8)&255; 131 | int b = (c>>16)&255; 132 | 133 | // hole means non-black pixels in mask 134 | if (r != 0 || g != 0 || b != 0) { return true; } 135 | return false; 136 | } 137 | 138 | /* check if a pixel x, y is in the bounding box or not */ 139 | bool inBox(int x, int y, int box_xmin, int box_xmax, int box_ymin, int box_ymax) { 140 | if (x >= box_xmin && x <= box_xmax+patch_w && y >= box_ymin && y <= box_ymax+patch_w) { 141 | return true; 142 | } 143 | return false; 144 | } 145 | 146 | /* Measure distance between 2 patches with upper left corners (ax, ay) and (bx, by), terminating early if we exceed a cutoff distance. 147 | You could implement your own descriptor here. */ 148 | int dist(BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, BITMAP *mask, int cutoff=INT_MAX) { 149 | int ans = 0; 150 | for (int dy = 0; dy < patch_w; dy++) { 151 | int *arow = &(*a)[ay+dy][ax]; 152 | int *brow = &(*b)[by+dy][bx]; 153 | for (int dx = 0; dx < patch_w; dx++) { 154 | int ac = arow[dx]; 155 | int bc = brow[dx]; 156 | int dr = (ac&255)-(bc&255); 157 | int dg = ((ac>>8)&255)-((bc>>8)&255); 158 | int db = (ac>>16)-(bc>>16); 159 | ans += dr*dr + dg*dg + db*db; 160 | } 161 | if (ans >= cutoff) { return cutoff; } 162 | } 163 | if (ans < 0) return INT_MAX; 164 | return ans; 165 | } 166 | 167 | void improve_guess(BITMAP *a, BITMAP *b, int ax, int ay, int &xbest, int &ybest, int &dbest, int bx, int by, BITMAP *mask, int type) { 168 | int d = dist(a, b, ax, ay, bx, by, mask, dbest); 169 | if ((d < dbest) && (ax != bx || ay != by) ) { 170 | #ifdef DEBUG 171 | if (type == 0) 172 | printf(" Prop x: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 173 | else if (type == 1) 174 | printf(" Prop y: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 175 | else 176 | printf(" Random: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 177 | #endif 178 | dbest = d; 179 | xbest = bx; 180 | ybest = by; 181 | } 182 | } 183 | 184 | /* Get the bounding box of hole */ 185 | void getBox(BITMAP *mask, int& xmin, int& xmax, int& ymin, int& ymax) { 186 | for (int h = 0; h < mask->h; h++) { 187 | for (int w = 0; w < mask->w; w++) { 188 | int c = (*mask)[h][w]; 189 | int r = c&255; 190 | int g = (c>>8)&255; 191 | int b = (c>>16)&255; 192 | // hole means non-black pixels in mask 193 | if (r != 0 || g != 0 || b != 0) { 194 | if (h < ymin) 195 | ymin = h; 196 | if (h > ymax) 197 | ymax = h; 198 | if (w < xmin) 199 | xmin = w; 200 | if (w > xmax) 201 | xmax = w; 202 | } 203 | } 204 | } 205 | xmin = xmin - patch_w + 1; 206 | ymin = ymin - patch_w + 1; 207 | xmin = (xmin < 0) ? 0 : xmin; 208 | ymin = (ymin < 0) ? 0 : ymin; 209 | 210 | xmax = (xmax > mask->w - patch_w + 1) ? mask->w - patch_w +1 : xmax; 211 | ymax = (ymax > mask->h - patch_w + 1) ? mask->h - patch_w +1 : ymax; 212 | 213 | printf("Hole's bounding box is x (%d, %d), y (%d, %d)\n", xmin, xmax, ymin, ymax); 214 | } 215 | 216 | BITMAP *norm_image(double *accum, int w, int h, BITMAP *ainit=NULL) { 217 | BITMAP *ans = new BITMAP(w, h); 218 | for (int y = 0; y < h; y++) { 219 | int *row = (*ans)[y]; 220 | int *arow = NULL; 221 | if (ainit) 222 | arow = (*ainit)[y]; 223 | double *prow = &accum[4*(y*w)]; 224 | for (int x = 0; x < w; x++) { 225 | double *p = &prow[4*x]; 226 | int c = p[3] ? p[3]: 1; 227 | int c2 = c>>1; /* Changed: round() instead of floor. */ 228 | if (ainit) 229 | row[x] = p[3] ? int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24) : arow[x]; 230 | else 231 | row[x] = int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24); 232 | } 233 | } 234 | return ans; 235 | } 236 | 237 | /* Match image a to image b, returning the nearest neighbor field mapping a => b coords, stored in an RGB 24-bit image as (by<<12)|bx. */ 238 | void patchmatch(BITMAP *a, BITMAP *mask, BITMAP *&ans, BITMAP *&ann, BITMAP *&annd) { 239 | /* Initialize with random nearest neighbor field (NNF). */ 240 | ann = new BITMAP(a->w, a->h); 241 | annd = new BITMAP(a->w, a->h); 242 | //int aew = a->w - patch_w+1, aeh = a->h - patch_w + 1; /* Effective width and height (possible upper left corners of patches). */ 243 | int mew = mask->w - patch_w+1, meh = mask->h - patch_w + 1; 244 | memset(ann->data, 0, sizeof(int)*a->w*a->h); 245 | memset(annd->data, 0, sizeof(int)*a->w*a->h); 246 | 247 | 248 | int box_xmin, box_xmax, box_ymin, box_ymax; 249 | box_xmin = box_ymin = INT_MAX; 250 | box_xmax = box_ymax = 0; 251 | 252 | getBox(mask, box_xmin, box_xmax, box_ymin, box_ymax); 253 | 254 | int bx, by; 255 | // Initialization 256 | for (int ay = box_ymin; ay < box_ymax; ay++) { 257 | for (int ax = box_xmin; ax < box_xmax; ax++) { 258 | bool valid = false; 259 | while (!valid) { 260 | bx = rand()%mew; 261 | by = rand()%meh; 262 | // should find patches outside bounding box 263 | if (inBox(bx, by, box_xmin, box_xmax, box_ymin, box_ymax)) { 264 | // or outside the hole 265 | //if (isHole(mask, bx, by) && isHole(mask, bx+patch_w, by+patch_w)) { 266 | valid = false; 267 | } else { 268 | valid = true; 269 | } 270 | } 271 | (*ann)[ay][ax] = XY_TO_INT(bx, by); 272 | (*annd)[ay][ax] = dist(a, a, ax, ay, bx, by, mask); 273 | } 274 | } 275 | 276 | 277 | 278 | save_bitmap(ann, "ann_before.jpg"); 279 | save_bitmap(annd, "annd_before.jpg"); 280 | save_bitmap(mask, "mask_before.jpg"); 281 | 282 | // in each iter we have two mask, the old one and updated new one 283 | int w = 1; 284 | for (int iter = 0; iter < pm_iters; iter++) { 285 | printf("iter = %d\n", iter); 286 | /* In each iteration, improve the NNF, by looping in scanline or reverse-scanline order. */ 287 | int ystart = box_ymin, yend = box_ymax, ychange = 1; 288 | int xstart = box_xmin, xend = box_xmax, xchange = 1; 289 | if (iter % 2 == 1) { 290 | xstart = box_xmax-1; xend = box_xmin-1; xchange = -1; 291 | ystart = box_ymax-1; yend = box_ymin-1; ychange = -1; 292 | } 293 | for (int ay = ystart; ay != yend; ay += ychange) { 294 | for (int ax = xstart; ax != xend; ax += xchange) { 295 | /* Current (best) guess. */ 296 | int v = (*ann)[ay][ax]; 297 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 298 | int dbest = (*annd)[ay][ax]; 299 | 300 | /* Propagation: Improve current guess by trying instead correspondences from left and above (below and right on odd iterations). */ 301 | if ((unsigned) (ax - xchange) < (unsigned) mew) { 302 | //if (inBox(ax - xchange, ay, box_xmin, box_xmax, box_ymin, box_ymax)) { 303 | int vp = (*ann)[ay][ax-xchange]; 304 | int xp = INT_TO_X(vp) + xchange, yp = INT_TO_Y(vp); 305 | if (((unsigned) xp < (unsigned) mew) && !inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 306 | //if (((unsigned) xp < (unsigned) mew)) { 307 | //printf("Propagation x\n"); 308 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 0); 309 | } 310 | } 311 | 312 | if ((unsigned) (ay - ychange) < (unsigned) meh) { 313 | //if (inBox(ax, ay - ychange, box_xmin, box_xmax, box_ymin, box_ymax)) { 314 | int vp = (*ann)[ay-ychange][ax]; 315 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp) + ychange; 316 | if (((unsigned) yp < (unsigned) meh) && !inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 317 | //if (((unsigned) yp < (unsigned) meh)) { 318 | //printf("Propagation y\n"); 319 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 1); 320 | } 321 | } 322 | 323 | /* Random search: Improve current guess by searching in boxes of exponentially decreasing size around the current best guess. */ 324 | int rs_start = rs_max; 325 | if (rs_start > MAX(a->w, a->h)) { rs_start = MAX(a->w, a->h); } 326 | for (int mag = rs_start; mag >= 1; mag /= 2) { 327 | /* Sampling window */ 328 | int xmin = MAX(xbest-mag, 0), xmax = MIN(xbest+mag+1, mew); 329 | int ymin = MAX(ybest-mag, 0), ymax = MIN(ybest+mag+1, meh); 330 | int xp = xmin+rand()%(xmax-xmin); 331 | int yp = ymin+rand()%(ymax-ymin); 332 | if (!inBox(xp, yp, box_xmin, box_xmax, box_ymin, box_ymax)) { 333 | //printf("Random\n"); 334 | improve_guess(a, a, ax, ay, xbest, ybest, dbest, xp, yp, mask, 2); 335 | } 336 | } 337 | 338 | (*ann)[ay][ax] = XY_TO_INT(xbest, ybest); 339 | (*annd)[ay][ax] = dbest; 340 | } 341 | } 342 | 343 | std::stringstream ss; 344 | ss << iter; 345 | 346 | std::string annd_file = "annd_iter_" + ss.str() + ".jpg"; 347 | const char* annd_ptr = annd_file.c_str(); 348 | save_bitmap(annd, annd_ptr); 349 | 350 | } 351 | 352 | // to store pixels in the new patch 353 | int sz = a->w*a->h; sz = sz << 2; // 4*w*h 354 | double* accum = new double[sz]; 355 | memset(accum, 0, sizeof(double)*sz ); 356 | 357 | // fill in missing pixels 358 | for (int ay = box_ymin; ay < box_ymax; ay++) { 359 | for (int ax = box_xmin; ax < box_xmax; ax++) { 360 | int vp = (*ann)[ay][ax]; 361 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp); 362 | for (int dy = 0; dy < patch_w; dy++) { 363 | int* arow = (*a)[yp+dy] + xp; 364 | double* prow = &accum[4*((ay+dy)*a->w + ax)]; 365 | for(int dx = 0; dx < patch_w; dx++) { 366 | if ((*annd)[yp+dy][xp+dx] == INT_MAX) { continue; } 367 | int c = arow[dx]; 368 | double* p = &prow[4*dx]; 369 | p[0] += (c&255)*w; 370 | p[1] += ((c>>8)&255)*w; 371 | p[2] += ((c>>16)&255)*w; 372 | p[3] += w; 373 | } 374 | } 375 | } 376 | } 377 | ans = norm_image(accum, a->w, a->h, NULL); 378 | delete[] accum; 379 | 380 | // join with original picture 381 | for (int h = 0; h < a->h; h++) { 382 | for (int w = 0; w < a->w; w++) { 383 | if (!isHole(mask, w, h)) { 384 | (*ans)[h][w] = 0 | (*a)[h][w]; 385 | } 386 | } 387 | } 388 | 389 | save_bitmap(ans, "final_picture.jpg"); 390 | 391 | save_bitmap(ann, "ann_final.jpg"); 392 | save_bitmap(annd, "annd_final.jpg"); 393 | 394 | 395 | } 396 | 397 | void tryIt(BITMAP* a, BITMAP *&ans, BITMAP *mask) { 398 | // fill in missing pixels 399 | //int ymin = 0, ymax = a->h - patch_w + 1; 400 | //int xmin = 0, xmax = a->w - patch_w + 1; 401 | int ymin = 200, ymax = 400; 402 | int xmin = 200, xmax = 400; 403 | // to store new pixels 404 | int sz = a->w*a->h; sz = sz << 2; // 4*w*h 405 | double* accum = new double[sz]; 406 | memset(accum, 0, sizeof(double)*sz ); 407 | 408 | int w = 1; 409 | for (int ay = ymin; ay < ymax; ay++) { 410 | for (int ax = xmin; ax < xmax; ax++) { 411 | int xp = ax - 200, yp = ay - 200; 412 | for (int dy = 0; dy < patch_w; dy++) { 413 | int* arow = (*a)[yp+dy] + xp; 414 | double* prow = &accum[4*((ay+dy)*a->w + ax)]; 415 | for(int dx = 0; dx < patch_w; dx++) { 416 | // if (!isHole(mask, ax+dx, ay+dy)) { continue; } 417 | int c = arow[dx]; 418 | double* p = &prow[4*dx]; 419 | p[0] += (c&255)*w; 420 | p[1] += ((c>>8)&255)*w; 421 | p[2] += ((c>>16)&255)*w; 422 | p[3] += w; 423 | // change mask 424 | // (*mask)[ay+dy][ax+dx] = 0; 425 | } 426 | } 427 | } 428 | } 429 | ans = norm_image(accum, a->w, a->h, a); 430 | save_bitmap(ans, "try_ans.jpg"); 431 | 432 | // join with original picture 433 | for (int h = 0; h < a->h; h++) { 434 | for (int w = 0; w < a->w; w++) { 435 | if (!isHole(mask, w, h)) { 436 | //if (!inBox(w, h, box_xmin, box_xmax, box_ymin, box_ymax)) { 437 | (*ans)[h][w] = 0 | (*a)[h][w]; 438 | } 439 | } 440 | } 441 | save_bitmap(ans, "try_ans_join.jpg"); 442 | } 443 | 444 | void reconstruct(BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *&r) { 445 | r = new BITMAP(a->w, a->h); 446 | memset(r->data, 0, sizeof(int)*a->w*a->h); 447 | 448 | for (int h = 0; h < a->h; h++) 449 | { 450 | for (int w = 0; w < a->w; w++) 451 | { 452 | int v = (*ann)[h][w]; 453 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 454 | (*r)[h][w] = (*b)[ybest][xbest]; 455 | } 456 | } 457 | } 458 | 459 | 460 | int main(int argc, char *argv[]) { 461 | argc--; 462 | argv++; 463 | if (argc != 3) { fprintf(stderr, "im_complete a mask result\n" 464 | "Given input image a and mask outputs result\n" 465 | "These are stored as RGB 24-bit images, with a 24-bit int at every pixel. For the NNF we store (by<<12)|bx."); exit(1); } 466 | printf("(1) Loading input images\n"); 467 | BITMAP *a = load_bitmap(argv[0]); 468 | BITMAP *mask = load_bitmap(argv[1]); 469 | BITMAP *ans = NULL, *ann = NULL, *annd = NULL; 470 | 471 | //BITMAP *ans2 = NULL; 472 | //tryIt(a, ans2, mask); 473 | 474 | printf("\n(2) Running PatchMatch\n"); 475 | patchmatch(a, mask, ans, ann, annd); 476 | printf("\n(3) Saving output images: ans\n"); 477 | save_bitmap(ans, argv[2]); 478 | 479 | return 0; 480 | } 481 | -------------------------------------------------------------------------------- /code/im_complete_opencv.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* ------------------------------------------------------------------------- 3 | Minimal (unoptimized) example of PatchMatch. Requires that ImageMagick be installed. 4 | 5 | To improve generality you can: 6 | - Use whichever distance function you want in dist(), e.g. compare SIFT descriptors computed densely. 7 | - Search over a larger search space, such as rotating+scaling patches (see MATLAB mex for examples of both) 8 | 9 | To improve speed you can: 10 | - Turn on optimizations (/Ox /Oi /Oy /fp:fast or -O6 -s -ffast-math -fomit-frame-pointer -fstrength-reduce -msse2 -funroll-loops) 11 | - Use the MATLAB mex which is already tuned for speed 12 | - Use multiple cores, tiling the input. See our publication "The Generalized PatchMatch Correspondence Algorithm" 13 | - Tune the distance computation: manually unroll loops for each patch size, use SSE instructions (see readme) 14 | - Precompute random search samples (to avoid using rand, and mod) 15 | - Move to the GPU 16 | -------------------------------------------------------------------------- */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #ifndef MAX 30 | #define MAX(a, b) ((a)>(b)?(a):(b)) 31 | #define MIN(a, b) ((a)<(b)?(a):(b)) 32 | #endif 33 | 34 | #define _DEBUG 35 | 36 | using namespace cv; 37 | using namespace std; 38 | 39 | /* ------------------------------------------------------------------------- 40 | BITMAP: Minimal image class 41 | ------------------------------------------------------------------------- */ 42 | 43 | class BITMAP { public: 44 | int w, h; 45 | int *data; 46 | BITMAP(int w_, int h_) :w(w_), h(h_) { data = new int[w*h]; } 47 | BITMAP(BITMAP* bm) { 48 | w = bm->w; 49 | h = bm->h; 50 | data = new int[w*h]; 51 | for (int i = 0; i < w*h; ++i) { 52 | data[i] = bm->data[i]; 53 | } 54 | } 55 | ~BITMAP() { delete[] data; } 56 | int *operator[](int y) { return &data[y*w]; } 57 | }; 58 | 59 | 60 | BITMAP *load_bitmap(const char *filename) { 61 | char rawname[256], txtname[256]; 62 | strcpy(rawname, filename); 63 | strcpy(txtname, filename); 64 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error reading image '%s': no extension found\n", filename); exit(1); } 65 | sprintf(strstr(rawname, "."), ".raw"); 66 | sprintf(strstr(txtname, "."), ".txt"); 67 | char buf[256]; 68 | sprintf(buf, "convert %s rgba:%s", filename, rawname); 69 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 70 | sprintf(buf, "identify -format \"%%w %%h\" %s > %s", filename, txtname); 71 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick identify gave an error\n", filename); exit(1); } 72 | FILE *f = fopen(txtname, "rt"); 73 | if (!f) { fprintf(stderr, "Error reading image '%s': could not read output of ImageMagick identify\n", filename); exit(1); } 74 | int w = 0, h = 0; 75 | if (fscanf(f, "%d %d", &w, &h) != 2) { fprintf(stderr, "Error reading image '%s': could not get size from ImageMagick identify\n", filename); exit(1); } 76 | fclose(f); 77 | printf("(w, h) = (%d, %d)\n", w, h); 78 | f = fopen(rawname, "rb"); 79 | BITMAP *ans = new BITMAP(w, h); 80 | unsigned char *p = (unsigned char *) ans->data; 81 | for (int i = 0; i < w*h*4; i++) { 82 | int ch = fgetc(f); 83 | if (ch == EOF) { fprintf(stderr, "Error reading image '%s': raw file is smaller than expected size %dx%dx%d\n", filename, w, h, 4); exit(1); } 84 | *p++ = ch; 85 | } 86 | fclose(f); 87 | return ans; 88 | } 89 | 90 | void save_bitmap(BITMAP *bmp, const char *filename) { 91 | char rawname[256]; 92 | strcpy(rawname, filename); 93 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error writing image '%s': no extension found\n", filename); exit(1); } 94 | sprintf(strstr(rawname, "."), ".raw"); 95 | char buf[256]; 96 | //printf("rawname = %s\n", rawname); 97 | FILE *f = fopen(rawname, "wb"); 98 | if (!f) { fprintf(stderr, "Error writing image '%s': could not open raw temporary file\n", filename); exit(1); } 99 | unsigned char *p = (unsigned char *) bmp->data; 100 | for (int i = 0; i < bmp->w*bmp->h*4; i++) { 101 | fputc(*p++, f); 102 | } 103 | fclose(f); 104 | sprintf(buf, "convert -size %dx%d -depth 8 rgba:%s %s", bmp->w, bmp->h, rawname, filename); 105 | //printf("system returned value = %d\n", system(buf)); 106 | if (system(buf) != 0) { fprintf(stderr, "Error writing image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 107 | } 108 | 109 | // Just a simple struct for Box 110 | struct Box { 111 | int xmin, xmax, ymin, ymax; 112 | }; 113 | 114 | /* ------------------------------------------------------------------------- 115 | PatchMatch, using L2 distance between upright patches that translate only 116 | ------------------------------------------------------------------------- */ 117 | 118 | int patch_w = 8; 119 | int pm_iters = 5; 120 | int rs_max = INT_MAX; // random search 121 | int sigma = 1 * patch_w * patch_w; 122 | 123 | #define XY_TO_INT(x, y) (((y)<<12)|(x)) 124 | #define INT_TO_X(v) ((v)&((1<<12)-1)) 125 | #define INT_TO_Y(v) ((v)>>12) 126 | 127 | /* Get the bounding box of hole */ 128 | Box getBox(Mat mask) { 129 | int xmin = INT_MAX, ymin = INT_MAX; 130 | int xmax = 0, ymax = 0; 131 | for (int h = 0; h < mask.rows; h++) { 132 | for (int w = 0; w < mask.cols; w++) { 133 | //Vec3b mask_pixel = mask.at(h, w); 134 | int mask_pixel = (int) mask.at(h, w); 135 | // hole means non-black pixels in mask 136 | // if (!(mask_pixel[0] == 0 && mask_pixel[1] == 0 && mask_pixel[2] == 0)) { 137 | if (mask_pixel == 255) { 138 | if (h < ymin) 139 | ymin = h; 140 | if (h > ymax) 141 | ymax = h; 142 | if (w < xmin) 143 | xmin = w; 144 | if (w > xmax) 145 | xmax = w; 146 | } else if (mask_pixel != 0) { 147 | cout << "SHIT happens, value " << mask_pixel << " in pos x " << w << " , y" << h << endl; 148 | } 149 | } 150 | } 151 | xmin = xmin - patch_w + 1; 152 | ymin = ymin - patch_w + 1; 153 | xmin = (xmin < 0) ? 0 : xmin; 154 | ymin = (ymin < 0) ? 0 : ymin; 155 | 156 | xmax = (xmax > mask.cols - patch_w + 1) ? mask.cols - patch_w +1 : xmax; 157 | ymax = (ymax > mask.rows - patch_w + 1) ? mask.rows - patch_w +1 : ymax; 158 | 159 | printf("Hole's bounding box is x (%d, %d), y (%d, %d)\n", xmin, xmax, ymin, ymax); 160 | Box box = {.xmin = xmin, .xmax = xmax, .ymin = ymin, .ymax = ymax}; 161 | return box; 162 | } 163 | 164 | /* check if a pixel x, y is in the bounding box or not */ 165 | bool inBox(int x, int y, Box box) { 166 | if (x >= box.xmin && x <= box.xmax && y >= box.ymin && y <= box.ymax) { 167 | return true; 168 | } 169 | return false; 170 | } 171 | 172 | /* Measure distance between 2 patches with upper left corners (ax, ay) and (bx, by), terminating early if we exceed a cutoff distance. 173 | You could implement your own descriptor here. */ 174 | int dist(Mat a, Mat b, int ax, int ay, int bx, int by, int cutoff=INT_MAX) { 175 | int ans = 0; 176 | if (a.type() != CV_8UC3) { 177 | cout << "Bad things happened in dist " <(ay + dy, ax + dx); 183 | Vec3b bc = b.at(by + dy, bx + dx); 184 | 185 | int db = ac[0] - bc[0]; 186 | int dg = ac[1] - bc[1]; 187 | int dr = ac[2] - bc[2]; 188 | ans += dr*dr + dg*dg + db*db; 189 | } 190 | if (ans >= cutoff) { return cutoff; } 191 | } 192 | if (ans < 0) return INT_MAX; 193 | return ans; 194 | } 195 | 196 | void improve_guess(Mat a, Mat b, int ax, int ay, int &xbest, int &ybest, int &dbest, int bx, int by, int type) { 197 | int d = dist(a, b, ax, ay, bx, by, dbest); 198 | if ((d < dbest) && (ax != bx || ay != by) ) { 199 | #ifdef DEBUG 200 | if (type == 0) 201 | printf(" Prop x: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 202 | else if (type == 1) 203 | printf(" Prop y: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 204 | else 205 | printf(" Random: improve (%d, %d) old nn (%d, %d) new nn (%d, %d) old dist %d, new dist %d\n", ax, ay, xbest, ybest, bx, by, dbest, d); 206 | #endif 207 | dbest = d; 208 | xbest = bx; 209 | ybest = by; 210 | } 211 | } 212 | 213 | /* Match image a to image b, returning the nearest neighbor field mapping a => b coords, stored in an RGB 24-bit image as (by<<12)|bx. */ 214 | void patchmatch(Mat a, Mat b, BITMAP *&ann, BITMAP *&annd, Mat dilated_mask) { 215 | /* Initialize with random nearest neighbor field (NNF). */ 216 | ann = new BITMAP(a.cols, a.rows); 217 | annd = new BITMAP(a.cols, a.rows); 218 | /* Effective width and height (possible upper left corners of patches). */ 219 | int aew = a.cols - patch_w + 1, aeh = a.rows - patch_w + 1; 220 | int bew = b.cols - patch_w + 1, beh = b.rows - patch_w + 1; 221 | memset(ann->data, 0, sizeof(int) * a.cols * a.rows); 222 | memset(annd->data, 0, sizeof(int) * a.cols * a.rows); 223 | 224 | 225 | // Initialization 226 | int bx, by; 227 | for (int ay = 0; ay < aeh; ay++) { 228 | for (int ax = 0; ax < aew; ax++) { 229 | bool valid = false; 230 | while (!valid) { 231 | bx = rand() % bew; 232 | by = rand() % beh; 233 | int mask_pixel = (int) dilated_mask.at(by, bx); 234 | // should find patches outside the hole 235 | if (mask_pixel == 255) { 236 | valid = false; 237 | } else { 238 | valid = true; 239 | } 240 | } 241 | (*ann)[ay][ax] = XY_TO_INT(bx, by); 242 | (*annd)[ay][ax] = dist(a, b, ax, ay, bx, by); 243 | } 244 | } 245 | 246 | #ifdef DEBUG 247 | for (int ay = 0; ay < aeh; ay++ ) { 248 | for (int ax = 0; ax < aew; ax++) { 249 | int vp = (*ann)[ay][ax]; 250 | int xp = INT_TO_X(vp); 251 | int yp = INT_TO_Y(vp); 252 | int mask_pixel = (int) dilated_mask.at(yp, xp); 253 | if (mask_pixel == 255) { 254 | cout << "Something wrong after init " << xp << " , " << yp << " pixel " << mask_pixel << endl; 255 | } 256 | } 257 | } 258 | #endif 259 | 260 | for (int iter = 0; iter < pm_iters; iter++) { 261 | // printf(" pm_iter = %d\n", iter); 262 | /* In each iteration, improve the NNF, by looping in scanline or reverse-scanline order. */ 263 | int ystart = 0, yend = aeh, ychange = 1; 264 | int xstart = 0, xend = aew, xchange = 1; 265 | if (iter % 2 == 1) { 266 | xstart = xend-1; xend = -1; xchange = -1; 267 | ystart = yend-1; yend = -1; ychange = -1; 268 | } 269 | for (int ay = ystart; ay != yend; ay += ychange) { 270 | for (int ax = xstart; ax != xend; ax += xchange) { 271 | /* Current (best) guess. */ 272 | int v = (*ann)[ay][ax]; 273 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 274 | int dbest = (*annd)[ay][ax]; 275 | 276 | /* Propagation: Improve current guess by trying instead correspondences from left and above (below and right on odd iterations). */ 277 | if ((unsigned) (ax - xchange) < (unsigned) aew) { 278 | int vp = (*ann)[ay][ax-xchange]; 279 | int xp = INT_TO_X(vp) + xchange, yp = INT_TO_Y(vp); 280 | 281 | if (((unsigned) xp < (unsigned) aew)) { 282 | int mask_pixel = (int) dilated_mask.at(yp, xp); 283 | if (mask_pixel != 255) { 284 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp, 0); 285 | } 286 | } 287 | } 288 | 289 | if ((unsigned) (ay - ychange) < (unsigned) aeh) { 290 | int vp = (*ann)[ay-ychange][ax]; 291 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp) + ychange; 292 | 293 | if (((unsigned) yp < (unsigned) aeh)) { 294 | int mask_pixel = (int) dilated_mask.at(yp, xp); 295 | if (mask_pixel != 255) { 296 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp, 1); 297 | } 298 | } 299 | } 300 | 301 | /* Random search: Improve current guess by searching in boxes of exponentially decreasing size around the current best guess. */ 302 | int rs_start = rs_max; 303 | if (rs_start > MAX(b.cols, b.rows)) { rs_start = MAX(b.cols, b.rows); } 304 | for (int mag = rs_start; mag >= 1; mag /= 2) { 305 | /* Sampling window */ 306 | int xmin = MAX(xbest-mag, 0), xmax = MIN(xbest+mag+1, bew); 307 | int ymin = MAX(ybest-mag, 0), ymax = MIN(ybest+mag+1, beh); 308 | bool do_improve = false; 309 | do { 310 | int xp = xmin + rand() % (xmax-xmin); 311 | int yp = ymin + rand() % (ymax-ymin); 312 | int mask_pixel = (int) dilated_mask.at(yp, xp); 313 | if (mask_pixel != 255) { 314 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp, 2); 315 | do_improve = true; 316 | } 317 | } while (!do_improve); 318 | } 319 | 320 | (*ann)[ay][ax] = XY_TO_INT(xbest, ybest); 321 | (*annd)[ay][ax] = dbest; 322 | } 323 | } 324 | } 325 | } 326 | 327 | /** 328 | * Image inpainting algorithm 329 | * Basic idea based on Wexler et. al 2017 Space-Time Image Completion 330 | * 331 | * @param im_orig: original image (with pixels in hole presented or not) 332 | * @param mask: mask specify missing region 333 | * 334 | * @return the completed/inpainting image 335 | */ 336 | void image_complete(Mat im_orig, Mat mask) { 337 | 338 | // some parameters for scaling 339 | int rows = im_orig.rows; 340 | int cols = im_orig.cols; 341 | int startscale = (int) -1*ceil(log2(MIN(rows, cols))) + 5; 342 | //int startscale = -3; 343 | double scale = pow(2, startscale); 344 | 345 | cout << "Scaling image by " << scale << endl; 346 | 347 | double t1 = (double)getTickCount(); 348 | 349 | // Resize image to starting scale 350 | Mat resize_img, resize_mask; 351 | resize(im_orig, resize_img, Size(), scale, scale, INTER_AREA); 352 | resize(mask, resize_mask, Size(), scale, scale, INTER_AREA); 353 | threshold(resize_mask, resize_mask, 127, 255, 0); 354 | 355 | // Random starting guess for inpainted image 356 | rows = resize_img.rows; 357 | cols = resize_img.cols; 358 | for (int y = 0; y < rows; ++y) { 359 | for (int x = 0; x < cols; ++x) { 360 | int mask_pixel = (int) resize_mask.at(y, x); 361 | if (mask_pixel != 0 && mask_pixel != 255) { 362 | cout << "GGGGGGGGGGGGGGG" << endl; 363 | exit(1); 364 | } 365 | // if not black pixel, then means white (1) pixel in mask 366 | // means hole, thus random init colors in hole 367 | if (mask_pixel != 0) { 368 | resize_img.at(y, x)[0] = rand() % 256; 369 | resize_img.at(y, x)[1] = rand() % 256; 370 | resize_img.at(y, x)[2] = rand() % 256; 371 | } 372 | } 373 | } 374 | 375 | 376 | double p1 = ((double)getTickCount() - t1) / getTickFrequency(); 377 | cout << "time for init = " << p1 << endl; 378 | 379 | // just for DEBUG 380 | int index = 0; 381 | 382 | // go through all scale 383 | for (int logscale = startscale; logscale <= 0; logscale++) { 384 | index++; 385 | 386 | scale = pow(2, logscale); 387 | 388 | cout << "Scaling is " << scale << endl; 389 | 390 | Box mask_box = getBox(resize_mask); 391 | // dilate the mask 392 | // 393 | // if patch_w = 3 394 | // kernel width = 5 , 0 1 2 is 1 395 | // pixel is result should be 396 | // 0 0 0 0 1 1 1 0 397 | // 0 0 0 0 1 1 1 0 398 | // 0 0 1 0 1 1 1 0 399 | // 0 0 0 0 0 0 0 0 400 | Mat element = Mat::zeros(2*patch_w - 1, 2*patch_w - 1, CV_8UC1); 401 | element(Rect(patch_w - 1, patch_w - 1, patch_w, patch_w)) = 255; 402 | Mat dilated_mask; 403 | dilate(resize_mask, dilated_mask, element); 404 | 405 | /* 406 | imwrite("dilated_mask.png", dilated_mask); 407 | imwrite("mask.png", mask); 408 | Mat inverted_mask; 409 | bitwise_not(mask, inverted_mask); 410 | Mat mask_diff; 411 | bitwise_and(dilated_mask, inverted_mask, mask_diff); 412 | imwrite("mask_diff.png", mask_diff); 413 | */ 414 | 415 | // iterations of image completion 416 | int im_iterations = 60; 417 | for (int im_iter = 0; im_iter < im_iterations; ++im_iter) { 418 | printf("im_iter = %d\n", im_iter); 419 | 420 | BITMAP *ann = NULL, *annd = NULL; 421 | 422 | double t2 = (double)getTickCount(); 423 | 424 | Mat B = resize_img.clone(); 425 | bitwise_and(resize_img, 0, B, resize_mask); 426 | 427 | // use patchmatch to find NN 428 | patchmatch(resize_img, B, ann, annd, dilated_mask); 429 | 430 | //stringstream ss; 431 | //ss << im_iter; 432 | //string annd_file = "annd_iter_" + ss.str() + ".jpg"; 433 | //const char* annd_ptr = annd_file.c_str(); 434 | //save_bitmap(ann, annd_ptr); 435 | 436 | double p2 = ((double)getTickCount() - t2) / getTickFrequency(); 437 | cout << "time for PM = " << p2 << endl; 438 | 439 | double t3 = (double)getTickCount(); 440 | // create new image by letting each patch vote 441 | Mat R = Mat::zeros(resize_img.rows, resize_img.cols, CV_32FC3); 442 | Mat Rcount = Mat::zeros(resize_img.rows, resize_img.cols, CV_32FC3); 443 | for (int y = mask_box.ymin; y < mask_box.ymax; ++y) { 444 | for (int x = mask_box.xmin; x < mask_box.xmax; ++x) { 445 | int v = (*ann)[y][x]; 446 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 447 | Rect srcRect(Point(x, y), Size(patch_w, patch_w)); 448 | Rect dstRect(Point(xbest, ybest), Size(patch_w, patch_w)); 449 | float d = (float) (*annd)[y][x]; 450 | float sim = exp(-d / (2*pow(sigma, 2) )); 451 | Mat toAssign; 452 | addWeighted(R(srcRect), 1.0, resize_img(dstRect), sim, 0, toAssign, CV_32FC3); 453 | toAssign.copyTo(R(srcRect)); 454 | add(Rcount(srcRect), sim, toAssign, noArray(), CV_32FC3); 455 | toAssign.copyTo(Rcount(srcRect)); 456 | /* 457 | Mat debugR = Rcount.clone(); 458 | cout << "Hole (" << x << ", " << y << ") has sim2 " << exp(-d / (2*pow(sigma, 2))) <(y, x); 570 | if (mask_pixel != 0) { 571 | a_matrix.at(y, x) = Vec3b(0, 0, 0); 572 | } 573 | } 574 | } 575 | 576 | image_complete(image, mask_cv); 577 | 578 | return 0; 579 | } 580 | -------------------------------------------------------------------------------- /code/man_const.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/code/man_const.png -------------------------------------------------------------------------------- /code/pm_minimal.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* ------------------------------------------------------------------------- 3 | Minimal (unoptimized) example of PatchMatch. Requires that ImageMagick be installed. 4 | 5 | To improve generality you can: 6 | - Use whichever distance function you want in dist(), e.g. compare SIFT descriptors computed densely. 7 | - Search over a larger search space, such as rotating+scaling patches (see MATLAB mex for examples of both) 8 | 9 | To improve speed you can: 10 | - Turn on optimizations (/Ox /Oi /Oy /fp:fast or -O6 -s -ffast-math -fomit-frame-pointer -fstrength-reduce -msse2 -funroll-loops) 11 | - Use the MATLAB mex which is already tuned for speed 12 | - Use multiple cores, tiling the input. See our publication "The Generalized PatchMatch Correspondence Algorithm" 13 | - Tune the distance computation: manually unroll loops for each patch size, use SSE instructions (see readme) 14 | - Precompute random search samples (to avoid using rand, and mod) 15 | - Move to the GPU 16 | -------------------------------------------------------------------------- */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #ifndef MAX 26 | #define MAX(a, b) ((a)>(b)?(a):(b)) 27 | #define MIN(a, b) ((a)<(b)?(a):(b)) 28 | #endif 29 | 30 | /* ------------------------------------------------------------------------- 31 | BITMAP: Minimal image class 32 | ------------------------------------------------------------------------- */ 33 | 34 | class BITMAP { public: 35 | int w, h; 36 | int *data; 37 | BITMAP(int w_, int h_) :w(w_), h(h_) { data = new int[w*h]; } 38 | ~BITMAP() { delete[] data; } 39 | int *operator[](int y) { return &data[y*w]; } 40 | }; 41 | 42 | void check_im() { 43 | int i; 44 | i = system("identify ../test-images/test1.jpg"); 45 | printf ("The value returned was: %d.\n",i); 46 | if (i != 0) { 47 | fprintf(stderr, "ImageMagick must be installed, and 'convert' and 'identify' must be in the path\n"); exit(1); 48 | } 49 | } 50 | 51 | BITMAP *load_bitmap(const char *filename) { 52 | check_im(); 53 | char rawname[256], txtname[256]; 54 | strcpy(rawname, filename); 55 | strcpy(txtname, filename); 56 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error reading image '%s': no extension found\n", filename); exit(1); } 57 | sprintf(strstr(rawname, "."), ".raw"); 58 | sprintf(strstr(txtname, "."), ".txt"); 59 | char buf[256]; 60 | sprintf(buf, "convert %s rgba:%s", filename, rawname); 61 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 62 | sprintf(buf, "identify -format \"%%w %%h\" %s > %s", filename, txtname); 63 | if (system(buf) != 0) { fprintf(stderr, "Error reading image '%s': ImageMagick identify gave an error\n", filename); exit(1); } 64 | FILE *f = fopen(txtname, "rt"); 65 | if (!f) { fprintf(stderr, "Error reading image '%s': could not read output of ImageMagick identify\n", filename); exit(1); } 66 | int w = 0, h = 0; 67 | if (fscanf(f, "%d %d", &w, &h) != 2) { fprintf(stderr, "Error reading image '%s': could not get size from ImageMagick identify\n", filename); exit(1); } 68 | fclose(f); 69 | printf("(w, h) = (%d, %d)\n", w, h); 70 | f = fopen(rawname, "rb"); 71 | BITMAP *ans = new BITMAP(w, h); 72 | unsigned char *p = (unsigned char *) ans->data; 73 | for (int i = 0; i < w*h*4; i++) { 74 | int ch = fgetc(f); 75 | if (ch == EOF) { fprintf(stderr, "Error reading image '%s': raw file is smaller than expected size %dx%dx%d\n", filename, w, h, 4); exit(1); } 76 | *p++ = ch; 77 | } 78 | fclose(f); 79 | return ans; 80 | } 81 | 82 | void save_bitmap(BITMAP *bmp, const char *filename) { 83 | check_im(); 84 | char rawname[256]; 85 | strcpy(rawname, filename); 86 | if (!strstr(rawname, ".")) { fprintf(stderr, "Error writing image '%s': no extension found\n", filename); exit(1); } 87 | sprintf(strstr(rawname, "."), ".raw"); 88 | char buf[256]; 89 | //printf("rawname = %s\n", rawname); 90 | FILE *f = fopen(rawname, "wb"); 91 | if (!f) { fprintf(stderr, "Error writing image '%s': could not open raw temporary file\n", filename); exit(1); } 92 | unsigned char *p = (unsigned char *) bmp->data; 93 | for (int i = 0; i < bmp->w*bmp->h*4; i++) { 94 | fputc(*p++, f); 95 | } 96 | fclose(f); 97 | sprintf(buf, "convert -size %dx%d -depth 8 rgba:%s %s", bmp->w, bmp->h, rawname, filename); 98 | //printf("system returned value = %d\n", system(buf)); 99 | if (system(buf) != 0) { fprintf(stderr, "Error writing image '%s': ImageMagick convert gave an error\n", filename); exit(1); } 100 | } 101 | 102 | /* ------------------------------------------------------------------------- 103 | PatchMatch, using L2 distance between upright patches that translate only 104 | ------------------------------------------------------------------------- */ 105 | 106 | int patch_w = 7; 107 | int pm_iters = 1; 108 | int rs_max = INT_MAX; // random search 109 | 110 | #define XY_TO_INT(x, y) (((y)<<12)|(x)) 111 | #define INT_TO_X(v) ((v)&((1<<12)-1)) 112 | #define INT_TO_Y(v) ((v)>>12) 113 | 114 | 115 | void reconstruct(BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *&ans); 116 | 117 | /* Measure distance between 2 patches with upper left corners (ax, ay) and (bx, by), terminating early if we exceed a cutoff distance. 118 | You could implement your own descriptor here. */ 119 | int dist(BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, int cutoff=INT_MAX) { 120 | int ans = 0; 121 | for (int dy = 0; dy < patch_w; dy++) { 122 | int *arow = &(*a)[ay+dy][ax]; 123 | int *brow = &(*b)[by+dy][bx]; 124 | for (int dx = 0; dx < patch_w; dx++) { 125 | int ac = arow[dx]; 126 | int bc = brow[dx]; 127 | int dr = (ac&255)-(bc&255); 128 | int dg = ((ac>>8)&255)-((bc>>8)&255); 129 | int db = (ac>>16)-(bc>>16); 130 | ans += dr*dr + dg*dg + db*db; 131 | } 132 | if (ans >= cutoff) { return cutoff; } 133 | } 134 | return ans; 135 | } 136 | 137 | void improve_guess(BITMAP *a, BITMAP *b, int ax, int ay, int &xbest, int &ybest, int &dbest, int bx, int by) { 138 | int d = dist(a, b, ax, ay, bx, by, dbest); 139 | if (d < dbest) { 140 | dbest = d; 141 | xbest = bx; 142 | ybest = by; 143 | } 144 | } 145 | 146 | /* Match image a to image b, returning the nearest neighbor field mapping a => b coords, stored in an RGB 24-bit image as (by<<12)|bx. */ 147 | void patchmatch(BITMAP *a, BITMAP *b, BITMAP *&ann, BITMAP *&annd) { 148 | /* Initialize with random nearest neighbor field (NNF). */ 149 | ann = new BITMAP(a->w, a->h); 150 | annd = new BITMAP(a->w, a->h); 151 | int aew = a->w - patch_w+1, aeh = a->h - patch_w + 1; /* Effective width and height (possible upper left corners of patches). */ 152 | int bew = b->w - patch_w+1, beh = b->h - patch_w + 1; 153 | memset(ann->data, 0, sizeof(int)*a->w*a->h); 154 | memset(annd->data, 0, sizeof(int)*a->w*a->h); 155 | 156 | // Initialization 157 | for (int ay = 0; ay < aeh; ay++) { 158 | for (int ax = 0; ax < aew; ax++) { 159 | int bx = rand()%bew; 160 | int by = rand()%beh; 161 | (*ann)[ay][ax] = XY_TO_INT(bx, by); 162 | (*annd)[ay][ax] = dist(a, b, ax, ay, bx, by); 163 | } 164 | } 165 | 166 | for (int iter = 0; iter < pm_iters; iter++) { 167 | printf("iter = %d\n", iter); 168 | /* In each iteration, improve the NNF, by looping in scanline or reverse-scanline order. */ 169 | int ystart = 0, yend = aeh, ychange = 1; 170 | int xstart = 0, xend = aew, xchange = 1; 171 | if (iter % 2 == 1) { 172 | xstart = xend-1; xend = -1; xchange = -1; 173 | ystart = yend-1; yend = -1; ychange = -1; 174 | } 175 | for (int ay = ystart; ay != yend; ay += ychange) { 176 | for (int ax = xstart; ax != xend; ax += xchange) { 177 | /* Current (best) guess. */ 178 | int v = (*ann)[ay][ax]; 179 | int xbest = INT_TO_X(v), ybest = INT_TO_Y(v); 180 | int dbest = (*annd)[ay][ax]; 181 | 182 | /* Propagation: Improve current guess by trying instead correspondences from left and above (below and right on odd iterations). */ 183 | if ((unsigned) (ax - xchange) < (unsigned) aew) { 184 | int vp = (*ann)[ay][ax-xchange]; 185 | int xp = INT_TO_X(vp) + xchange, yp = INT_TO_Y(vp); 186 | if ((unsigned) xp < (unsigned) bew) { 187 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp); 188 | } 189 | } 190 | 191 | if ((unsigned) (ay - ychange) < (unsigned) aeh) { 192 | int vp = (*ann)[ay-ychange][ax]; 193 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp) + ychange; 194 | if ((unsigned) yp < (unsigned) beh) { 195 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp); 196 | } 197 | } 198 | 199 | /* Random search: Improve current guess by searching in boxes of exponentially decreasing size around the current best guess. */ 200 | int rs_start = rs_max; 201 | if (rs_start > MAX(b->w, b->h)) { rs_start = MAX(b->w, b->h); } 202 | for (int mag = rs_start; mag >= 1; mag /= 2) { 203 | /* Sampling window */ 204 | int xmin = MAX(xbest-mag, 0), xmax = MIN(xbest+mag+1,bew); 205 | int ymin = MAX(ybest-mag, 0), ymax = MIN(ybest+mag+1,beh); 206 | int xp = xmin+rand()%(xmax-xmin); 207 | int yp = ymin+rand()%(ymax-ymin); 208 | improve_guess(a, b, ax, ay, xbest, ybest, dbest, xp, yp); 209 | } 210 | 211 | (*ann)[ay][ax] = XY_TO_INT(xbest, ybest); 212 | (*annd)[ay][ax] = dbest; 213 | } 214 | } 215 | 216 | // try to reconstruct at every iter 217 | /* 218 | BITMAP *r = NULL; 219 | reconstruct(a, b, ann, r); 220 | std::stringstream ss; 221 | ss << iter; 222 | std::string r_file = "a_recons_iter_" + ss.str() + ".jpg"; 223 | const char* r_ptr = r_file.c_str(); 224 | save_bitmap(r, r_ptr); 225 | */ 226 | } 227 | } 228 | 229 | BITMAP *norm_image(double *accum, int w, int h, BITMAP *ainit=NULL) { 230 | BITMAP *ans = new BITMAP(w, h); 231 | for (int y = 0; y < h; y++) { 232 | int *row = (*ans)[y]; 233 | int *arow = NULL; 234 | if (ainit) 235 | arow = (*ainit)[y]; 236 | double *prow = &accum[4*(y*w)]; 237 | for (int x = 0; x < w; x++) { 238 | double *p = &prow[4*x]; 239 | int c = p[3] ? p[3]: 1; 240 | int c2 = c>>1; /* Changed: round() instead of floor. */ 241 | if (ainit) 242 | row[x] = p[3] ? int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24) : arow[x]; 243 | else 244 | row[x] = int((p[0]+c2)/c)|(int((p[1]+c2)/c)<<8)|(int((p[2]+c2)/c)<<16)|(255<<24); 245 | } 246 | } 247 | return ans; 248 | } 249 | 250 | void reconstruct(BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *&ans) { 251 | 252 | int sz = a->w*a->h; sz = sz << 2; // 4*w*h 253 | double* accum = new double[sz]; 254 | memset(accum, 0, sizeof(double)*sz ); 255 | 256 | for (int ay = 0; ay < a->h - patch_w + 1; ay++) { 257 | for (int ax = 0; ax < a->w - patch_w + 1; ax++) { 258 | int vp = (*ann)[ay][ax]; 259 | int xp = INT_TO_X(vp), yp = INT_TO_Y(vp); 260 | for (int dy = 0; dy < patch_w; dy++) { 261 | int* brow = (*b)[yp+dy] + xp; 262 | double* prow = &accum[4*((ay+dy)*a->w + ax)]; 263 | for(int dx = 0; dx < patch_w; dx++) { 264 | int c = brow[dx]; 265 | double* p = &prow[4*dx]; 266 | p[0] += (c&255); 267 | p[1] += ((c>>8)&255); 268 | p[2] += ((c>>16)&255); 269 | p[3] += 1; 270 | } 271 | } 272 | } 273 | } 274 | ans = norm_image(accum, a->w, a->h, NULL); 275 | } 276 | 277 | 278 | int main(int argc, char *argv[]) { 279 | argc--; 280 | argv++; 281 | if (argc != 4) { fprintf(stderr, "pm_minimal a b ann annd\n" 282 | "Given input images a, b outputs nearest neighbor field 'ann' mapping a => b coords, and the squared L2 distance 'annd'\n" 283 | "These are stored as RGB 24-bit images, with a 24-bit int at every pixel. For the NNF we store (by<<12)|bx."); exit(1); } 284 | printf("(1) Loading input images\n"); 285 | BITMAP *a = load_bitmap(argv[0]); 286 | BITMAP *b = load_bitmap(argv[1]); 287 | BITMAP *ann = NULL, *annd = NULL; 288 | printf("\n(2) Running PatchMatch\n"); 289 | patchmatch(a, b, ann, annd); 290 | printf("\n(3) Saving output images: ann & annd\n"); 291 | save_bitmap(ann, argv[2]); 292 | save_bitmap(annd, argv[3]); 293 | 294 | // Reconstruct image based on ann 295 | printf("\n(4) Reconstructibg an image for the source image\n"); 296 | BITMAP *r = NULL; 297 | reconstruct(a, b, ann, r); 298 | save_bitmap(r, "a_restructed.jpg"); 299 | 300 | return 0; 301 | } 302 | -------------------------------------------------------------------------------- /gui/PatchMatch.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/gui/PatchMatch.fig -------------------------------------------------------------------------------- /gui/PatchMatch.m: -------------------------------------------------------------------------------- 1 | function varargout = PatchMatch(varargin) 2 | % PATCHMATCH MATLAB code for PatchMatch.fig 3 | % PATCHMATCH, by itself, creates a new PATCHMATCH or raises the existing 4 | % singleton*. 5 | % 6 | % H = PATCHMATCH returns the handle to a new PATCHMATCH or the handle to 7 | % the existing singleton*. 8 | % 9 | % PATCHMATCH('CALLBACK',hObject,eventData,handles,...) calls the local 10 | % function named CALLBACK in PATCHMATCH.M with the given input arguments. 11 | % 12 | % PATCHMATCH('Property','Value',...) creates a new PATCHMATCH or raises the 13 | % existing singleton*. Starting from the left, property value pairs are 14 | % applied to the GUI before PatchMatch_OpeningFcn gets called. An 15 | % unrecognized property name or invalid value makes property application 16 | % stop. All inputs are passed to PatchMatch_OpeningFcn via varargin. 17 | % 18 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 19 | % instance to run (singleton)". 20 | % 21 | % See also: GUIDE, GUIDATA, GUIHANDLES 22 | 23 | % Edit the above text to modify the response to help PatchMatch 24 | 25 | % Last Modified by GUIDE v2.5 04-Apr-2018 00:26:10 26 | 27 | % Begin initialization code - DO NOT EDIT 28 | 29 | 30 | gui_Singleton = 1; 31 | gui_State = struct('gui_Name', mfilename, ... 32 | 'gui_Singleton', gui_Singleton, ... 33 | 'gui_OpeningFcn', @PatchMatch_OpeningFcn, ... 34 | 'gui_OutputFcn', @PatchMatch_OutputFcn, ... 35 | 'gui_LayoutFcn', [] , ... 36 | 'gui_Callback', []); 37 | if nargin && ischar(varargin{1}) 38 | gui_State.gui_Callback = str2func(varargin{1}); 39 | end 40 | 41 | if nargout 42 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 43 | else 44 | gui_mainfcn(gui_State, varargin{:}); 45 | end 46 | % End initialization code - DO NOT EDIT 47 | 48 | 49 | % --- Executes just before PatchMatch is made visible. 50 | function PatchMatch_OpeningFcn(hObject, eventdata, handles, varargin) 51 | % This function has no output args, see OutputFcn. 52 | % hObject handle to figure 53 | % eventdata reserved - to be defined in a future version of MATLAB 54 | % handles structure with handles and user data (see GUIDATA) 55 | % varargin command line arguments to PatchMatch (see VARARGIN) 56 | global img; 57 | global msk; 58 | global mskcol; 59 | global wbmFlg; 60 | global point0; 61 | global drawFlg; 62 | global pnSize; 63 | global imSize; 64 | global viewMode; 65 | 66 | img = []; 67 | msk = []; 68 | mskcol = [0 0 0]; 69 | wbmFlg = 0; 70 | point0 = []; 71 | drawFlg = -1; 72 | imSize = []; 73 | pnSize = 5; 74 | viewMode = 1; 75 | % Choose default command line output for PatchMatch 76 | handles.output = hObject; 77 | 78 | % Update handles structure 79 | guidata(hObject, handles); 80 | 81 | %set(hObject,... 82 | %'WindowButtonMotionFcn',{@uipanel1_ButtonMotionFcn},... 83 | %'WindowButtonUpFcn',{@uipanel1_ButtonUpFcn},... 84 | %'WindowButtonDownFcn',{@uipanel1_ButtonDownFcn}); 85 | 86 | % UIWAIT makes PatchMatch wait for user response (see UIRESUME) 87 | % uiwait(handles.figure1); 88 | 89 | 90 | % --- Outputs from this function are returned to the command line. 91 | function varargout = PatchMatch_OutputFcn(hObject, eventdata, handles) 92 | % varargout cell array for returning output args (see VARARGOUT); 93 | % hObject handle to figure 94 | % eventdata reserved - to be defined in a future version of MATLAB 95 | % handles structure with handles and user data (see GUIDATA) 96 | 97 | % Get default command line output from handles structure 98 | varargout{1} = handles.output; 99 | 100 | 101 | function uipanel1_ButtonDownFcn(hObject, eventdata, handles) 102 | % hObject handle to figure1 (see GCBO) 103 | % eventdata reserved - to be defined in a future version of MATLAB 104 | % handles structure with handles and user data (see GUIDATA) 105 | 106 | % --- Executes on button press in pushbutton1. 107 | function pushbutton1_Callback(hObject, eventdata, handles) 108 | % hObject handle to pushbutton1 (see GCBO) 109 | % eventdata reserved - to be defined in a future version of MATLAB 110 | % handles structure with handles and user data (see GUIDATA) 111 | 112 | global filename; 113 | global dir; 114 | [filename, dir] = uigetfile( '*.*', 'Load Image'); 115 | 116 | global img; 117 | global msk; 118 | global imSize; 119 | 120 | img = imread([dir filename]); 121 | imSize = size(img); 122 | msk = zeros(imSize(1),imSize(2),'uint8'); 123 | axes(handles.uipanel1); 124 | imshow(img); 125 | 126 | 127 | 128 | 129 | function edit1_Callback(hObject, eventdata, handles) 130 | % hObject handle to edit1 (see GCBO) 131 | % eventdata reserved - to be defined in a future version of MATLAB 132 | % handles structure with handles and user data (see GUIDATA) 133 | 134 | % Hints: get(hObject,'String') returns contents of edit1 as text 135 | % str2double(get(hObject,'String')) returns contents of edit1 as a double 136 | 137 | 138 | % --- Executes during object creation, after setting all properties. 139 | function edit1_CreateFcn(hObject, eventdata, handles) 140 | % hObject handle to edit1 (see GCBO) 141 | % eventdata reserved - to be defined in a future version of MATLAB 142 | % handles empty - handles not created until after all CreateFcns called 143 | 144 | % Hint: edit controls usually have a white background on Windows. 145 | % See ISPC and COMPUTER. 146 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 147 | set(hObject,'BackgroundColor','white'); 148 | end 149 | 150 | 151 | % --- Executes during object creation, after setting all properties. 152 | function pushbutton1_CreateFcn(hObject, eventdata, handles) 153 | % hObject handle to pushbutton1 (see GCBO) 154 | % eventdata reserved - to be defined in a future version of MATLAB 155 | % handles empty - handles not created until after all CreateFcns called 156 | 157 | 158 | % --- Executes on mouse press over figure background, over a disabled or 159 | % --- inactive control, or over an axes background. 160 | function figure1_WindowButtonDownFcn(hObject, eventdata, handles) 161 | % hObject handle to figure1 (see GCBO) 162 | % eventdata reserved - to be defined in a future version of MATLAB 163 | % handles structure with handles and user data (see GUIDATA) 164 | global drawFlg; 165 | global point0; 166 | 167 | mouse = get(gcf,'SelectionType'); 168 | if( strcmpi( mouse, 'normal' ) ) 169 | drawFlg = 1; 170 | point0 = getPixelPosition(); 171 | 172 | elseif( strcmpi( mouse, 'alt' ) ) 173 | drawFlg = 0; 174 | point0 = getPixelPosition(); 175 | 176 | else 177 | drawFlg = -1; 178 | end 179 | 180 | 181 | % --- Executes on mouse motion over figure - except title and menu. 182 | function figure1_WindowButtonMotionFcn(hObject, eventdata, handles) 183 | % hObject handle to figure1 (see GCBO) 184 | % eventdata reserved - to be defined in a future version of MATLAB 185 | % handles structure with handles and user data (see GUIDATA) 186 | global pnSize; 187 | global imSize; 188 | global msk; 189 | global point0; 190 | global drawFlg; 191 | 192 | global wbmFlg; 193 | 194 | if( wbmFlg == 0 && drawFlg >= 0 ) 195 | wbmFlg = 1; 196 | 197 | point1 = getPixelPosition() 198 | 199 | if( ~isempty( point0 ) ) 200 | ps = pnSize / 480 * max([imSize(1),imSize(2)]); 201 | msk = drawLine( msk, point0, point1, ps, drawFlg ); 202 | showImageMask(handles.uipanel1); 203 | end 204 | 205 | point0 = point1; 206 | 207 | wbmFlg = 0; 208 | end 209 | 210 | 211 | % --- Executes on mouse press over figure background, over a disabled or 212 | % --- inactive control, or over an axes background. 213 | function figure1_WindowButtonUpFcn(hObject, eventdata, handles) 214 | % hObject handle to figure1 (see GCBO) 215 | % eventdata reserved - to be defined in a future version of MATLAB 216 | % handles structure with handles and user data (see GUIDATA) 217 | global drawFlg; 218 | global point0; 219 | drawFlg = -1; 220 | point0 = []; 221 | 222 | function point = getPixelPosition() 223 | global imSize; 224 | 225 | if( isempty( imSize ) ) 226 | point = []; 227 | else 228 | cp = get (gca, 'CurrentPoint'); 229 | cp = cp(1,1:2); 230 | row = int32(round( axes2pix(imSize(1), [1 imSize(1)], cp(2)) )); 231 | col = int32(round( axes2pix(imSize(2), [1 imSize(2)], cp(1)) )); 232 | 233 | point = [row col]; 234 | end 235 | 236 | 237 | % --- Executes on button press in pushbutton2. 238 | function pushbutton2_Callback(hObject, eventdata, handles) 239 | % hObject handle to pushbutton2 (see GCBO) 240 | % eventdata reserved - to be defined in a future version of MATLAB 241 | % handles structure with handles and user data (see GUIDATA) 242 | global filename; 243 | global dir; 244 | global img; 245 | global msk; 246 | global mskcol; 247 | 248 | [d name ext] = fileparts(filename); 249 | 250 | msk = uint8(msk*255); 251 | maskimage = double(img).*double(repmat(~msk,1,1,3)); 252 | imwrite( uint8(maskimage), [dir name '_img.png'] ); 253 | imwrite( uint8(msk), [dir name '_msk.png'] ); 254 | 255 | function [] = showImageMask(handle) 256 | global img; 257 | global msk; 258 | global mskcol; 259 | global viewMode; 260 | 261 | if( ~isempty(img) ) 262 | switch( viewMode ) 263 | case 1 264 | maskimage = genImageMask( single(img), single(msk), single(mskcol) ); 265 | case 2 266 | maskimage = reshape( mskcol, [1 1 3] ); 267 | maskimage = single(repmat( maskimage, [size(msk,1), size(msk,2), 1] )) .* single(repmat( msk, [1 1 3] )); 268 | case 3 269 | maskimage = img; 270 | otherwise 271 | maskimage = zeros(size(msk)); 272 | end 273 | axes(handle); 274 | imshow(uint8(maskimage)); 275 | end 276 | -------------------------------------------------------------------------------- /gui/Untitled Document: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/gui/Untitled Document -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 |
4 |

5 | Image/Video editing tools and applications have been widely used in many areas, including marketing, fashion design, and film production. Among these applications, we are especially interested in Image Completion, and think it is an important function. Why is Image Completion important? Actually, it is very useful for lots of purposes. No matter it’s for everyday photo or movie post-processing, it can help you remove objects you don’t want (see Fig1 and Fig2). 6 |

7 |
8 | 9 |
10 |
11 | 12 |

Figure 1: Everyday Photo

13 | 14 |

Figure 2: Movie Post-Processing

15 |
16 |
17 | 18 | # State-of-the-Art 19 | 20 |
21 |

22 | We survey the literature works. The latest one is from SIGGRAPH 2017 (see Fig3), which is based on deep neural network. 23 |

24 |
25 | 26 |
27 |
28 | 29 |

Figure 3: Deep convolutional neural networks [1]

30 |
31 |
32 | 33 |
34 |

35 | Although this work is very powerful, it may still fail in some cases (see Fig4). We also find other problems with this model. Usually, It takes lots of time and images to train a model. Also, it doesn’t provide an interactive way for users to improve results if they are not good enough. 36 |

37 |
38 | 39 |
40 |
41 | 42 |

Figure 4: Failed case in [1]

43 |
44 |
45 | 46 | # Adobe Photoshop: Content Aware Fill (PatchMatch) 47 | 48 |
49 |

50 | Thus, we’re more interested in what’s the industry solution for this problem since we usually ask for a higher standard of image quality provided by those market products. We find that Adobe Photoshop also has this function which is called Content Aware Fill (see Fig5) using PatchMatch algorithm [2]. So, we try to find some insights from this algorithm. 51 |

52 |
53 | 54 |
55 |
56 | 57 |

Figure 5: Adobe Photoshop: Content Aware Fill

58 |
59 |
60 | 61 | # PatchMatch 62 | ## Algorithm 63 | 64 |
65 |

66 | The purpose of the PatchMatch algorithm is to efficiently find the similar patches between two images. Basically, its algorithm contains three steps: random initlization, propagation, and random search (see Fig6). 67 |

68 |
69 | 70 |
71 |
72 | 73 |

Figure 6: PatchMatch Algorithm

74 |
75 |
76 | 77 |
78 |

79 | Take Fig7 as example. For each patch in A, we try to find a similar patch in B. In the fist step, we randomly match each patch in A with a patch in B. If we’re lucky, we may get some pairs already similar enough. Then, in the second step, we check if our neighbors can give us a better candidate patch. If it is, we just propagate this benefit, i.e., just update the patch. In the final step, we continue looking for a better patch in our neighborhood by random search in order to get out of a local optimum. 80 |

81 |
82 | 83 |
84 |
85 | 86 |

Figure 7: Example of PatchMatch Algorithm

87 |
88 |
89 | 90 | ## Simulation Result 91 | 92 |
93 |

94 | Here is the simulation results (see Fig8). You can see how fast this algorithm is. Even for the first iteration, we can almost reconstruct the image just using pixels from B. Then, after that, each iteration just gets the result sharper and sharper. 95 |

96 |
97 | 98 |
99 |
100 | 101 |

Figure 8: Simulation Results of Different Iterations

102 |
103 |
104 | 105 |
106 |

107 | In addition to the subjective evaluation, we also calculate its SNR score, which shows how similar two images look like. According to the SNR formula below, we calculate 27.860412 as the SNR score, which also shows that the original image and the final result are very similar based on the criteria of ISO 12232: Electronic Still Picture Cameras. 108 |

109 |
110 | 111 |
112 |
113 | 114 |

Figure 9: SNR Formula and ISO 12232 Criteria

115 |
116 |
117 | 118 | # Image Completion 119 | ## Task Definition 120 |
121 |

122 | Image completion/inpainting is used when there is corrupted or unwanted region in image and we want to fill those region with 123 | pixels that are coherent with the background. Below is an illustration, say we want to remove the cow in the image, we will 124 | done that by remove the cow from image and try to complete it. 125 |

126 |
127 |
128 |
129 | 130 |

Figure 10: Image Completion Task Definition

131 |
132 |
133 | 134 | ## First try 135 |
136 |

137 | To use patchmatch for image completion, we come up with this straight forward method. 138 | First, find a bounding box of the missing region. 139 | Then for each patch in the bounding box, we try to find the nearest patch outside the bounding box use PatchMatch. 140 | Finally, we just use those nearest patches to vote for the pixel value inside the missing region. 141 |

142 |
143 |
144 |
145 | 146 |

Figure 11: Algorithm of First Try

147 |
148 |
149 |
150 |
151 | 152 |

Figure 12: Result of First Try

153 |
154 |
155 | 156 | ## What's the problem? 157 |
158 |

159 | We can observe that there are some blurred region of the result in Figure 12. It is because the nearby pixels in the 160 | missing region are not finding coherent nearest neighbor patches. When those patches voting for the pixel, they give 161 | different votes and averaging them yields blur region. 162 |

163 |

164 | So how can we find better nearest neighbor patches? 165 | Turns out that we want patch size to be large enough in the first hand to see the global picture of the image. 166 | Meanwhile, we also want it to become small enough in the end so that our algithm can be aware of local structure 167 | and produce sharp image. The answer to that is adaptive patch size, or we can done that by fix patch size and varying 168 | the image size in multiple scale. 169 |

170 |
171 | 172 | ## Multi-Scale Image Completion 173 |
174 |

175 | We use multi-scale image completion, as described in [3]. 176 | We start from the smallest scale, do image completion at that scale, then keep scaling up until we meet the original scale. 177 | In each scale change, for the pixels outside the missing region, we simply scale down the original image to that scale; 178 | for the pixels inside the missing region, we scale up the filled region as initialization of next scale. 179 |

180 |
181 | 182 |
183 |
184 | 185 |

Figure 13: Algorithm of Multi-Scale Image Completion

186 |
187 |
188 |
189 |
190 | 191 |

Figure 14: Result of Multi-Scale Image Completion

192 |
193 |
194 | 195 | ## Incorporating Constraints 196 |
197 |

198 | However, sometimes it still produce images with artifacts, like the left image of Figure 17. 199 | Luckily, there is a solution. We follow [1] to incorporate user-specified constraints to enhance the completion result. 200 | To do that, we simply restrict the constrained pixels in missing region to search for patches that are of same constraint. 201 |

202 |
203 |
204 |
205 | 206 |

Figure 15: Man and dog image

207 |
208 |
209 |
210 |
211 | 212 |

Figure 16: User-specified constraint

213 |
214 |
215 |
216 |
217 | 218 |

Figure 17: Image completion result of man and dog

219 |
220 |
221 | 222 | # Interactive GUI 223 |
224 |

225 | We designed an interactive GUI for end users. User can load an image and mask for that image. Then he/she can introduce some contraints to maintain some boundaries and let the algorithm complete the hole in the image. Using our imterative interface user can improve the performance of image completion. For a short demonstraion please watch the video below. 226 |

227 |
228 | 229 |
230 | 231 |
232 | 233 | # Image Completion Results 234 | 235 |
236 |
237 | 238 |
239 |
240 | 241 |
242 |
243 | 244 |
245 |
246 |
247 |
248 | 249 |
250 |
251 |
252 |
253 | 254 |
255 |
256 |
257 |
258 | 259 |
260 |
261 | 262 | # Future Work 263 | 1. Adopt KNN rather than the most similar patch 264 | 2. Figure out a way for better initialization 265 | 3. Find how to determine patch size 266 | 4. Speed up our application to real time 267 | 5. Improve the sensitivity issues for initialization and patch size 268 | 269 | # Presentation 270 | [Slides](https://docs.google.com/presentation/d/1YMoPjG7pNWLSEDjNDadcxzCkqFpysvW_enfNe-DhoVM/edit#slide=id.p1) 271 | 272 | # Source Code 273 | [Code](https://github.com/WenFuLee/CS-766-Computer-Vision) 274 | 275 | # Reference 276 | 1. Iizuka, S., Simo-Serra, E., & Ishikawa, H. (2017). Globally and locally consistent image completion. ACM Transactions on Graphics (TOG), 36(4), 107. 277 | 2. Barnes, C., Shechtman, E., Finkelstein, A., & Goldman, D. B. (2009). PatchMatch: A randomized correspondence algorithm for structural image editing. ACM Transactions on Graphics-TOG, 28(3), 24. 278 | 3. Wexler, Y., Shechtman, E., & Irani, M. (2007). Space-time completion of video. IEEE Transactions on pattern analysis and machine intelligence, 29(3). 279 | 4. Hays, J., & Efros, A. A. (2007, August). Scene completion using millions of photographs. In ACM Transactions on Graphics (TOG) (Vol. 26, No. 3, p. 4). ACM. 280 | -------------------------------------------------------------------------------- /report/image/constraint_illu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/constraint_illu.png -------------------------------------------------------------------------------- /report/image/constraint_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/constraint_result.png -------------------------------------------------------------------------------- /report/image/first_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/first_result.png -------------------------------------------------------------------------------- /report/image/first_try.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/first_try.png -------------------------------------------------------------------------------- /report/image/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image1.png -------------------------------------------------------------------------------- /report/image/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image2.png -------------------------------------------------------------------------------- /report/image/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image3.png -------------------------------------------------------------------------------- /report/image/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image4.png -------------------------------------------------------------------------------- /report/image/image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image5.png -------------------------------------------------------------------------------- /report/image/image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image6.png -------------------------------------------------------------------------------- /report/image/image7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image7.png -------------------------------------------------------------------------------- /report/image/image8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image8.png -------------------------------------------------------------------------------- /report/image/image9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/image9.png -------------------------------------------------------------------------------- /report/image/man_dog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/man_dog.png -------------------------------------------------------------------------------- /report/image/multi_algo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/multi_algo.png -------------------------------------------------------------------------------- /report/image/multi_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/multi_result.png -------------------------------------------------------------------------------- /report/image/result1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/result1.png -------------------------------------------------------------------------------- /report/image/result2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/result2.png -------------------------------------------------------------------------------- /report/image/result3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/result3.png -------------------------------------------------------------------------------- /report/image/result4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/result4.png -------------------------------------------------------------------------------- /report/image/result5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/result5.png -------------------------------------------------------------------------------- /report/image/task_def.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/report/image/task_def.png -------------------------------------------------------------------------------- /report/tmp.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex1/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex1/a.png -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex1/a_completion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex1/a_completion.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex1/a_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex1/a_hole.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex1/a_hole_mask.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex1/a_hole_mask.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex2/test7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex2/test7.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex2/test7h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex2/test7h.png -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex2/test7m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex2/test7m.png -------------------------------------------------------------------------------- /simulation-results/Image_Completion_Ex2/test7m_completion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Completion_Ex2/test7m_completion.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Reconstruction_Ex1/Source Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Reconstruction_Ex1/Source Image.png -------------------------------------------------------------------------------- /simulation-results/Image_Reconstruction_Ex1/Target Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Reconstruction_Ex1/Target Image.png -------------------------------------------------------------------------------- /simulation-results/Image_Reconstruction_Ex1/a_restructed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Reconstruction_Ex1/a_restructed.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Reconstruction_Ex1/ann.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Reconstruction_Ex1/ann.jpg -------------------------------------------------------------------------------- /simulation-results/Image_Reconstruction_Ex1/annd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/simulation-results/Image_Reconstruction_Ex1/annd.jpg -------------------------------------------------------------------------------- /simulation-results/Untitled Document: -------------------------------------------------------------------------------- 1 | sdf 2 | -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test2.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test2h.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test2h.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test2m.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test2m.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test3.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test3h.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test3h.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test3m.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test3m.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test7.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test7h.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test7h.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test7m.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test7m.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test8.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test8h.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test8h.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/bmp/test8m.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/bmp/test8m.bmp -------------------------------------------------------------------------------- /test-images/Image_Completion/createHole.m: -------------------------------------------------------------------------------- 1 | 2 | for i=1 3 | 4 | if exist(strcat('test',num2str(i),'.bmp'), 'file')==2 5 | 6 | a = imread(strcat('test',num2str(i),'.bmp')); 7 | mask = ~logical(imread(strcat('test',num2str(i),'m.bmp'))); 8 | r = a.*uint8(~mask); 9 | imwrite(mask(:,:,1), strcat('test',num2str(i),'m.bmp')); 10 | imwrite(r, strcat('test',num2str(i),'h.bmp')); 11 | else 12 | a = imread(strcat('test',num2str(i),'.jpg')); 13 | mask = ~logical(imread(strcat('test',num2str(i),'m.jpg'))); 14 | r = a.*uint8(~mask); 15 | imwrite(mask(:,:,1), strcat('test',num2str(i),'m.jpg')); 16 | imwrite(r, strcat('test',num2str(i),'h.jpg')); 17 | end 18 | 19 | end -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test1.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test1h.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test1m.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test1m.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test4.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test4h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test4h.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test4m.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test4m.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test5.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test5h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test5h.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test5m.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test5m.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test6.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test6h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test6h.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/jpg/test6m.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/jpg/test6m.jpg -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test1.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test1m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test1m.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test2.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test2m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test2m.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test3.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test3m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test3m.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test4.png -------------------------------------------------------------------------------- /test-images/Image_Completion/png/test4m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Completion/png/test4m.png -------------------------------------------------------------------------------- /test-images/Image_Reconstruction/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Reconstruction/a.png -------------------------------------------------------------------------------- /test-images/Image_Reconstruction/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Reconstruction/b.png -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_10_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_10_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_17_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_17_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_19_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_19_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_1_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_1_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_20_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_20_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_21_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_21_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_23_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_23_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_24_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_24_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_26_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_26_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_27_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_27_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_28_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_28_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_29_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_29_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_2_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_2_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_30_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_30_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_32_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_32_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_35_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_35_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_4_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_4_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_5_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_5_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_6_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_6_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_8_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_8_aaa.jpg -------------------------------------------------------------------------------- /test-images/Image_Retargeting/ours_9_aaa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/Image_Retargeting/ours_9_aaa.jpg -------------------------------------------------------------------------------- /test-images/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/a.png -------------------------------------------------------------------------------- /test-images/a_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/a_hole.jpg -------------------------------------------------------------------------------- /test-images/a_hole_mask.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/a_hole_mask.jpg -------------------------------------------------------------------------------- /test-images/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenFuLee/CS-766-Computer-Vision/23aa58c6c8709fea22ca9cb3c06ddf254723e330/test-images/b.png --------------------------------------------------------------------------------