Commit 6c0b5d11 by Yijun Tan

repore init

parents
images/*
.vscode/*
.build/*
.data/*
\ No newline at end of file
cmake_minimum_required(VERSION 3.0)
project(ppPlace)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(ENV{TYPE_CALL} library)
file(GLOB_RECURSE SRC
src/*
)
add_executable(ppPlace main.cpp ${SRC})
target_include_directories(ppPlace PUBLIC ${CMAKE_SOURCE_DIR}/include/)
target_include_directories(ppPlace PUBLIC ${CMAKE_SOURCE_DIR}/module/CImg)
#target_link_libraries(ppPlace X11 pthread)
target_link_libraries(ppPlace pthread)
#cmake .. -G "MinGW Makefiles"
\ No newline at end of file
set(CMAKE_C_COMPILER "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe")
set(CMAKE_C_COMPILER_ARG1 "")
set(CMAKE_C_COMPILER_ID "GNU")
set(CMAKE_C_COMPILER_VERSION "8.1.0")
set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
set(CMAKE_C_COMPILER_WRAPPER "")
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "17")
set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "ON")
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;c_std_17")
set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")
set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")
set(CMAKE_C17_COMPILE_FEATURES "c_std_17")
set(CMAKE_C23_COMPILE_FEATURES "")
set(CMAKE_C_PLATFORM_ID "MinGW")
set(CMAKE_C_SIMULATE_ID "")
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
set(CMAKE_C_SIMULATE_VERSION "")
set(CMAKE_AR "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ar.exe")
set(CMAKE_C_COMPILER_AR "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc-ar.exe")
set(CMAKE_RANLIB "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ranlib.exe")
set(CMAKE_C_COMPILER_RANLIB "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc-ranlib.exe")
set(CMAKE_LINKER "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ld.exe")
set(CMAKE_MT "")
set(CMAKE_COMPILER_IS_GNUCC 1)
set(CMAKE_C_COMPILER_LOADED 1)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_C_ABI_COMPILED TRUE)
set(CMAKE_C_COMPILER_ENV_VAR "CC")
set(CMAKE_C_COMPILER_ID_RUN 1)
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_C_LINKER_PREFERENCE 10)
# Save compiler ABI information.
set(CMAKE_C_SIZEOF_DATA_PTR "8")
set(CMAKE_C_COMPILER_ABI "")
set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN")
set(CMAKE_C_LIBRARY_ARCHITECTURE "")
if(CMAKE_C_SIZEOF_DATA_PTR)
set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
endif()
if(CMAKE_C_COMPILER_ABI)
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
endif()
if(CMAKE_C_LIBRARY_ARCHITECTURE)
set(CMAKE_LIBRARY_ARCHITECTURE "")
endif()
set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
endif()
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include")
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "mingw32;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;iconv;mingw32;gcc;moldname;mingwex")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/lib;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib")
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
set(CMAKE_CXX_COMPILER "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe")
set(CMAKE_CXX_COMPILER_ARG1 "")
set(CMAKE_CXX_COMPILER_ID "GNU")
set(CMAKE_CXX_COMPILER_VERSION "8.1.0")
set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
set(CMAKE_CXX_COMPILER_WRAPPER "")
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "ON")
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;cxx_std_20")
set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
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")
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")
set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
set(CMAKE_CXX23_COMPILE_FEATURES "")
set(CMAKE_CXX_PLATFORM_ID "MinGW")
set(CMAKE_CXX_SIMULATE_ID "")
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
set(CMAKE_CXX_SIMULATE_VERSION "")
set(CMAKE_AR "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ar.exe")
set(CMAKE_CXX_COMPILER_AR "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc-ar.exe")
set(CMAKE_RANLIB "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ranlib.exe")
set(CMAKE_CXX_COMPILER_RANLIB "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc-ranlib.exe")
set(CMAKE_LINKER "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/ld.exe")
set(CMAKE_MT "")
set(CMAKE_COMPILER_IS_GNUCXX 1)
set(CMAKE_CXX_COMPILER_LOADED 1)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_CXX_ABI_COMPILED TRUE)
set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
set(CMAKE_CXX_COMPILER_ID_RUN 1)
set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm)
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
foreach (lang C OBJC OBJCXX)
if (CMAKE_${lang}_COMPILER_ID_RUN)
foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
endforeach()
endif()
endforeach()
set(CMAKE_CXX_LINKER_PREFERENCE 30)
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
# Save compiler ABI information.
set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
set(CMAKE_CXX_COMPILER_ABI "")
set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN")
set(CMAKE_CXX_LIBRARY_ARCHITECTURE "")
if(CMAKE_CXX_SIZEOF_DATA_PTR)
set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
endif()
if(CMAKE_CXX_COMPILER_ABI)
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
endif()
if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
set(CMAKE_LIBRARY_ARCHITECTURE "")
endif()
set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
endif()
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include")
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;mingw32;gcc_s;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;iconv;mingw32;gcc_s;gcc;moldname;mingwex")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/lib;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib")
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
set(CMAKE_RC_COMPILER "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/windres.exe")
set(CMAKE_RC_COMPILER_ARG1 "")
set(CMAKE_RC_COMPILER_LOADED 1)
set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC)
set(CMAKE_RC_OUTPUT_EXTENSION .obj)
set(CMAKE_RC_COMPILER_ENV_VAR "RC")
set(CMAKE_HOST_SYSTEM "Windows-10.0.22621")
set(CMAKE_HOST_SYSTEM_NAME "Windows")
set(CMAKE_HOST_SYSTEM_VERSION "10.0.22621")
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
set(CMAKE_SYSTEM "Windows-10.0.22621")
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_SYSTEM_VERSION "10.0.22621")
set(CMAKE_SYSTEM_PROCESSOR "AMD64")
set(CMAKE_CROSSCOMPILING "FALSE")
set(CMAKE_SYSTEM_LOADED 1)
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.22
# Relative path conversion top directories.
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "E:/iccad2023/ppp")
set(CMAKE_RELATIVE_PATH_TOP_BINARY "E:/iccad2023/ppp/build")
# Force unix paths in dependencies.
set(CMAKE_FORCE_UNIX_PATHS 1)
# The C and CXX include file regular expressions for this directory.
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.22
# The generator used is:
set(CMAKE_DEPENDS_GENERATOR "MinGW Makefiles")
# The top level Makefile was generated from the following files:
set(CMAKE_MAKEFILE_DEPENDS
"CMakeCache.txt"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeGenericSystem.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeRCInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-C.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-CXX.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-C-ABI.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-C.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-CXX-ABI.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-CXX.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-windres.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/WindowsPaths.cmake"
"../CMakeLists.txt"
"CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeSystem.cmake"
)
# The corresponding makefile is:
set(CMAKE_MAKEFILE_OUTPUTS
"Makefile"
"CMakeFiles/cmake.check_cache"
)
# Byproducts of CMake generate step:
set(CMAKE_MAKEFILE_PRODUCTS
"CMakeFiles/CMakeDirectoryInformation.cmake"
)
# Dependency information for all targets:
set(CMAKE_DEPEND_INFO_FILES
"CMakeFiles/ppPlace.dir/DependInfo.cmake"
)
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.22
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Disable VCS-based implicit rules.
% : %,v
# Disable VCS-based implicit rules.
% : RCS/%
# Disable VCS-based implicit rules.
% : RCS/%,v
# Disable VCS-based implicit rules.
% : SCCS/s.%
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
SHELL = cmd.exe
# The CMake executable.
CMAKE_COMMAND = "C:\Program Files\CMake\bin\cmake.exe"
# The command to remove a file.
RM = "C:\Program Files\CMake\bin\cmake.exe" -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = E:\iccad2023\ppp
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = E:\iccad2023\ppp\build
#=============================================================================
# Directory level rules for the build root directory
# The main recursive "all" target.
all: CMakeFiles/ppPlace.dir/all
.PHONY : all
# The main recursive "preinstall" target.
preinstall:
.PHONY : preinstall
# The main recursive "clean" target.
clean: CMakeFiles/ppPlace.dir/clean
.PHONY : clean
#=============================================================================
# Target rules for target CMakeFiles/ppPlace.dir
# All Build rule for target.
CMakeFiles/ppPlace.dir/all:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/depend
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=1,2,3,4,5,6 "Built target ppPlace"
.PHONY : CMakeFiles/ppPlace.dir/all
# Build rule for subdir invocation for target.
CMakeFiles/ppPlace.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 6
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 CMakeFiles/ppPlace.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 0
.PHONY : CMakeFiles/ppPlace.dir/rule
# Convenience name for target.
ppPlace: CMakeFiles/ppPlace.dir/rule
.PHONY : ppPlace
# clean rule for target.
CMakeFiles/ppPlace.dir/clean:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/clean
.PHONY : CMakeFiles/ppPlace.dir/clean
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 0
.PHONY : cmake_check_build_system
E:/iccad2023/ppp/build/CMakeFiles/ppPlace.dir
E:/iccad2023/ppp/build/CMakeFiles/edit_cache.dir
E:/iccad2023/ppp/build/CMakeFiles/rebuild_cache.dir
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
# Consider dependencies only in project.
set(CMAKE_DEPENDS_IN_PROJECT_ONLY OFF)
# The set of languages for which implicit dependencies are needed:
set(CMAKE_DEPENDS_LANGUAGES
)
# The set of dependency files which are needed:
set(CMAKE_DEPENDS_DEPENDENCY_FILES
"E:/iccad2023/ppp/main.cpp" "CMakeFiles/ppPlace.dir/main.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/main.cpp.obj.d"
"E:/iccad2023/ppp/src/Circuit.cpp" "CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj.d"
"E:/iccad2023/ppp/src/Database.cpp" "CMakeFiles/ppPlace.dir/src/Database.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/Database.cpp.obj.d"
"E:/iccad2023/ppp/src/FFTBin.cpp" "CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj.d"
"E:/iccad2023/ppp/src/FFT_calculator.cpp" "CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj.d"
)
# Targets to which this target links.
set(CMAKE_TARGET_LINKED_INFO_FILES
)
# Fortran module output directory.
set(CMAKE_Fortran_TARGET_MODULE_DIR "")
file(REMOVE_RECURSE
"CMakeFiles/ppPlace.dir/main.cpp.obj"
"CMakeFiles/ppPlace.dir/main.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj"
"CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/Database.cpp.obj"
"CMakeFiles/ppPlace.dir/src/Database.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj"
"CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj"
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj.d"
"libppPlace.dll.a"
"ppPlace.exe"
"ppPlace.exe.manifest"
"ppPlace.pdb"
)
# Per-language clean rules from dependency scanning.
foreach(lang CXX)
include(CMakeFiles/ppPlace.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
# CMAKE generated file: DO NOT EDIT!
# Timestamp file for compiler generated dependencies management for ppPlace.
# Empty dependencies file for ppPlace.
# This may be replaced when dependencies are built.
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.22
# compile CXX with C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe
CXX_DEFINES =
CXX_INCLUDES = @CMakeFiles/ppPlace.dir/includes_CXX.rsp
CXX_FLAGS =
-IE:/iccad2023/ppp/include -IE:/iccad2023/ppp/module/CImg
"C:\Program Files\CMake\bin\cmake.exe" -E rm -f CMakeFiles\ppPlace.dir/objects.a
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\ar.exe qc CMakeFiles\ppPlace.dir/objects.a @CMakeFiles\ppPlace.dir\objects1.rsp
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE -Wl,--whole-archive CMakeFiles\ppPlace.dir/objects.a -Wl,--no-whole-archive -o ppPlace.exe -Wl,--out-implib,libppPlace.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\ppPlace.dir\linklibs.rsp
-lpthread -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles/ppPlace.dir/main.cpp.obj CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj CMakeFiles/ppPlace.dir/src/Database.cpp.obj CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj
CMAKE_PROGRESS_1 = 1
CMAKE_PROGRESS_2 = 2
CMAKE_PROGRESS_3 = 3
CMAKE_PROGRESS_4 = 4
CMAKE_PROGRESS_5 = 5
CMAKE_PROGRESS_6 = 6
CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj: \
E:\iccad2023\ppp\src\FFT_calculator.cpp \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cmath \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits/c++config.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits/os_defines.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits/cpu_defines.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/cpp_type_traits.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ext/type_traits.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/math.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/vadefs.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/std_abs.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/stdlib.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed/limits.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed/syslimits.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/limits.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/stdlib.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/malloc.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/stdio.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw_print_push.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/_mingw_print_pop.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstdlib \
E:/iccad2023/ppp/include/FFT_calculator.h
# CMAKE generated file: DO NOT EDIT!
# Generated by "MinGW Makefiles" Generator, CMake Version 3.22
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Disable VCS-based implicit rules.
% : %,v
# Disable VCS-based implicit rules.
% : RCS/%
# Disable VCS-based implicit rules.
% : RCS/%,v
# Disable VCS-based implicit rules.
% : SCCS/s.%
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
SHELL = cmd.exe
# The CMake executable.
CMAKE_COMMAND = "C:\Program Files\CMake\bin\cmake.exe"
# The command to remove a file.
RM = "C:\Program Files\CMake\bin\cmake.exe" -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = E:\iccad2023\ppp
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = E:\iccad2023\ppp\build
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
"C:\Program Files\CMake\bin\cmake-gui.exe" -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
"C:\Program Files\CMake\bin\cmake.exe" --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles E:\iccad2023\ppp\build\\CMakeFiles\progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named ppPlace
# Build rule for target.
ppPlace: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 ppPlace
.PHONY : ppPlace
# fast build rule for target.
ppPlace/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/build
.PHONY : ppPlace/fast
main.obj: main.cpp.obj
.PHONY : main.obj
# target to build an object file
main.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/main.cpp.obj
.PHONY : main.cpp.obj
main.i: main.cpp.i
.PHONY : main.i
# target to preprocess a source file
main.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/main.cpp.i
.PHONY : main.cpp.i
main.s: main.cpp.s
.PHONY : main.s
# target to generate assembly for a file
main.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/main.cpp.s
.PHONY : main.cpp.s
src/Circuit.obj: src/Circuit.cpp.obj
.PHONY : src/Circuit.obj
# target to build an object file
src/Circuit.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj
.PHONY : src/Circuit.cpp.obj
src/Circuit.i: src/Circuit.cpp.i
.PHONY : src/Circuit.i
# target to preprocess a source file
src/Circuit.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Circuit.cpp.i
.PHONY : src/Circuit.cpp.i
src/Circuit.s: src/Circuit.cpp.s
.PHONY : src/Circuit.s
# target to generate assembly for a file
src/Circuit.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Circuit.cpp.s
.PHONY : src/Circuit.cpp.s
src/Database.obj: src/Database.cpp.obj
.PHONY : src/Database.obj
# target to build an object file
src/Database.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Database.cpp.obj
.PHONY : src/Database.cpp.obj
src/Database.i: src/Database.cpp.i
.PHONY : src/Database.i
# target to preprocess a source file
src/Database.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Database.cpp.i
.PHONY : src/Database.cpp.i
src/Database.s: src/Database.cpp.s
.PHONY : src/Database.s
# target to generate assembly for a file
src/Database.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Database.cpp.s
.PHONY : src/Database.cpp.s
src/FFTBin.obj: src/FFTBin.cpp.obj
.PHONY : src/FFTBin.obj
# target to build an object file
src/FFTBin.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj
.PHONY : src/FFTBin.cpp.obj
src/FFTBin.i: src/FFTBin.cpp.i
.PHONY : src/FFTBin.i
# target to preprocess a source file
src/FFTBin.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFTBin.cpp.i
.PHONY : src/FFTBin.cpp.i
src/FFTBin.s: src/FFTBin.cpp.s
.PHONY : src/FFTBin.s
# target to generate assembly for a file
src/FFTBin.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFTBin.cpp.s
.PHONY : src/FFTBin.cpp.s
src/FFT_calculator.obj: src/FFT_calculator.cpp.obj
.PHONY : src/FFT_calculator.obj
# target to build an object file
src/FFT_calculator.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj
.PHONY : src/FFT_calculator.cpp.obj
src/FFT_calculator.i: src/FFT_calculator.cpp.i
.PHONY : src/FFT_calculator.i
# target to preprocess a source file
src/FFT_calculator.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.i
.PHONY : src/FFT_calculator.cpp.i
src/FFT_calculator.s: src/FFT_calculator.cpp.s
.PHONY : src/FFT_calculator.s
# target to generate assembly for a file
src/FFT_calculator.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.s
.PHONY : src/FFT_calculator.cpp.s
# Help Target
help:
@echo The following are some of the valid targets for this Makefile:
@echo ... all (the default if no target is provided)
@echo ... clean
@echo ... depend
@echo ... edit_cache
@echo ... rebuild_cache
@echo ... ppPlace
@echo ... main.obj
@echo ... main.i
@echo ... main.s
@echo ... src/Circuit.obj
@echo ... src/Circuit.i
@echo ... src/Circuit.s
@echo ... src/Database.obj
@echo ... src/Database.i
@echo ... src/Database.s
@echo ... src/FFTBin.obj
@echo ... src/FFTBin.i
@echo ... src/FFTBin.s
@echo ... src/FFT_calculator.obj
@echo ... src/FFT_calculator.i
@echo ... src/FFT_calculator.s
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 0
.PHONY : cmake_check_build_system
# Install script for directory: E:/iccad2023/ppp
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/ppPlace")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
# Set default install directory permissions.
if(NOT DEFINED CMAKE_OBJDUMP)
set(CMAKE_OBJDUMP "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/objdump.exe")
endif()
if(CMAKE_INSTALL_COMPONENT)
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
else()
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
file(WRITE "E:/iccad2023/ppp/build/${CMAKE_INSTALL_MANIFEST}"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
NumTechnologies 2
Tech TA 3
LibCell N MC1 7 10 1
Pin P1 2 7
LibCell N MC2 14 10 2
Pin P1 10 4
Pin P2 4 6
LibCell Y MC3 17 12 3
Pin P1 5 3
Pin P2 3 6
Pin P3 10 8
Tech TB 3
LibCell N MC1 7 15 1
Pin P1 2 11
LibCell N MC2 12 15 2
Pin P1 5 12
Pin P2 8 3
LibCell Y MC3 18 18 3
Pin P1 2 12
Pin P2 3 3
Pin P3 15 7
DieSize 0 0 40 30
TopDieMaxUtil 80
BottomDieMaxUtil 90
TopDieRows 0 0 40 10 3
BottomDieRows 0 0 40 15 2
TopDieTech TA
BottomDieTech TB
TerminalSize 6 6
TerminalSpacing 5
TerminalCost 10
NumInstances 8
Inst C1 MC1
Inst C2 MC3
Inst C3 MC3
Inst C4 MC2
Inst C5 MC2
Inst C6 MC3
Inst C7 MC2
Inst C8 MC1
NumNets 6
Net N1 2
Pin C1/P1
Pin C2/P2
Net N2 3
Pin C2/P1
Pin C3/P1
Pin C7/P2
Net N3 2
Pin C2/P3
Pin C8/P1
Net N4 3
Pin C3/P3
Pin C6/P2
Pin C7/P1
Net N5 3
Pin C4/P2
Pin C6/P1
Pin C5/P1
Net N6 2
Pin C4/P1
Pin C5/P2
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
NumTechnologies 2
Tech TA 3
LibCell N MC1 7 10 1
Pin P1 2 7
LibCell N MC2 14 10 2
Pin P1 10 4
Pin P2 4 6
LibCell Y MC3 17 12 3
Pin P1 5 3
Pin P2 3 6
Pin P3 10 8
Tech TB 3
LibCell N MC1 7 15 1
Pin P1 2 11
LibCell N MC2 12 15 2
Pin P1 5 12
Pin P2 8 3
LibCell Y MC3 18 18 3
Pin P1 2 12
Pin P2 3 3
Pin P3 15 7
DieSize 0 0 40 60
TopDieMaxUtil 80
BottomDieMaxUtil 90
TopDieRows 0 0 40 10 3
BottomDieRows 0 0 40 15 2
TopDieTech TA
BottomDieTech TB
TerminalSize 6 6
TerminalSpacing 5
TerminalCost 10
NumInstances 8
Inst C1 MC1
Inst C2 MC3
Inst C3 MC3
Inst C4 MC2
Inst C5 MC2
Inst C6 MC3
Inst C7 MC2
Inst C8 MC1
NumNets 6
Net N1 2
Pin C1/P1
Pin C2/P2
Net N2 3
Pin C2/P1
Pin C3/P1
Pin C7/P2
Net N3 2
Pin C2/P3
Pin C8/P1
Net N4 3
Pin C3/P3
Pin C6/P2
Pin C7/P1
Net N5 3
Pin C4/P2
Pin C6/P1
Pin C5/P1
Net N6 2
Pin C4/P1
Pin C5/P2
filler cell NumInstances
local smoothing
cur a pre a coeff
cellcenter
\ No newline at end of file
#include "Database.h"
#include "FFTBin.h"
#include "Param.h"
class Circuit : public Database{
public:
int filler_num, allcell_num;
//std::vector<std::vector<Bin>> bins;
fftBin* fftbin;
int binsize_x;
int binsize_y;
float scale; //visualizer scale
public:
void init();
void makeCellList();
void setCellTechs();
void makeInstList();
//void makeNetList();
void initialPlacement(int);
//void readcase(std::string filename) {database.readcase(filename);}
void moveCellCoordinates();
void cellClassify();
void Iteration(int);
void checkCellPlace();
void fftinit();
void doFFT();
void updateDensity();
float calHPWL();
void preCalWL();
std::pair<float, float> calWLf(int);
void print();
//cimg
#if VISUAL
void draw(std::string, int Scale=1);
void plotCells(cimg_library::CImg<unsigned char>&);
void plotNets(cimg_library::CImg<unsigned char>&);
void drawLine(cimg_library::CImg<unsigned char>&, const int, const int, const int, const int, const unsigned int, const unsigned char[]);
//void drawBinDensity(cimg_library::CImg<unsigned char>& image, float opacity);
//void drawArrow(cimg_library::CImg<unsigned char>& image, int x1, int y1, int x3, int y3, int thick,
// const unsigned char color[], float opacity);
#endif
~Circuit() {delete fftbin;};
};
\ No newline at end of file
#ifndef PPP_DATABASE_H
#define PPP_DATABASE_H
#include "Param.h"
/*
class Net
{
int pin_num;
std::vector<std::pair<int, int>> pins;
};
*/
class Inst
{
public:
int w, h;
long area;
public:
Inst() = default;
Inst(int W, int H): w(W), h(H), area(W*H) {}
};
class Cell
{
public:
//int instance_id;
//int layer;
int w, h;
long area;
bool is_macro;
bool is_filler;
std::vector<std::pair<int, int>> pins;
public:
Cell() = default;
Cell(int W, int H): w(W), h(H), area(W*H), is_macro(false), is_filler(false) {}
Cell(int W, int H, bool IM): w(W), h(H), is_macro(IM), is_filler(false), area(W*H) {}
};
class Die_infro
{
public:
int MaxUtil;
int rowHeight,rowN;
long w, h;
int cells_num;
long long area;
int tech;
};
class Database
{
public:
std::vector<std::vector<Cell>> techs;
int h, w;
Die_infro die_infro[2];
int th, tw, tspaceing, tcost; //terminal information
int tech_num, cell_num, net_num;
std::vector<int> cells;
std::vector<int> layer;
std::vector<int> cell_die;
std::vector<int> mass;
std::vector<Inst> insts;
std::vector<std::vector<std::pair<int, int>>> nets;
std::vector<std::vector<std::pair<int, int>>> node_net;
std::vector<std::pair<float, float>> cell_pos;
std::vector<std::pair<float, float>> force, velocity;
std::vector<std::pair<float, float>> net_center;
public:
void readcase(std::string);
void writecase();
};
#endif
\ No newline at end of file
#ifndef PPP_FFTBIN_H
#define PPP_FFTBIN_h
#include "param.h"
#include "FFT_calculator.h"
class fftBin : public FFT_calculator {
public:
//bin parts
float size_x, size_y;
float area;
float binsize_x, binsize_y;
//std::vector<std::vector<float>> llx, lly, urx, ury;
std::vector<float> coordx, coordy;
std::vector<float*> electricDensity;
std::vector<float*> electricPotential;
std::vector<float*> electricField_x;
std::vector<float*> electricField_y;
std::vector<std::vector<float>> stdArea, fillerArea;
std::vector<std::vector<std::vector<int>>> correspondCells;
//fft parts
std::vector<float> wx, wy;
std::vector<float> wx_sq, wy_sq;
std::vector<float> cosTable;
std::vector<int> workArea;
public:
void binPlace(float llx, float lly);
float llx(float x, float y) {return coordx[x];}
float lly(float x, float y) {return coordy[y];}
float urx(float x, float y) {return coordx[x+1];}
float ury(float x, float y) {return coordy[x+1];}
void doFFT();
float getOverlap(int, int, float, float, float, float) const;
public:
~fftBin();
};
#endif
#ifndef EPLACEPRACTICE_SRC_ALGORITHMS_FFT_calculator_H_
#define EPLACEPRACTICE_SRC_ALGORITHMS_FFT_calculator_H_
class FFT_calculator {
protected:
// The following FFT library came from
// http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html
// 1D fftsg
void cdft(int n, int isgn, float *a, int *ip, float *w);
void rdft(int n, int isgn, float *a, int *ip, float *w);
void ddct(int n, int isgn, float *a, int *ip, float *w);
void ddst(int n, int isgn, float *a, int *ip, float *w);
void dfct(int n, float *a, float *t, int *ip, float *w);
void dfst(int n, float *a, float *t, int *ip, float *w);
void makewt(int nw, int *ip, float *w);
void makeipt(int nw, int *ip);
void makect(int nc, int *ip, float *c);
void cftfsub(int n, float *a, int *ip, int nw, float *w);
void cftbsub(int n, float *a, int *ip, int nw, float *w);
void bitrv2(int n, int *ip, float *a);
void bitrv2conj(int n, int *ip, float *a);
void bitrv216(float *a);
void bitrv216neg(float *a);
void bitrv208(float *a);
void bitrv208neg(float *a);
void cftf1st(int n, float *a, float *w);
void cftb1st(int n, float *a, float *w);
void cftrec4(int n, float *a, int nw, float *w);
int cfttree(int n, int j, int k, float *a, int nw, float *w);
void cftleaf(int n, int isplt, float *a, int nw, float *w);
void cftmdl1(int n, float *a, float *w);
void cftmdl2(int n, float *a, float *w);
void cftfx41(int n, float *a, int nw, float *w);
void cftf161(float *a, float *w);
void cftf162(float *a, float *w);
void cftf081(float *a, float *w);
void cftf082(float *a, float *w);
void cftf040(float *a);
void cftb040(float *a);
void cftx020(float *a);
void rftfsub(int n, float *a, int nc, float *c);
void rftbsub(int n, float *a, int nc, float *c);
void dctsub(int n, float *a, int nc, float *c);
void dstsub(int n, float *a, int nc, float *c);
// 2D fftsg
void cdft2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void rdft2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void rdft2dsort(int n1, int n2, int isgn, float **a);
void ddcst2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void ddsct2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void ddct2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void ddst2d(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void cdft2d_sub(int n1, int n2, int isgn, float **a, float *t, int *ip, float *w);
void rdft2d_sub(int n1, int isgn, float **a);
void ddxt2d_sub(int n1, int n2, int ics, int isgn, float **a, float *t, int *ip, float *w);
};
#endif //EPLACEPRACTICE_SRC_ALGORITHMS_FFT_calculator_H_
#ifndef PPP_PARAM_H
#define PPP_PARAM_H
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <unordered_map>
#include <vector>
#include <random>
#include <algorithm>
#include <math.h>
#define _USE_MATH_DEFINES
#include <cassert>
#define VISUAL 1
#if VISUAL
#include <CImg.h>
#endif
namespace Color {
const unsigned char BLACK[] = {0, 0, 0};
const unsigned char DIM_GRAY[] = {105, 105, 105};
const unsigned char WHITE[] = {255, 255, 255};
const unsigned char BLUE[] = {3, 252, 219};
const unsigned char RED[] = {255, 0, 0};
const unsigned char PINK[] = {255, 51, 255};
const unsigned char LIGHT_YELLOW[] = {255, 236, 196};
const unsigned char LIGHT_GREEN[] = {73, 235, 52};
}
const static float densityScale = 1e-1; //1e-4; // variable for preventing the overflow of binDensity
const static float time_step = 0.02;
const static float wireLengthCoefficient = 10; //1e-1;
const static float frictionCoefficient = 50;
#endif
\ No newline at end of file
#include "Circuit.h"
int main() {
std::ios::sync_with_stdio(false);
Circuit* circuit = new Circuit();
circuit->readcase("../data/toy.txt");
std::string picname;
circuit->init();
picname = "initial.bmp";
circuit->draw(picname);
std::cout << "HPWL bmp:" << circuit->calHPWL() << std::endl;
std::cout << circuit->tech_num << " " << circuit->cell_num << " " << circuit->net_num << std::endl;
std::cout << "Electric potential apply." << std::endl;
for (int i = 0; i < 30; ++i) {
circuit->Iteration(i);
std::cout << "HPWL:" << circuit->calHPWL() << std::endl;
if (i % 1 == 0) {
picname = "iter" + std::to_string(i) + ".bmp";
circuit->draw(picname);
}
}
picname = "after.bmp";
circuit->draw(picname);
std::cout << "Progress End." << std::endl;
delete circuit;
return 0;
}
language: cpp
compiler:
- gcc
script:
- cd examples
- make CXX='g++-4.8' travis
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- clang
- libpng12-dev
- libjpeg-dev
- libmagick++-dev
- libgraphicsmagick++1-dev
- libfftw3-dev
- zlib1g-dev
This source diff could not be displayed because it is too large. You can view the blob instead.
<a href="http://cimg.eu">![Logo](http://cimg.eu/img/logo_header.jpg)</a>
##### http://cimg.eu
------------------
The **CImg Library** is a **small** and **open-source** **C++ library** for **image processing**, designed with these properties in mind:
![Usefulness](http://cimg.eu/img/item_usefulness.jpg) **CImg** defines *classes* and *methods* to manage images in your own C++ code. You can use **CImg** to load/save various file formats, access pixel values, display/transform/filter images, draw primitives (text, faces, curves, 3d objects, ...), compute statistics, manage user interactions on images, and so on...
![Genericity](http://cimg.eu/img/item_genericity.jpg) **CImg** defines a single image class able to represent datasets having up to *4-dimensions* (from 1d scalar signals to 3d hyperspectral volumetric images), with *template pixel types* (`bool,char,int,float,...`). It also handles image *collections* and *sequences*.
![Portability](http://cimg.eu/img/item_portability.jpg) **CImg** is *self-contained*, *thread-safe* and *highly portable*. It fully works on *different operating systems* (`Unix,Windows,MacOS X,*BSD,...`) and is compatible with *various C++ compilers* (`Visual C++,g++,clang++,icc,...`).
![Simplicity](http://cimg.eu/img/item_simplicity.jpg) **CImg** is *lightweight*. It is made of a single header file [`CImg.h`](https://github.com/dtschump/CImg/raw/master/CImg.h) that must be included in your C++ source. It defines only *four* different classes, encapsulated in the namespace `cimg_library`. It can be compiled using a minimal set of standard C++ and system libraries only. *No need for exotic or complex dependencies*.
![Extensibility](http://cimg.eu/img/item_extensibility.jpg) Although not mandatory, **CImg** can use functionalities of external tools/libraries such as [Board](http://libboard.sourceforge.net/), [FFMPEG](http://ffmpeg.mplayerhq.hu/), [FFTW3](http://www.fftw.org/), [GraphicsMagick](http://www.graphicsmagick.org/), [ImageMagick](http://www.imagemagick.org/), [Lapack](http://www.netlib.org/lapack/), [libcurl](http://curl.haxx.se/libcurl/), [libjpeg](http://www.ijg.org/), [libpng](http://www.libpng.org/pub/png/libpng.html), [libtiff](http://www.libtiff.org/), [Magick++](http://www.imagemagick.org/Magick++/), [OpenEXR](http://www.openexr.com/), [OpenCV](http://http://opencv.willowgarage.com/wiki/), [OpenMP](http://www.openmp.org/) or [XMedCon](http://xmedcon.sourceforge.net/). Moreover, a simple *plug-in* mechanism allows any user to directly enhance the library capabilities according to their needs.
![Freedom](http://cimg.eu/img/item_freedom.jpg) **CImg** is a *free, open-source library* distributed under the [*CeCILL-C*](http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.txt) (close to the GNU LGPL) or [CeCILL](http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt) (compatible with the GNU GPL) licenses. It can be used in commercial applications.
------------------
> **CImg** stands for **Cool Image** : It is _easy to use_, _efficient_ and is intended to be a very pleasant toolbox to design image processing algorithms in C++. Due to its generic conception, it can cover a wide range of image processing applications.
------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
____ _ _ ____
(_ _)( )_( )( ___)
)( ) _ ( )__)
(__) (_) (_)(____)
___ ____ __ __ ___ __ ____ ____ ____ __ ____ _ _
/ __)(_ _)( \/ )/ __) ( ) (_ _)( _ \( _ \ /__\ ( _ \( \/ )
( (__ _)(_ ) (( (_-. )(__ _)(_ ) _ < ) / /(__)\ ) / \ /
\___)(____)(_/\/\_)\___/ (____)(____)(____/(_)\_)(__)(__)(_)\_) (__)
C++ Template Image Processing Toolkit
( http://cimg.eu )
_cimg_version
--------------------------------------------------------------------------------
# Summary
#---------
The CImg Library is a small and open-source C++ toolkit for image processing.
It consists in a single header file 'CImg.h' providing a minimal set of C++
classes and methods that can be used in your own sources, to load/save,
process and display images. Very portable (Unix/X11,Windows, MacOS X, FreeBSD, .. ),
efficient, easy to use, it's a pleasant library for developing image processing
algorithms in C++.
# Authors and contributors :
#----------------------------
- David Tschumperlé (project leader) ( http://tschumperle.users.greyc.fr/ )
- Maksim Aizenshtein
- Alberto Albiol
- Antonio Albiol
- Simon Barthelme
- Neil Brown
- Haz-Edine Assemlal
- Vincent Barra
- Wolf Blecher
- Romain Blei
- Yohan Bentolila
- Jerome Boulanger
- Pierre Buyssens
- Sebastien Coudert
- Frederic Devernay
- Olivier D'Hondt
- Francois-Xavier Dupe
- Gerd von Egidy
- Eric Fausett
- Jean-Marie Favreau
- Sebastien Fourey
- Alexandre Fournier
- Hon-Kwok Fung
- Vincent Garcia
- David Grimbichler
- Jinwei Gu
- Jean-Daniel Guyot
- Cedric Hammiche
- Matt Hanson
- Sebastien Hanel
- Michael Holroyd
- Christoph Hormann
- Werner Jainek
- Daniel Kondermann
- Pierre Kornprobst
- Jan W. Krieger
- Orges Leka
- Francois Lauze
- Xie Long
- Thomas Martin
- Cesar Martinez
- Jean Martinot
- Arnold Meijster (Center for High Performance Computing and Visualization, University of Groningen/The Netherlands)
- Nikita Melnichenko
- Julien Morat
- Baptiste Mougel
- Jovana Milutinovich
- Guillaume Nee
- Adam Newgas
- Francisco Oliveira
- Andrea Onofri
- Renaud Peteri
- Martin Petricek
- Paolo Prete
- Adrien Reboisson
- Klaus Schneider
- Jakob Schluttig
- Jamie Smith
- Veronique Souchaud
- Konstantin Spirin
- David G. Starkweather
- Rainer Steffens
- Grzegorz Szwoch
- Thierry Thomas
- Yu-En-Yun
- Vo Duc Khanh
- Phillip Wood
- Bug Zhao
- Haibo Zheng
# Institution
#-------------
GREYC Image / CNRS UMR 6072 / FRANCE
The CImg Library project started in 2000, at the INRIA-Sophia
Antipolis/France ( http://www-sop.inria.fr/ ), in the ROBOTVIS / ODYSSEE Team.
Since October 2004, it is maintained and developed in the Image team of
the GREYC Lab (CNRS, UMR 6072), in Caen/France.
Team web page : http://www.greyc.fr/image
# Licenses
#----------
The source code of the CImg Library is distributed under
two distinct licenses :
- The main library file 'CImg.h' is *dual-licensed* :
It can be either distributed under the CeCILL-C or CeCILL license.
(see files 'Licence_CeCILL-C_V1-en.txt' and 'Licence_CeCILL_V2-en.txt').
Both are Free-Software licenses :
* CeCILL-C is adapted to the distribution of
library components, and is close in its terms to the well known GNU LGPL license
(the 'CImg.h' file can thus be used in closed-source products under certain
conditions, please read carefully the license file).
* CeCILL is close to (and even compatible with) the GNU GPL license.
- Most of the other files are distributed under the CeCiLL license
(file 'Licence_CeCILL_V2-en.txt'). See each file header to see what license applies.
These two CeCiLL licenses ( http://www.cecill.info/index.en.html ) have been
created under the supervision of the three biggest research institutions on
computer sciences in France :
- CNRS ( http://www.cnrs.fr/ )
- CEA ( http://www.cea.fr/ )
- INRIA ( http://www.inria.fr/ )
You have to RESPECT these licenses. More particularly, please carefully read
the license terms before using the CImg library in commercial products.
# Package structure :
#--------------------
The main package directory CImg/ is organized as follows :
- README.txt : This file.
- Licence_CeCILL-C_V1-en.txt : A copy of the CeCiLL-C license file.
- Licence_CeCILL_V2-en.txt : A copy of the CeCiLL license.
- CImg.h : The single header file that constitutes the library itself.
- examples/ : A directory containing a lot of example programs performing
various things, using the CImg library.
- html/ : A directory containing a copy of the CImg web page in html
format. The reference documentation is generated
automatically with the tool 'doxygen' (http://www.doxygen.org).
- resources/ : A directory containing some resources files for compiling
CImg examples or packages with various C++ compilers and OS.
- plugins/ : A directory containing CImg plug-ins files that can be used to
add specific extra functionalities to the CImg library.
# Getting started
#-----------------
If you are new to CImg, you should first try to compile the different examples
provided in the 'examples/' directory, to see what CImg is capable of
(as CImg is a template-based library, no prior compilation of the library is mandatory).
Look at the 'resources/' directory to ease this compilation on different platforms.
Then, you can look at the documentation 'html/reference/' to learn more about CImg
functions and classes. Finally, you can participate to the 'Forum' section
of the CImg web page and ask for help if needed.
# End of file
#------------
/*
#
# File : captcha.cpp
# ( C++ source file )
#
# Description : Captcha images generator.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#ifndef cimg_debug
#define cimg_debug 1
#endif
#include "CImg.h"
using namespace cimg_library;
#undef min
#undef max
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line parameters
//------------------------------
cimg_usage("Simple captcha generator.");
const char *file_o = cimg_option("-o",(const char*)0,"Output image file");
const bool add_border = cimg_option("-b",true,"Add border to captcha image");
const bool visu = cimg_option("-visu",true,"Enable visualization if no output file");
// Generate captcha text (6 char max).
//------------------------------------
const char *predef_words[] = {
"aarrgh", "abacas", "abacus", "abakas", "abamps", "abased", "abaser", "abases", "abasia", "abated", "abater",
"abates", "abatis", "abator", "baobab", "barbal", "barbed", "barbel", "barber", "barbes", "barbet", "barbie",
"barbut", "barcas", "barded", "bardes", "bardic", "barege", "cavies", "cavils", "caving", "cavity", "cavort",
"cawing", "cayman", "cayuse", "ceased", "ceases", "cebids", "ceboid", "cecity", "cedarn", "dicast", "dicers",
"dicier", "dicing", "dicker", "dickey", "dickie", "dicots", "dictum", "didact", "diddle", "diddly", "didies",
"didoes", "emails", "embalm", "embank", "embark", "embars", "embays", "embeds", "embers", "emblem", "embody",
"emboli", "emboly", "embosk", "emboss", "fluffy", "fluids", "fluish", "fluked", "flukes", "flukey", "flumed",
"flumes", "flumps", "flunks", "flunky", "fluors", "flurry", "fluted", "genome", "genoms", "genres", "genros",
"gentes", "gentil", "gentle", "gently", "gentry", "geodes", "geodic", "geoids", "gerahs", "gerbil", "hotter",
"hottie", "houdah", "hounds", "houris", "hourly", "housed", "housel", "houser", "houses", "hovels", "hovers",
"howdah", "howdie", "inland", "inlays", "inlets", "inlier", "inmate", "inmesh", "inmost", "innage", "innate",
"inners", "inning", "inpour", "inputs", "inroad", "joypop", "jubbah", "jubhah", "jubile", "judder", "judged",
"judger", "judges", "judoka", "jugate", "jugful", "jugged", "juggle", "jugula", "knifer", "knifes", "knight",
"knives", "knobby", "knocks", "knolls", "knolly", "knosps", "knotty", "knouts", "knower", "knowns", "knubby",
"legate", "legato", "legend", "legers", "legged", "leggin", "legion", "legist", "legits", "legman", "legmen",
"legong", "legume", "lehuas", "mammal", "mammas", "mammee", "mammer", "mammet", "mammey", "mammie", "mammon",
"mamzer", "manage", "manana", "manats", "manche", "manege", "nihils", "nilgai", "nilgau", "nilled", "nimble",
"nimbly", "nimbus", "nimmed", "nimrod", "ninety", "ninjas", "ninons", "ninths", "niobic", "offish", "offkey",
"offset", "oftest", "ogdoad", "oghams", "ogival", "ogives", "oglers", "ogling", "ogress", "ogrish", "ogrism",
"ohmage", "papaws", "papaya", "papers", "papery", "pappus", "papula", "papule", "papyri", "parade", "paramo",
"parang", "paraph", "parcel", "pardah", "quasar", "quatre", "quaver", "qubits", "qubyte", "queans", "queasy",
"queazy", "queens", "queers", "quelea", "quells", "quench", "querns", "raised", "raiser", "raises", "raisin",
"raitas", "rajahs", "rakees", "rakers", "raking", "rakish", "rallye", "ralphs", "ramada", "ramate", "savory",
"savour", "savoys", "sawers", "sawfly", "sawing", "sawlog", "sawney", "sawyer", "saxony", "sayeds", "sayers",
"sayest", "sayids", "tondos", "toneme", "toners", "tongas", "tonged", "tonger", "tongue", "tonics", "tonier",
"toning", "tonish", "tonlet", "tonner", "tonnes", "uredia", "uredos", "ureide", "uremia", "uremic", "ureter",
"uretic", "urgent", "urgers", "urging", "urials", "urinal", "urines", "uropod", "villus", "vimina", "vinals",
"vincas", "vineal", "vinery", "vinier", "vinify", "vining", "vinous", "vinyls", "violas", "violet", "violin",
"webfed", "weblog", "wechts", "wedded", "wedder", "wedeln", "wedels", "wedged", "wedges", "wedgie", "weeded",
"weeder", "weekly", "weened", "xystoi", "xystos", "xystus", "yabber", "yabbie", "yachts", "yacked", "yaffed",
"yagers", "yahoos", "yairds", "yakked", "yakker", "yakuza", "zigged", "zigzag", "zillah", "zinced", "zincic",
"zincky", "zinebs", "zinged", "zinger", "zinnia", "zipped", "zipper", "zirams", "zircon" };
cimg::srand();
const char *const captcha_text = predef_words[std::rand()%(sizeof(predef_words)/sizeof(char*))];
// Create captcha image
//----------------------
// Write colored and distorted text
CImg<unsigned char> captcha(256,64,1,3,0), color(3);
char letter[2] = { 0 };
for (unsigned int k = 0; k<6; ++k) {
CImg<unsigned char> tmp;
*letter = captcha_text[k];
if (*letter) {
cimg_forX(color,i) color[i] = (unsigned char)(128 + (std::rand()%127));
tmp.draw_text((int)(2 + 8*cimg::rand()),
(int)(12*cimg::rand()),
letter,color.data(),0,1,std::rand()%2?38:57).resize(-100,-100,1,3);
const unsigned int dir = std::rand()%4, wph = tmp.width() + tmp.height();
cimg_forXYC(tmp,x,y,v) {
const int val = dir==0?x + y:(dir==1?x + tmp.height() - y:(dir==2?y + tmp.width() - x:
tmp.width() - x + tmp.height() - y));
tmp(x,y,v) = (unsigned char)std::max(0.0f,std::min(255.0f,1.5f*tmp(x,y,v)*val/wph));
}
if (std::rand()%2) tmp = (tmp.get_dilate(3)-=tmp);
tmp.blur((float)cimg::rand()*0.8f).normalize(0,255);
const float sin_offset = (float)cimg::rand(-1,1)*3, sin_freq = (float)cimg::rand(-1,1)/7;
cimg_forYC(captcha,y,v) captcha.get_shared_row(y,0,v).shift((int)(4*std::cos(y*sin_freq + sin_offset)));
captcha.draw_image(6 + 40*k,tmp);
}
}
// Add geometric and random noise
CImg<unsigned char> copy = (+captcha).fill(0);
for (unsigned int l = 0; l<3; ++l) {
if (l) copy.blur(0.5f).normalize(0,148);
for (unsigned int k = 0; k<10; ++k) {
cimg_forX(color,i) color[i] = (unsigned char)(128 + cimg::rand()*127);
if (cimg::rand()<0.5f) copy.draw_circle((int)(cimg::rand()*captcha.width()),
(int)(cimg::rand()*captcha.height()),
(int)(cimg::rand()*30),
color.data(),0.6f,~0U);
else copy.draw_line((int)(cimg::rand()*captcha.width()),
(int)(cimg::rand()*captcha.height()),
(int)(cimg::rand()*captcha.width()),
(int)(cimg::rand()*captcha.height()),
color.data(),0.6f);
}
}
captcha|=copy;
captcha.noise(10,2);
if (add_border)
captcha.draw_rectangle(0,0,captcha.width() - 1,captcha.height() - 1,
CImg<unsigned char>::vector(255,255,255).data(),1.0f,~0U);
captcha = (+captcha).fill(255) - captcha;
// Write output image and captcha text
//-------------------------------------
std::printf("%s\n",captcha_text);
if (file_o) captcha.save(file_o);
else if (visu) {
CImgDisplay disp(CImg<unsigned char>(512,128,1,3,180).draw_image(128,32,captcha),captcha_text,0);
while (!disp.is_closed() && !disp.key()) { disp.wait(); if (disp.is_resized()) disp.resize(disp).wait(100); }
}
return 0;
}
/*
#
# File : fade_images.cpp
# ( C++ source file )
#
# Description : Compute a linear fading between two images.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
#undef min
#undef max
// Main procedure
//---------------
int main(int argc,char **argv) {
// Read and check command line parameters.
cimg_usage("Compute a linear fading between two 2D images");
const char *file_i1 = cimg_option("-i1",cimg_imagepath "sh0r.pgm","Input Image 1");
const char *file_i2 = cimg_option("-i2",cimg_imagepath "milla.bmp","Input Image 2");
const char *file_o = cimg_option("-o",(char*)0,"Output Image");
const bool visu = cimg_option("-visu",true,"Visualization mode");
const double pmin = cimg_option("-min",40.0,"Begin of the fade (in %)")/100.0;
const double pmax = cimg_option("-max",60.0,"End of the fade (in %)")/100.0;
const double angle = cimg_option("-angle",0.0,"Fade angle")*cil::cimg::PI/180;
// Init images.
cil::CImg<unsigned char> img1(file_i1), img2(file_i2);
if (!img2.is_sameXYZC(img1)) {
int
dx = std::max(img1.width(),img2.width()),
dy = std::max(img1.height(),img2.height()),
dz = std::max(img1.depth(),img2.depth()),
dv = std::max(img1.spectrum(),img2.spectrum());
img1.resize(dx,dy,dz,dv,3);
img2.resize(dx,dy,dz,dv,3);
}
cil::CImg<unsigned char> dest(img1);
// Compute the faded image.
const double ca = std::cos(angle), sa = std::sin(angle);
double alpha;
cimg_forXYZC(dest,x,y,z,k) {
const double X = ((double)x/img1.width() - 0.5)*ca + ((double)y/img1.height() - 0.5)*sa;
if (X + 0.5<pmin) alpha = 0; else {
if (X + 0.5>pmax) alpha = 1; else
alpha = (X + 0.5 - pmin)/(pmax - pmin);
}
dest(x,y,z,k) = (unsigned char)((1 - alpha)*img1(x,y,z,k) + alpha*img2(x,y,z,k));
}
// Save and exit
if (file_o) dest.save(file_o);
if (visu) dest.display("Image fading");
return 0;
}
/*
#
# File : gaussian_fit1d.cpp
# ( C++ source file )
#
# Description : Fit a gaussian function on a set of sample points,
# using the Levenberg-Marquardt algorithm.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#ifndef cimg_plugin
#define cimg_plugin "examples/gaussian_fit1d.cpp"
#include "CImg.h"
using namespace cimg_library;
#undef min
#undef max
// Main procedure
//----------------
int main(int argc,char **argv) {
cimg_usage("Fit gaussian function on sample points, using Levenberg-Marquardt algorithm.");
// Read command line arguments.
const char *s_params = cimg_option("-p","10,3,4","Amplitude, Mean and Std of the ground truth");
const unsigned int s_nb = cimg_option("-N",40,"Number of sample points");
const float s_noise = cimg_option("-n",10.0f,"Pourcentage of noise on the samples points");
const char *s_xrange = cimg_option("-x","-10,10","X-range allowed for the sample points");
const char *f_params = cimg_option("-p0",(char*)0,"Amplitude, Mean and Std of the first estimate");
const float f_lambda0 = cimg_option("-l",100.0f,"Initial damping factor");
const float f_dlambda = cimg_option("-dl",0.9f,"Damping attenuation");
float s_xmin = -10, s_xmax = 10, s_amp = 1, s_mean = 1, s_std = 1;
std::sscanf(s_xrange,"%f%*c%f",&s_xmin,&s_xmax);
std::sscanf(s_params,"%f%*c%f%*c%f",&s_amp,&s_mean,&s_std);
// Create noisy samples of a Gaussian function.
const float s_std2 = 2*s_std*s_std, s_fact = s_amp/((float)std::sqrt(2*cimg::PI)*s_std);
CImg<> samples(s_nb,2);
cimg_forX(samples,i) {
const float
x = (float)(s_xmin + (s_xmax - s_xmin)*cimg::rand()),
y = s_fact*(float)(1 + s_noise*cimg::grand()/100)*std::exp(-cimg::sqr(x - s_mean)/s_std2);
samples(i,0) = x;
samples(i,1) = y;
}
// Fit Gaussian function on the sample points and display curve iterations.
CImgDisplay disp(640,480,"Levenberg-Marquardt Gaussian Fitting",0);
float f_amp = 1, f_mean = 1, f_std = 1, f_lambda = f_lambda0;
if (f_params) std::sscanf(f_params,"%f%*c%f%*c%f",&f_amp,&f_mean,&f_std);
else {
const float& vmax = samples.get_shared_row(1).max();
float cmax = 0; samples.contains(vmax,cmax);
f_mean = samples((int)cmax,0);
f_std = (s_xmax - s_xmin)/10;
f_amp = vmax*(float)std::sqrt(2*cimg::PI)*f_std;
}
CImg<> beta = CImg<>::vector(f_amp,f_mean,f_std);
for (unsigned int iter = 0; !disp.is_closed() && !disp.is_keyQ() && !disp.is_keyESC(); ++iter) {
// Do one iteration of the Levenberg-Marquardt algorithm.
CImg<> YmF(1,s_nb), J(beta.height(),s_nb);
const float
_f_amp = beta(0), _f_mean = beta(1), _f_std = beta(2),
_f_std2 = 2*_f_std*_f_std, _f_fact = (float)std::sqrt(2*cimg::PI)*_f_std;
float _f_error = 0;
cimg_forY(J,i) {
const float
x = samples(i,0),
_f_exp = std::exp(-cimg::sqr(x - _f_mean)/_f_std2),
delta = samples(i,1) - _f_amp*_f_exp/_f_fact;
YmF(i) = delta;
J(0,i) = _f_exp/_f_fact;
J(1,i) = _f_amp*_f_exp/_f_fact*(x - _f_mean)*2/_f_std2;
J(2,i) = _f_amp*_f_exp/_f_fact*(cimg::sqr(x - _f_mean)/(_f_std*_f_std*_f_std));
_f_error+=cimg::sqr(delta);
}
CImg<> Jt = J.get_transpose(), M = Jt*J;
cimg_forX(M,x) M(x,x)*=1 + f_lambda;
beta+=M.get_invert()*Jt*YmF;
if (beta(0)<=0) beta(0) = 0.1f;
if (beta(2)<=0) beta(2) = 0.1f;
f_lambda*=f_dlambda;
// Display fitting curves.
const unsigned char black[] = { 0,0,0 }, gray[] = { 228,228,228 };
CImg<unsigned char>(disp.width(),disp.height(),1,3,255).
draw_gaussfit(samples,beta(0),beta(1),beta(2),s_amp,s_mean,s_std).
draw_rectangle(5,7,150,100,gray,0.9f).draw_rectangle(5,7,150,100,black,1,~0U).
draw_text(10,10,"Iteration : %d",black,0,1,13,iter).
draw_text(10,25,"Amplitude : %.4g (%.4g)",black,0,1,13,beta(0),s_amp).
draw_text(10,40,"Mean : %.4g (%.4g)",black,0,1,13,beta(1),s_mean).
draw_text(10,55,"Std : %.4g (%.4g)",black,0,1,13,beta(2),s_std).
draw_text(10,70,"Error : %.4g",black,0,1,13,std::sqrt(_f_error)).
draw_text(10,85,"Lambda : %.4g",black,0,1,13,f_lambda).
display(disp.resize(false).wait(20));
}
return 0;
}
#else
// Draw sample points, ideal and fitted gaussian curves on the instance image.
// (defined as a CImg plug-in function).
template<typename t>
CImg<T>& draw_gaussfit(const CImg<t>& samples,
const float f_amp, const float f_mean, const float f_std,
const float i_amp, const float i_mean, const float i_std) {
if (is_empty()) return *this;
const unsigned char black[] = { 0,0,0 }, green[] = { 10,155,20 }, orange[] = { 155,20,0 }, purple[] = { 200,10,200 };
float
xmin, xmax = samples.get_shared_row(0).max_min(xmin), deltax = xmax - xmin,
ymin, ymax = samples.get_shared_row(1).max_min(ymin), deltay = ymax - ymin;
xmin-=0.2f*deltax; xmax+=0.2f*deltax; ymin-=0.2f*deltay; ymax+=0.2f*deltay;
deltax = xmax - xmin; deltay = ymax - ymin;
draw_grid(64,64,0,0,false,false,black,0.3f,0x55555555,0x55555555).draw_axes(xmin,xmax,ymax,ymin,black,0.8f);
CImg<> nsamples(samples);
(nsamples.get_shared_row(0)-=xmin)*=width()/deltax;
(nsamples.get_shared_row(1)-=ymax)*=-height()/deltay;
cimg_forX(nsamples,i) draw_circle((int)nsamples(i,0),(int)nsamples(i,1),3,orange,1,~0U);
CImg<int> truth(width(),2), fit(width(),2);
const float
i_std2 = 2*i_std*i_std, i_fact = i_amp/((float)std::sqrt(2*cimg::PI)*i_std),
f_std2 = 2*f_std*f_std, f_fact = f_amp/((float)std::sqrt(2*cimg::PI)*f_std);
cimg_forX(*this,x) {
const float
x0 = xmin + x*deltax/width(),
ys0 = i_fact*std::exp(-cimg::sqr(x0 - i_mean)/i_std2),
yf0 = f_fact*std::exp(-cimg::sqr(x0 - f_mean)/f_std2);
fit(x,0) = truth(x,0) = x;
truth(x,1) = (int)((ymax - ys0)*height()/deltay);
fit(x,1) = (int)((ymax - yf0)*height()/deltay);
}
return draw_line(truth,green,0.7f,0xCCCCCCCC).draw_line(fit,purple);
}
#endif
/*
#
# File : hough_transform2d.cpp
# ( C++ source file )
#
# Description : Implementation of the Hough transform.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
// Main procedure
//----------------
int main(int argc,char **argv) {
cimg_usage("Illustration of the Hough transform");
CImg<unsigned char> src(cimg_option("-i",cimg_imagepath "parrot.ppm","Input image"));
CImg<> vote(500,400,1,1,0), img = src.get_norm().normalize(0,255).resize(-100,-100,1,2,2);
CImgDisplay disp(src,"Image"), dispvote(vote,"Hough Transform");
const unsigned char col1[3]={255,255,255}, col2[3]={0,0,0};
const double
alpha = cimg_option("-a",1.5,"Gradient smoothing"),
sigma = cimg_option("-s",0.5,"Hough Transform smoothing"),
rhomax = std::sqrt((double)(img.width()*img.width() + img.height()*img.height()))/2,
thetamax = 2*cimg::PI;
if (cimg::dialog(cimg::basename(argv[0]),
"Instructions : \n"
"----------------\n\n"
"(1) When clicking on the color image, all lines crossing the selected point\n"
"will be voted in the Hough buffer.\n\n"
"(2) When clicking on the Hough buffer, the corresponding line is drawn\n"
"on the color image.\n\n"
"(3) When pressing the space bar, lines in the color image are detected from the\n"
"image gradients through votes in the Hough buffer.\n\n"
"Note that a logarithmic scaling is performed for displayin the vote image.\n"
"See also the available options (option '-h')\n","Start !","Quit",0,0,0,0,
src.get_resize(100,100,1,3),true)) std::exit(0);
while (!disp.is_closed() && !dispvote.is_closed() &&
!disp.is_keyQ() && !dispvote.is_keyQ() && !disp.is_keyESC() && !dispvote.is_keyESC()) {
CImgDisplay::wait(disp,dispvote);
// When pressing space bar, the vote is performed from the image gradients.
if (dispvote.is_keySPACE() || disp.is_keySPACE()) {
CImgList<> grad = img.get_gradient();
cimglist_for(grad,l) grad[l].blur((float)alpha);
vote.fill(0);
cimg_forXY(img,x,y) {
const double
X = (double)x - img.width()/2,
Y = (double)y - img.height()/2,
gx = grad[0](x,y),
gy = grad[1](x,y);
double
theta = std::atan2(gy,gx),
rho = std::sqrt(X*X + Y*Y)*std::cos(std::atan2(Y,X) - theta);
if (rho<0) { rho=-rho; theta+=cimg::PI; }
theta = cimg::mod(theta,thetamax);
vote((int)(theta*dispvote.width()/thetamax),(int)(rho*dispvote.height()/rhomax))+=
(float)std::sqrt(gx*gx + gy*gy);
}
vote.blur((float)sigma);
CImg<> vote2(vote); cimg_forXY(vote2,x,y) vote2(x,y) = (float)std::log(1 + vote(x,y)); vote2.display(dispvote);
}
// When clicking on the vote window.
if (dispvote.button()) {
const double
rho = dispvote.mouse_y()*rhomax/dispvote.height(),
theta = dispvote.mouse_x()*thetamax/dispvote.width(),
x = img.width()/2 + rho*std::cos(theta),
y = img.height()/2 + rho*std::sin(theta);
const int
x0 = (int)(x + 1000*std::sin(theta)),
y0 = (int)(y - 1000*std::cos(theta)),
x1 = (int)(x - 1000*std::sin(theta)),
y1 = (int)(y + 1000*std::cos(theta));
CImg<unsigned char>(src).
draw_line(x0,y0,x1,y1,col1,1.0f,0xF0F0F0F0).draw_line(x0,y0,x1,y1,col2,1.0f,0x0F0F0F0F).
draw_line(x0 + 1,y0,x1 + 1,y1,col1,1.0f,0xF0F0F0F0).draw_line(x0 + 1,y0,x1 + 1,y1,col2,1.0f,0x0F0F0F0F).
draw_line(x0,y0 + 1,x1,y1 + 1,col1,1.0f,0xF0F0F0F0).draw_line(x0,y0 + 1,x1,y1 + 1,col2,1.0f,0x0F0F0F0F).
display(disp);
}
// When clicking on the image.
if (disp.button() && disp.mouse_x()>=0) {
const double
x0 = (double)disp.mouse_x() - disp.width()/2,
y0 = (double)disp.mouse_y() - disp.height()/2,
rho0 = std::sqrt(x0*x0 + y0*y0),
theta0 = std::atan2(y0,x0);
for (double t=0; t<thetamax; t+=0.001) {
double theta = t, rho = rho0*std::cos(theta0 - t);
if (rho<0) { rho=-rho; theta=cimg::mod(theta + cimg::PI,thetamax); }
vote((int)(theta*vote.width()/thetamax),(int)(rho*vote.height()/rhomax))+=1;
}
CImg<> vote2(vote); cimg_forXY(vote2,x,y) vote2(x,y) = (float)std::log(1 + vote(x,y)); vote2.display(dispvote);
}
dispvote.resize(dispvote);
disp.resize(disp);
}
std::exit(0);
return 0;
}
/*
#
# File : image2ascii.cpp
# ( C++ source file )
#
# Description : A basic image to ASCII-art converter.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
// Tell CImg not to use display capabilities.
#undef cimg_display
#define cimg_display 0
#include "CImg.h"
using namespace cimg_library;
/*---------------------------
Main procedure
--------------------------*/
int main(int argc,char **argv) {
cimg_usage("A simple image to ASCII-art converter.\n\nUsage : image2ascii [options] image");
// Read command line parameters
const char *const file_i = cimg_option("-i",(char*)0,"Input image");
const char *const geom = cimg_option("-g","79x40","Output size");
const int alphabet = cimg_option("-a",0,"Alphabet type (0=full, 1=numbers, 2=letters, 3=signs, 4=minimal");
const bool invert = cimg_option("-invert",false,"Invert image intensities");
const float contour = (float)cimg_option("-contour",0.0f,"Use image contours higher than specified threshold");
const float blur = (float)cimg_option("-blur",0.8f,"Image pre-blur");
const float sigma = (float)cimg_option("-sigma",10.0f,"Font pre-blur");
int w = 79, h = 40;
std::sscanf(geom,"%d%*c%d",&w,&h);
if (cimg_option("-h",false,0)) std::exit(0);
// Init fonts
CImgList<> font_full = CImgList<>::font(13,false);
font_full.remove(0,255);
const int fw = font_full[(int)'A'].width(), fh = font_full[(int)'A'].height();
CImgList<> font, font_blur;
CImgList<unsigned char> font_code;
switch (alphabet) {
case 1: {
font_code.insert(CImg<>::vector(' '));
for (unsigned char l='0'; l<='9'; l++) font_code.insert(CImg<>::vector(l));
} break;
case 2: {
font_code.insert(CImg<>::vector(' '));
for (unsigned char l='A'; l<='Z'; l++) font_code.insert(CImg<>::vector(l));
} break;
case 3: {
font_code.insert(CImg<>::vector(' '));
font_code.insert(CImg<>::vector('-'));
font_code.insert(CImg<>::vector('_'));
font_code.insert(CImg<>::vector('|'));
font_code.insert(CImg<>::vector('/'));
font_code.insert(CImg<>::vector('\\'));
font_code.insert(CImg<>::vector('+'));
font_code.insert(CImg<>::vector('.'));
font_code.insert(CImg<>::vector('*'));
font_code.insert(CImg<>::vector('='));
font_code.insert(CImg<>::vector(']'));
font_code.insert(CImg<>::vector('['));
font_code.insert(CImg<>::vector('('));
font_code.insert(CImg<>::vector(')'));
font_code.insert(CImg<>::vector('{'));
font_code.insert(CImg<>::vector('}'));
font_code.insert(CImg<>::vector('"'));
font_code.insert(CImg<>::vector('!'));
font_code.insert(CImg<>::vector('$'));
} break;
case 4: {
font_code.insert(CImg<>::vector(' '));
font_code.insert(CImg<>::vector('.'));
font_code.insert(CImg<>::vector('/'));
font_code.insert(CImg<>::vector('\\'));
font_code.insert(CImg<>::vector('_'));
font_code.insert(CImg<>::vector('_'));
font_code.insert(CImg<>::vector('|'));
} break;
default: { for (unsigned char l=' '; l<='~'; l++) font_code.insert(CImg<>::vector(l)); } break;
}
cimglist_for(font_code,l) {
font.insert(font_full(font_code[l](0)));
font_blur.insert(font[l].get_resize(fw,fh,1,1).blur(sigma).normalize(0,255));
}
// Init images
CImg<> img;
if (!file_i) { float white[3] = { 255,255,255 }; img.assign().draw_text(0,0," CImg\nRocks !",white); }
else img.assign(file_i);
img.norm().resize(fw*w,fh*h);
if (blur) img.blur(blur);
if (contour>0) {
CImgList<> grad = img.get_gradient("xy",4);
img = (grad[0].pow(2) + grad[1].pow(2)).sqrt().normalize(0,100).threshold(contour);
}
img.normalize(0,255);
if (invert) img = 255.0f - img;
CImg<unsigned char> dest(w,h,1,1,0);
// Render ASCII-art image, using a simple correlation method.
CImg<> neigh;
cimg_forY(dest,y) { cimg_forX(dest,x) {
neigh = img.get_crop(x*fw,y*fh,(x + 1)*fw,(y + 1)*fh);
float scoremin = 2e28f;
unsigned int best = 0;
cimglist_for(font_code,l) {
const CImg<>& letter = font_blur[l];
const float score = (float)((letter - neigh).pow(2).sum());
if (score<scoremin) { scoremin = score; best = l; }
}
dest(x,y) = (unsigned char)best;
std::fprintf(stdout,"%c",font_code[dest(x,y)](0));
}
std::fprintf(stdout,"\n");
}
std::exit(0);
return 0;
}
/*
#
# File : image_registration2d.cpp
# ( C++ source file )
#
# Description : Compute a motion field between two images,
# with a multiscale and variational algorithm.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
#undef min
#undef max
// animate_warp() : Create warping animation from two images and a motion field
//----------------
void animate_warp(const CImg<unsigned char>& src, const CImg<unsigned char>& dest, const CImg<>& U,
const bool morph, const bool imode, const char *filename,int nb, CImgDisplay& disp) {
CImg<unsigned char> visu = (src,dest,src)>'x', warp(src);
float t = 0;
for (unsigned int iteration = 0; !disp || (!disp.is_closed() && !disp.is_keyQ()); ++iteration) {
if (morph) cimg_forXYC(warp,x,y,k) {
const float dx = U(x,y,0), dy = U(x,y,1),
I1 = (float)src.linear_atXY(x - t*dx, y - t*dy, k),
I2 = (float)dest.linear_atXY(x + (1 - t)*dx,y + (1 - t)*dy,k);
warp(x,y,k) = (unsigned char)((1 - t)*I1 + t*I2);
} else cimg_forXYC(warp,x,y,k) {
const float dx = U(x,y,0), dy = U(x,y,1), I1 = (float)src.linear_atXY(x - t*dx, y - t*dy, 0,k);
warp(x,y,k) = (unsigned char)I1;
}
if (disp) visu.draw_image(2*src.width(),warp).display(disp.resize().wait(30));
if (filename && *filename && (imode || (int)iteration<nb)) {
std::fprintf(stderr,"\r > frame %d ",iteration);
warp.save(filename,iteration);
}
t+=1.0f/nb;
if (t<0) { t = 0; nb = -nb; }
if (t>1) { t = 1; nb = -nb; if (filename && *filename) std::exit(0); }
}
}
// optflow() : multiscale version of the image registration algorithm
//-----------
CImg<> optflow(const CImg<>& source, const CImg<>& target,
const float smoothness, const float precision, const unsigned int nb_scales, CImgDisplay& disp) {
const unsigned int iteration_max = 100000;
const float _precision = (float)std::pow(10.0,-(double)precision);
const CImg<>
src = source.get_resize(target,3).normalize(0,1),
dest = target.get_normalize(0,1);
CImg<> U;
const unsigned int _nb_scales = nb_scales>0?nb_scales:
(unsigned int)(2*std::log((double)(std::max(src.width(),src.height()))));
for (int scale = _nb_scales - 1; scale>=0; --scale) {
const float factor = (float)std::pow(1.5,(double)scale);
const unsigned int
_sw = (unsigned int)(src.width()/factor), sw = _sw?_sw:1,
_sh = (unsigned int)(src.height()/factor), sh = _sh?_sh:1;
const CImg<>
I1 = src.get_resize(sw,sh,1,-100,2),
I2 = dest.get_resize(I1,2);
std::fprintf(stderr," * Scale %d\n",scale);
if (U) (U*=1.5f).resize(I2.width(),I2.height(),1,-100,3);
else U.assign(I2.width(),I2.height(),1,2,0);
float dt = 2, energy = cimg::type<float>::max();
const CImgList<> dI = I2.get_gradient();
for (unsigned int iteration = 0; iteration<iteration_max; ++iteration) {
std::fprintf(stderr,"\r- Iteration %d - E = %g",iteration,energy); std::fflush(stderr);
float _energy = 0;
cimg_for3XY(U,x,y) {
const float
X = x + U(x,y,0),
Y = y + U(x,y,1);
float deltaI = 0;
cimg_forC(I2,c) deltaI+=(float)(I1(x,y,c) - I2.linear_atXY(X,Y,c));
float _energy_regul = 0;
cimg_forC(U,c) {
const float
Ux = 0.5f*(U(_n1x,y,c) - U(_p1x,y,c)),
Uy = 0.5f*(U(x,_n1y,c) - U(x,_p1y,c)),
Uxx = U(_n1x,y,c) + U(_p1x,y,c),
Uyy = U(x,_n1y,c) + U(x,_p1y,c);
U(x,y,c) = (float)( U(x,y,c) + dt*(deltaI*dI[c].linear_atXY(X,Y) +
smoothness* ( Uxx + Uyy )))/(1 + 4*smoothness*dt);
_energy_regul+=Ux*Ux + Uy*Uy;
}
_energy+=deltaI*deltaI + smoothness*_energy_regul;
}
const float d_energy = (_energy - energy)/(sw*sh);
if (d_energy<=0 && -d_energy<_precision) break;
if (d_energy>0) dt*=0.5f;
energy = _energy;
if (disp) disp.resize();
if (disp && disp.is_closed()) std::exit(0);
if (disp && !(iteration%300)) {
const unsigned char white[] = { 255,255,255 };
CImg<unsigned char> tmp = I1.get_warp(U,true,true,1).normalize(0,200);
tmp.resize(disp.width(),disp.height()).draw_quiver(U,white,0.7f,15,-14,true).display(disp);
}
}
std::fprintf(stderr,"\n");
}
return U;
}
/*------------------------
Main function
------------------------*/
int main(int argc,char **argv) {
// Read command line parameters
cimg_usage("Compute an optical flow between two 2D images, and create a warped animation");
const char
*name_i1 = cimg_option("-i",cimg_imagepath "sh0r.pgm","Input Image 1 (Destination)"),
*name_i2 = cimg_option("-i2",cimg_imagepath "sh1r.pgm","Input Image 2 (Source)"),
*name_o = cimg_option("-o",(const char*)NULL,"Output 2D flow (inrimage)"),
*name_seq = cimg_option("-o2",(const char*)NULL,"Output Warping Sequence");
const float
smoothness = cimg_option("-s",0.1f,"Flow Smoothness"),
precision = cimg_option("-p",6.0f,"Convergence precision");
const unsigned int
nb = cimg_option("-n",40,"Number of warped frames"),
nb_scales = cimg_option("-scale",0,"Number of scales (0=auto)");
const bool
normalize = cimg_option("-equalize",true,"Histogram normalization of the images"),
morph = cimg_option("-m",true,"Morphing mode"),
imode = cimg_option("-c",true,"Complete interpolation (or last frame is missing)"),
dispflag = !cimg_option("-novisu",false,"Visualization");
// Init images and display
std::fprintf(stderr," - Init images.\n");
const CImg<>
src(name_i1),
dest(CImg<>(name_i2).resize(src,3)),
src_blur = normalize?src.get_blur(0.5f).equalize(256):src.get_blur(0.5f),
dest_blur = normalize?dest.get_blur(0.5f).equalize(256):dest.get_blur(0.5f);
CImgDisplay disp;
if (dispflag) {
unsigned int w = src.width(), h = src.height();
const unsigned int dmin = std::min(w,h), minsiz = 512;
if (dmin<minsiz) { w=w*minsiz/dmin; h=h*minsiz/dmin; }
const unsigned int dmax = std::max(w,h), maxsiz = 1024;
if (dmax>maxsiz) { w=w*maxsiz/dmax; h=h*maxsiz/dmax; }
disp.assign(w,h,"Estimated Motion",0);
}
// Run Motion estimation algorithm
std::fprintf(stderr," - Compute optical flow.\n");
const CImg<> U = optflow(src_blur,dest_blur,smoothness,precision,nb_scales,disp);
if (name_o) U.save(name_o);
U.print("Computed flow");
// Do morphing animation
std::fprintf(stderr," - Create warped animation.\n");
CImgDisplay disp2;
if (dispflag) {
unsigned int w = src.width(), h = src.height();
const unsigned int dmin = std::min(w,h), minsiz = 100;
if (dmin<minsiz) { w = w*minsiz/dmin; h=h*minsiz/dmin; }
const unsigned int dmax = std::max(w,h), maxsiz = 1024/3;
if (dmax>maxsiz) { w = w*maxsiz/dmax; h=h*maxsiz/dmax; }
disp2.assign(3*w,h,"Source/Destination images and Motion animation",0);
}
animate_warp(src.get_normalize(0,255),dest.get_normalize(0,255),U,morph,imode,name_seq,nb,disp2);
std::exit(0);
return 0;
}
/*
#
# File : image_surface3d.cpp
# ( C++ source file )
#
# Description : This tool allows to show an image as a 3D surface.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line arguments.
cimg_usage("Render an image as a surface");
const char *file_i = cimg_option("-i",cimg_imagepath "logo.bmp","Input image");
const char *file_o = cimg_option("-o",(char*)0,"Output 3D object");
const float sigma = cimg_option("-smooth",1.0f,"Amount of image smoothing");
const float ratioz = cimg_option("-z",0.25f,"Aspect ratio along z-axis");
const unsigned int di = cimg_option("-di",10,"Step for isophote skipping");
// Load 2D image file.
std::fprintf(stderr,"\n- Load file '%s'",cimg::basename(file_i)); std::fflush(stderr);
const CImg<unsigned char>
img = CImg<>(file_i).blur(sigma).resize(-100,-100,1,3),
norm = img.get_norm().normalize(0,255);
// Compute surface with triangles.
std::fprintf(stderr,"\n- Create image surface"); std::fflush(stderr);
CImgList<unsigned int> primitives;
CImgList<unsigned char> colors;
const CImg<> points = img.get_elevation3d(primitives,colors,norm*-ratioz);
// Compute image isophotes.
std::fprintf(stderr,"\n- Compute image isophotes"); std::fflush(stderr);
CImgList<unsigned int> isoprimitives;
CImgList<unsigned char> isocolors;
CImg<> isopoints;
for (unsigned int i = 0; i<255; i+=di) {
CImgList<> prims;
const CImg<> pts = norm.get_isoline3d(prims,(float)i);
isopoints.append_object3d(isoprimitives,pts,prims);
}
cimglist_for(isoprimitives,l) {
const unsigned int i0 = isoprimitives(l,0);
const float x0 = isopoints(i0,0), y0 = isopoints(i0,1);
const unsigned char
r = (unsigned char)img.linear_atXY(x0,y0,0),
g = (unsigned char)img.linear_atXY(x0,y0,1),
b = (unsigned char)img.linear_atXY(x0,y0,2);
isocolors.insert(CImg<unsigned char>::vector(r,g,b));
}
cimg_forX(isopoints,ll) isopoints(ll,2) = -ratioz*norm.linear_atXY(isopoints(ll,0),isopoints(ll,1));
// Save object if necessary
if (file_o) {
std::fprintf(stderr,"\n- Save 3d object as '%s'",cimg::basename(file_o)); std::fflush(stderr);
points.save_off(primitives,colors,file_o);
}
// Enter event loop
std::fprintf(stderr,
"\n- Enter interactive loop.\n\n"
"Reminder : \n"
" + Use mouse to rotate and zoom object\n"
" + key 'F' : Toggle fullscreen\n"
" + key 'Q' or 'ESC' : Quit\n"
" + Any other key : Change rendering type\n\n"); std::fflush(stderr);
const char *const title = "Image viewed as a surface";
CImgDisplay disp(800,600,title,0);
unsigned int rtype = 2;
CImg<float> pose = CImg<float>::identity_matrix(4);
while (!disp.is_closed()) {
const unsigned char white[3]={ 255, 255, 255 };
CImg<unsigned char> visu(disp.width(),disp.height(),1,3,0);
visu.draw_text(10,10,"%s",white,0,1,24,
rtype==0?"Points":(rtype==1?"Lines":(rtype==2?"Faces":(rtype==3?"Flat-shaded faces":
(rtype==4?"Gouraud-shaded faces":(rtype==5?"Phong-shaded faces":"Isophotes"))))));
static bool first_time = true;
if (rtype==6) visu.display_object3d(disp,isopoints,isoprimitives,isocolors,first_time,1,-1,true,
500.0f,0.0f,0.0f,-5000.0f,0.0f,0.0f,true,pose.data());
else visu.display_object3d(disp,points,primitives,colors,first_time,rtype,-1,true,
500.0f,0.0f,0.0f,-5000.0f,0.0f,0.0f,true,pose.data());
first_time = false;
switch (disp.key()) {
case 0: break;
case cimg::keyBACKSPACE: rtype = (7 + rtype - 1)%7; break;
case cimg::keyQ:
case cimg::keyESC: disp.close(); break;
case cimg::keyF:
if (disp.is_fullscreen()) disp.resize(800,600); else disp.resize(disp.screen_width(),disp.screen_height());
disp.toggle_fullscreen();
break;
default: rtype = (rtype + 1)%7; break;
}
}
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
#
# File : mcf_levelsets2d.cpp
# ( C++ source file )
#
# Description : Implementation of the Mean Curvature Flow on a 2D curve,
# using the framework of Level Sets.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#undef min
#undef max
// Retrieve the curve corresponding to the zero level set of the distance function.
template<typename T>
CImg<unsigned char> get_level0(const CImg<T>& img) {
CImg<unsigned char> dest(img);
CImg_2x2(I,T); Inn = 0;
cimg_for2x2(img,x,y,0,0,I,T) if (Icc*Inc<0 || Icc*Icn<0) dest(x,y) = 255; else dest(x,y) = Icc<0?100:0;
return dest;
}
/*--------------------
Main procedure
----------------------*/
int main(int argc,char **argv) {
cimg_usage("Perform a Mean Curvature Flow on closed curves, using Level Sets");
const float dt = cimg_option("-dt",0.8f,"PDE time step");
const unsigned int nb_iterations = cimg_option("-iter",10000,"Number of iterations");
// Create a user-defined closed curve.
CImg<unsigned char> curve(256,256,1,2,0);
unsigned char col1[] = {0,255}, col2[] = {200,255}, col3[] = {255,255};
curve.draw_grid(20,20,0,0,false,false,col1,0.4f,0xCCCCCCCC,0xCCCCCCCC).
draw_text(5,5,"Please draw your curve\nin this window\n(Use your mouse)",col1);
CImgDisplay disp(curve,"Mean curvature flow",0);
int xo = -1, yo = -1, x0 = -1, y0 = -1, x1 = -1, y1 = -1;
while (!disp.is_closed() && (x0<0 || disp.button())) {
if (disp.button() && disp.mouse_x()>=0 && disp.mouse_y()>=0) {
if (x0<0) { xo = x0 = disp.mouse_x(); yo = y0 = disp.mouse_y(); } else {
x1 = disp.mouse_x(); y1 = disp.mouse_y();
curve.draw_line(x0,y0,x1,y1,col2).display(disp);
x0 = x1; y0 = y1;
}
}
disp.wait();
if (disp.is_resized()) disp.resize(disp);
}
curve.draw_line(x1,y1,xo,yo,col2).channel(0).draw_fill(0,0,col3);
CImg<> img = CImg<>(curve.get_shared_channel(0)).normalize(-1,1);
// Perform the "Mean Curvature Flow".
img.distance_eikonal(10);
CImg_3x3(I,float);
for (unsigned int iteration = 0; iteration<nb_iterations && !disp.is_closed() &&
!disp.is_keyQ() && !disp.is_keyESC(); ++iteration) {
CImg<float> velocity(img.width(),img.height(),img.depth(),img.spectrum());
float *ptrd = velocity.data(), veloc_max = 0;
cimg_for3x3(img,x,y,0,0,I,float) {
const float
ix = (Inc - Ipc)/2,
iy = (Icn - Icp)/2,
ixx = Inc + Ipc - 2*Icc,
iyy = Icn + Icp - 2*Icc,
ixy = (Ipp + Inn - Inp - Ipn)/4,
ngrad = ix*ix + iy*iy,
iee = (ngrad>1e-5)?((iy*iy*ixx - 2*ix*iy*ixy + ix*ix*iyy)/ngrad):0;
*(ptrd++) = iee;
if (iee>veloc_max) veloc_max = iee; else if (-iee>veloc_max) veloc_max = -iee;
}
if (veloc_max>0) img+=(velocity*=dt/veloc_max);
if (!(iteration%10)) {
get_level0(img).resize(disp.width(),disp.height()).
draw_grid(20,20,0,0,false,false,col3,0.4f,0xCCCCCCCC,0xCCCCCCCC).
draw_text(5,5,"Iteration %d",col3,0,1,13,iteration).display(disp);
}
if (!(iteration%60)) img.distance_eikonal(1,3);
if (disp.is_resized()) disp.resize();
}
return 0;
}
/*
#
# File : mcf_levelsets3d.cpp
# ( C++ source file )
#
# Description : Implementation of the Mean Curvature Flow on Surfaces
# using the framework of Level Sets 3D.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#undef min
#undef max
// Apply the Mean curvature flow PDE
//-----------------------------------
template<typename T> CImg<T>& mcf_PDE(CImg<T>& img, const unsigned int nb_iterations,
const float dt=0.25f, const float narrow=4.0f) {
CImg<float> velocity(img.width(),img.height(),img.depth(),img.spectrum());
CImg_3x3x3(I,float);
for (unsigned int iteration = 0; iteration<nb_iterations; ++iteration) {
float *ptrd = velocity.data(), veloc_max = 0;
cimg_for3x3x3(img,x,y,z,0,I,float) if (cimg::abs(Iccc)<narrow) {
const float
ix = (Incc - Ipcc)/2,
iy = (Icnc - Icpc)/2,
iz = (Iccn - Iccp)/2,
norm = (float)std::sqrt(1e-5f + ix*ix + iy*iy + iz*iz),
ixx = Incc + Ipcc - 2*Iccc,
ixy = (Ippc + Innc - Inpc - Ipnc)/4,
ixz = (Ipcp + Incn - Incp - Ipcn)/4,
iyy = Icnc + Icpc - 2*Iccc,
iyz = (Icpp + Icnn - Icnp - Icpn)/4,
izz = Iccn + Iccp - 2*Iccc,
a = ix/norm,
b = iy/norm,
c = iz/norm,
inn = a*a*ixx + b*b*iyy + c*c*izz + 2*a*b*ixy + 2*a*c*ixz + 2*b*c*iyz,
veloc = ixx + iyy + izz - inn;
*(ptrd++) = veloc;
if (veloc>veloc_max) veloc_max = veloc; else if (-veloc>veloc_max) veloc_max = -veloc;
} else *(ptrd++) = 0;
if (veloc_max>0) img+=(velocity*=dt/veloc_max);
}
return img;
}
/*----------------------
Main procedure
--------------------*/
int main(int argc,char **argv) {
cimg_usage("Mean curvature flow of a surface, using 3D level sets");
const char *file_i = cimg_option("-i",(char*)0,"Input image");
const float dt = cimg_option("-dt",0.05f,"PDE Time step");
const float narrow = cimg_option("-band",5.0f,"Size of the narrow band");
const bool both = cimg_option("-both",false,"Show both evolving and initial surface");
// Define the signed distance map of the initial surface.
CImg<> img;
if (file_i) {
const float sigma = cimg_option("-sigma",1.2f,"Segmentation regularity");
const float alpha = cimg_option("-alpha",5.0f,"Region growing tolerance");
img.load(file_i).channel(0);
CImg<int> s;
CImgDisplay disp(img,"Please select a starting point");
while (!s || s[0]<0) s = img.get_select(0,disp);
CImg<> region;
float tmp[] = { 0 };
img.draw_fill(s[0],s[1],s[2],tmp,1,region,alpha);
((img = region.normalize(-1,1))*=-1).blur(sigma);
}
else { // Create synthetic implicit function
img.assign(60,60,60);
const float exte[] = { 1 }, inte[] = { -1 };
img.fill(*exte).draw_rectangle(15,15,15,45,45,45,inte).draw_rectangle(25,25,0,35,35,img.depth() - 1,exte).
draw_rectangle(0,25,25,img.width() - 1,35,35,exte).draw_rectangle(25,0,25,35,img.height() - 1,35,exte).noise(0.7);
}
img.distance_eikonal(10,0,0.1f);
// Compute corresponding surface triangularization by the marching cube algorithm (isovalue 0).
CImg<> points0;
CImgList<unsigned int> faces0;
if (both) points0 = img.get_isosurface3d(faces0,0);
const CImgList<unsigned char> colors0(faces0.size(),CImg<unsigned char>::vector(100,200,255));
const CImgList<> opacities0(faces0.size(),1,1,1,1,0.2f);
// Perform MCF evolution.
CImgDisplay disp(256,256,0,1), disp3d(512,512,0,0);
float alpha = 0, beta = 0;
for (unsigned int iteration = 0; !disp.is_closed() && !disp3d.is_closed() &&
!disp.is_keyESC() && !disp3d.is_keyESC() && !disp.is_keyQ() && !disp3d.is_keyQ(); ++iteration) {
disp.set_title("3D implicit Function (iter. %u)",iteration);
disp3d.set_title("Mean curvature flow 3D - Isosurface (iter. %u)",iteration);
// Apply PDE on the distance function.
mcf_PDE(img,1,dt,narrow); // Do one iteration of mean curvature flow
// Every 10 steps, do one iteration of distance function re-initialization.
if (!(iteration%10)) img.distance_eikonal(1,narrow,0.5f);
// Compute surface triangularization by the marching cube algorithm (isovalue 0)
CImgList<unsigned int> faces;
CImg<> points = img.get_isosurface3d(faces,0);
CImgList<unsigned char> colors(faces.size(),CImg<unsigned char>::vector(200,128,100));
CImgList<> opacities(faces.size(),CImg<>::vector(1.0f));
const float fact = 3*std::max(disp3d.width(),disp3d.height())/(4.0f*std::max(img.width(),img.height()));
// Append initial object if necessary.
if (both) {
points.append_object3d(faces,points0,faces0);
colors.insert(colors0);
opacities.insert(opacities0);
}
// Center and rescale the objects
cimg_forX(points,l) {
points(l,0)=(points(l,0) - img.width()/2)*fact;
points(l,1)=(points(l,1) - img.height()/2)*fact;
points(l,2)=(points(l,2) - img.depth()/2)*fact;
}
// Display 3D object on the display window.
CImg<unsigned char> visu(disp3d.width(),disp3d.height(),1,3,0);
const CImg<> rot = CImg<>::rotation_matrix(1,0,0,(beta+=0.5f))*CImg<>::rotation_matrix(0,1,1,(alpha+=3));
if (points.size()) {
visu.draw_object3d(visu.width()/2.0f,visu.height()/2.0f,0.0f,
rot*points,faces,colors,opacities,3,
false,500.0,0.0f,0.0f,-8000.0f).display(disp3d);
} else visu.fill(0).display(disp3d);
img.display(disp.wait(20));
if ((disp3d.button() || disp3d.key()) && points.size() && !disp3d.is_keyESC() && !disp3d.is_keyQ()) {
const unsigned char white[3] = { 255, 255, 255 };
visu.fill(0).draw_text(10,10,"Time stopped, press any key to start again",white).
display_object3d(disp3d,points,faces,colors,opacities,true,4,3,false,500,0,0,-5000,0.4f,0.3f);
disp3d.set_key();
}
if (disp.is_resized()) disp.resize(false);
if (disp3d.is_resized()) disp3d.resize(false);
disp.wait(50);
}
return 0;
}
/*
#
# File : odykill.cpp
# ( C++ source file )
#
# Description : Simple shoot-em-up game featuring the Robotvis/Odyssee Team !
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "img/odykill.h"
#include "CImg.h"
using namespace cimg_library;
// Main procedure
//----------------
int main(int argc,char **argv) {
// Create game graphics
CImg<unsigned char> graphics[21] = {
CImg<unsigned char>(data_tomato,100,100,1,3,false),
CImg<unsigned char>(data_heart,100,100,1,3,false),
CImg<unsigned char>(data_dynamite,100,100,1,3,false),
CImg<unsigned char>(data_brain,100,100,1,3,false),
CImg<unsigned char>(data_cdrom,100,100,1,3,false),
CImg<unsigned char>(data_enemy,113,150,1,3,false),
CImg<unsigned char>(data_enemy2,116,155,1,3,false),
CImg<unsigned char>(data_enemy3,104,134,1,3,false),
CImg<unsigned char>(data_enemy4,141,151,1,3,false),
CImg<unsigned char>(data_enemy5,140,152,1,3,false),
CImg<unsigned char>(data_enemy6,131,156,1,3,false),
CImg<unsigned char>(data_enemy7,114,125,1,3,false),
CImg<unsigned char>(data_enemy8,97,125,1,3,false),
CImg<unsigned char>(data_enemy9,143,134,1,3,false),
CImg<unsigned char>(data_enemy10,158,214,1,3,false),
CImg<unsigned char>(data_enemy11,131,168,1,3,false),
CImg<unsigned char>(data_enemy12,114,138,1,3,false),
CImg<unsigned char>(data_enemy13,144,144,1,3,false),
CImg<unsigned char>(data_enemy14,132,153,1,3,false),
CImg<unsigned char>(data_enemy15,152,151,1,3,false),
CImg<unsigned char>(data_enemy16,139,185,1,3,false),
};
CImg<> masks[21];
const unsigned char black[] = { 0,0,0 }, white[] = { 255,255,255 };
// Display weapon selection menu
CImg<unsigned char> back0(640,480,1,3), title(data_title,294,94,1,3,true), choose(data_choose,524,49,1,3,true);
back0.fill(0).draw_image(back0.width()/2 - title.width()/2,30,title).
draw_image(back0.width()/2 - choose.width()/2,150,choose);
CImgDisplay disp(back0,"OdyKill");
int weapon=-1;
while (!disp.is_closed() && !disp.button()) {
weapon = -1;
for (int k=0; k<5; k++) {
const int mx = disp.mouse_x(), my = disp.mouse_y();
if (!((mx - 40)/110==k && my>250 && my<350)) back0.draw_image(40 + k*110,250,graphics[k]/2.0);
else back0.draw_image(40 + k*110,250,graphics[weapon=k]);
}
CImg<unsigned char> tmp = CImg<unsigned char>().draw_text(0,0,
weapon==0?" Tomato ":
weapon==1?" Heart ":
weapon==2?" Dynamite ":
weapon==3?" Brain ":
weapon==4?" CD-Rom ":
" ",white,black,1,32).resize(-100,-100,1,1),
tmp2 = tmp.get_blur(6).normalize(0,255).draw_image(tmp,0.5f);
cimg_forC(back0,k) back0.draw_image(250,390,0,k,tmp2);
disp.resize(disp).display(back0).wait();
if (disp.is_keyCTRLLEFT() && disp.is_keyF()) disp.toggle_fullscreen();
if (disp.is_closed() || disp.is_keyQ() || disp.is_keyESC()) std::exit(0);
}
disp.hide_mouse();
/*---------------------------------
Go !
--------------------------------*/
const CImg<unsigned char>
background = CImg<unsigned char>(100,100,1,3,0).noise(100,2).draw_plasma().
resize(back0.width(),back0.height(),1,3,5)/2.5;
for (unsigned int k = 0; k<21; k++) {
CImg<> tmp = graphics[k].resize(k<5?32:164,k<5?32:164,1,3);
cimg_forXY(tmp,x,y) tmp(x,y) = (tmp(x,y,0)==255 && tmp(x,y,1)==255 && tmp(x,y,2)==255)?0.0f:1.0f;
masks[k] = tmp.get_channel(0);
graphics[k].resize(k<5?32:164,k<5?32:164,1,3,5);
}
CImg<unsigned char> canvas(background);
int n = 5 + ((int)(200*cimg::rand())%16);
CImg<unsigned char> tomato = graphics[weapon], enemy = graphics[n];
CImg<> m_tomato = masks[weapon], m_enemy = masks[n];
double angle = 0;
int tomato_x = 0,tomato_y = 0,shooted = 0;
double enemy_x = -1000, enemy_y = -1000, enemy_z = -1000, tomato_z = 0, vx = 0, vy = 0, vz = 0, va = 0;
double speed = cimg_option("-speed",5.0,"Speed");
int timeleft = 2000, score = 0;
CImg<unsigned char> r_enemy;
// Main loop
while (timeleft && !disp.is_closed() && !disp.is_keyESC() && !disp.is_keyQ()) {
--timeleft;
const int mx = disp.mouse_x()*back0.width()/disp.width(), my = disp.mouse_y()*back0.height()/disp.height();
// Handle object motion
if (tomato_z>0) {
tomato_z+=0.07; tomato_y -= (int)(20*std::cos(cimg::PI/7 + tomato_z*cimg::PI));
if (tomato_z>=1) { tomato_z=0; tomato_x = mx; tomato_y = my; }
}
if (!shooted) { enemy_x +=vx; enemy_y +=vy; enemy_z +=vz; }
else {
va = 10;
enemy_y += vy;
vy += 2;
tomato_z = 0;
if (enemy_y>5*canvas.height()/4) {
shooted = 0;
int nn = 5 + ((int)(200*cimg::rand())%16);
enemy = graphics[nn];
m_enemy = masks[nn];
enemy_x=cimg::rand(-1,1)*1e8; enemy_y=cimg::rand(-1,1)*1e8; enemy_z=cimg::rand(-1,1)*1e8;
va = angle = 0;
}
}
if (enemy_x<0) { enemy_x=0; vx = speed*cimg::rand(-1,1); }
if (enemy_x>canvas.width()) { enemy_x=canvas.width(); vx = speed*cimg::rand(-1,1); }
if (enemy_y<0) { enemy_y=0; vy = speed*cimg::rand(-1,1); }
if (!shooted && enemy_y>canvas.height()) { enemy_y=canvas.height(); vy = speed*cimg::rand(-1,1); }
if (enemy_z<0.1) { enemy_z = 0.1; vz = speed*0.01*cimg::rand(-1,1); }
if (enemy_z>0.7) { enemy_z = 0.7; vz = speed*0.01*cimg::rand(-1,1); }
angle+=va;
// Handle mouse interaction
if (!disp.button()) {
if (tomato_z==0) {
tomato_x = mx; tomato_y = my;
}
} else tomato_z +=0.0001;
// Detect shooting
if (cimg::abs(tomato_z - enemy_z)<0.1) {
if (tomato_x>enemy_x - r_enemy.width()/2 && tomato_x<enemy_x + r_enemy.width()/2 &&
tomato_y>enemy_y - r_enemy.height()/2 && tomato_y<enemy_y + r_enemy.height()/2) {
score++;
shooted = 1;
}
}
// Draw into canvas
canvas = background;
r_enemy = enemy.get_resize((int)(8 + enemy.width()*(1 - enemy_z)),
(int)(8 + enemy.height()*(1 - enemy_z)),-100,-100);
CImg<> rm_enemy = m_enemy.get_resize(r_enemy.width(),r_enemy.height());
CImg<unsigned char> r_tomato = tomato.get_resize((int)(8 + tomato.width()*(1 - tomato_z)),
(int)(8 + tomato.height()*(1 - tomato_z)),-100,-100);
CImg<> rm_tomato = m_tomato.get_resize(r_tomato.width(),r_tomato.height());
if (angle!=0) {
r_enemy.rotate((float)angle,0,0);
rm_enemy.rotate((float)angle,0,0);
cimg_forXY(r_enemy,x,y) r_enemy(x,y,0) = (r_enemy(x,y,0) + 255)/2;
}
r_enemy*=(1 - (enemy_z - 0.1)/1.6);
r_tomato*=(1 - tomato_z/1.6);
rm_enemy*=(1 - (enemy_z - 0.1)/1.6);
if (enemy_z>tomato_z) {
canvas.draw_image((int)(enemy_x - r_enemy.width()/2),
(int)(enemy_y - r_enemy.height()/2),
r_enemy,rm_enemy);
if (tomato_x>=0) canvas.draw_image(tomato_x - r_tomato.width()/2,
tomato_y - r_tomato.height()/2,
r_tomato,rm_tomato);
}
else {
if (tomato_x>=0) canvas.draw_image(tomato_x - r_tomato.width()/2,
tomato_y - r_tomato.height()/2,
r_tomato,rm_tomato);
canvas.draw_image((int)(enemy_x - r_enemy.width()/2),
(int)(enemy_y - r_enemy.height()/2),
r_enemy,rm_enemy);
}
canvas.draw_text(1,1," Time left %d, Score = %d",white,0,0.5f,24,timeleft,score);
disp.resize(disp).display(canvas).wait(25);
if (disp.is_keyCTRLLEFT() && disp.is_keyF()) disp.toggle_fullscreen();
}
std::fprintf(stderr,"\n\n YOUR SCORE : %d\n\n\n",score);
return 0;
}
/*
#
# File : pde_TschumperleDeriche2d.cpp
# ( C++ source file )
#
# Description : Implementation of the Tschumperlé-Deriche's Regularization
# PDE, for 2D multivalued images, as described in the articles below.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# (1) PDE-Based Regularization of Multivalued Images and Applications.
# (D. Tschumperlé). PhD Thesis. University of Nice-Sophia Antipolis, December 2002.
# (2) Diffusion PDE's on Vector-valued Images : Local Approach and Geometric Viewpoint.
# (D. Tschumperlé and R. Deriche). IEEE Signal Processing Magazine, October 2002.
# (3) Vector-Valued Image Regularization with PDE's : A Common Framework for Different Applications.
# (D. Tschumperlé and R. Deriche). CVPR'2003, Computer Vision and Pattern Recognition,
# Madison, United States, June 2003.
#
# This code can be used to perform image restoration, inpainting, magnification or flow visualization.
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
#undef min
#undef max
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line arguments
//-----------------------------
cimg_usage("Tschumperlé-Deriche's flow for 2D Image Restoration, Inpainting, Magnification or Flow visualization");
const char *file_i = cimg_option("-i",cimg_imagepath "milla.bmp","Input image");
const char *file_m = cimg_option("-m",(char*)NULL,"Mask image (if Inpainting)");
const char *file_f = cimg_option("-f",(char*)NULL,"Flow image (if Flow visualization)");
const char *file_o = cimg_option("-o",(char*)NULL,"Output file");
const double zoom = cimg_option("-zoom",1.0,"Image magnification");
const unsigned int nb_iter = cimg_option("-iter",100000,"Number of iterations");
const double dt = cimg_option("-dt",20.0,"Adapting time step");
const double alpha = cimg_option("-alpha",0.0,"Gradient smoothing");
const double sigma = cimg_option("-sigma",0.5,"Structure tensor smoothing");
const float a1 = cimg_option("-a1",0.5f,"Diffusion limiter along minimal variations");
const float a2 = cimg_option("-a2",0.9f,"Diffusion limiter along maximal variations");
const double noiseg = cimg_option("-ng",0.0,"Add gauss noise before aplying the algorithm");
const double noiseu = cimg_option("-nu",0.0,"Add uniform noise before applying the algorithm");
const double noises = cimg_option("-ns",0.0,"Add salt&pepper noise before applying the algorithm");
const bool stflag = cimg_option("-stats",false,"Display image statistics at each iteration");
const unsigned int save = cimg_option("-save",0,"Iteration saving step");
const unsigned int visu = cimg_option("-visu",10,"Visualization step (0=no visualization)");
const unsigned int init = cimg_option("-init",3,"Inpainting initialization (0=black, 1=white, 2=noise, 3=unchanged)");
const unsigned int skip = cimg_option("-skip",1,"Step of image geometry computation");
bool view_t = cimg_option("-d",false,"View tensor directions (useful for debug)");
double xdt = 0;
// Variable initialization
//-------------------------
CImg<> img, flow;
CImg<int> mask;
if (file_i) {
img = CImg<>(file_i).resize(-100,-100,1,-100);
if (file_m) mask = CImg<unsigned char>(file_m).resize(img.width(),img.height(),1,1);
else if (zoom>1) {
mask = CImg<int>(img.width(),img.height(),1,1,-1).
resize((int)(img.width()*zoom),(int)(img.height()*zoom),1,1,4) + 1;
img.resize((int)(img.width()*zoom),(int)(img.height()*zoom),1,-100,3);
}
} else {
if (file_f) {
flow = CImg<>(file_f);
img = CImg<>((int)(flow.width()*zoom),(int)(flow.height()*zoom),1,1,0).noise(100,2);
flow.resize(img.width(),img.height(),1,2,3);
} else
throw CImgException("You need to specify at least one input image (option -i), or one flow image (option -f)");
}
img.noise(noiseg,0).noise(noiseu,1).noise(noises,2);
float initial_min, initial_max = img.max_min(initial_min);
if (mask && init!=3)
cimg_forXYC(img,x,y,k) if (mask(x,y))
img(x,y,k) = (float)((init?
(init==1?initial_max:((initial_max - initial_min)*cimg::rand())):
initial_min));
CImgDisplay disp;
if (visu) disp.assign(img,"Iterated Image");
CImg<> G(img.width(),img.height(),1,3,0), T(G), veloc(img), val(2), vec(2,2);
// PDE main iteration loop
//-------------------------
for (unsigned int iter = 0; iter<nb_iter &&
(!disp || (!disp.is_closed() && !disp.is_keyQ() && !disp.is_keyESC())); ++iter) {
std::printf("\riter %u , xdt = %g ",iter,xdt); std::fflush(stdout);
if (stflag) img.print();
if (disp && disp.is_keySPACE()) { view_t = !view_t; disp.set_key(); }
if (!(iter%skip)) {
// Compute the tensor field T, used to drive the diffusion
//---------------------------------------------------------
// When using PDE for flow visualization
if (flow) cimg_forXY(flow,x,y) {
const float
u = flow(x,y,0,0),
v = flow(x,y,0,1),
n = (float)std::sqrt((double)(u*u + v*v)),
nn = (n!=0)?n:1;
T(x,y,0) = u*u/nn;
T(x,y,1) = u*v/nn;
T(x,y,2) = v*v/nn;
} else {
// Compute structure tensor field G
CImgList<> grad = img.get_gradient();
if (alpha!=0) cimglist_for(grad,l) grad[l].blur((float)alpha);
G.fill(0);
cimg_forXYC(img,x,y,k) {
const float ix = grad[0](x,y,k), iy = grad[1](x,y,k);
G(x,y,0) += ix*ix;
G(x,y,1) += ix*iy;
G(x,y,2) += iy*iy;
}
if (sigma!=0) G.blur((float)sigma);
// When using PDE for image restoration, inpainting or zooming
T.fill(0);
if (!mask) cimg_forXY(G,x,y) {
G.get_tensor_at(x,y).symmetric_eigen(val,vec);
const float
l1 = (float)std::pow(1.0f + val[0] + val[1],-a1),
l2 = (float)std::pow(1.0f + val[0] + val[1],-a2),
ux = vec(1,0),
uy = vec(1,1);
T(x,y,0) = l1*ux*ux + l2*uy*uy;
T(x,y,1) = l1*ux*uy - l2*ux*uy;
T(x,y,2) = l1*uy*uy + l2*ux*ux;
}
else cimg_forXY(G,x,y) if (mask(x,y)) {
G.get_tensor_at(x,y).symmetric_eigen(val,vec);
const float
ux = vec(1,0),
uy = vec(1,1);
T(x,y,0) = ux*ux;
T(x,y,1) = ux*uy;
T(x,y,2) = uy*uy;
}
}
}
// Compute the PDE velocity and update the iterated image
//--------------------------------------------------------
CImg_3x3(I,float);
veloc.fill(0);
cimg_forC(img,k) cimg_for3x3(img,x,y,0,k,I,float) {
const float
a = T(x,y,0),
b = T(x,y,1),
c = T(x,y,2),
ixx = Inc + Ipc - 2*Icc,
iyy = Icn + Icp - 2*Icc,
ixy = 0.25f*(Ipp + Inn - Ipn - Inp);
veloc(x,y,k) = a*ixx + 2*b*ixy + c*iyy;
}
if (dt>0) {
float m, M = veloc.max_min(m);
xdt = dt/std::max(cimg::abs(m),cimg::abs(M));
} else xdt=-dt;
img+=veloc*xdt;
img.cut((float)initial_min,(float)initial_max);
// Display and save iterations
if (disp && !(iter%visu)) {
if (!view_t) img.display(disp);
else {
const unsigned char white[3] = {255,255,255};
CImg<unsigned char> nvisu = img.get_resize(disp.width(),disp.height()).normalize(0,255);
CImg<> isophotes(img.width(),img.height(),1,2,0);
cimg_forXY(img,x,y) if (!mask || mask(x,y)) {
T.get_tensor_at(x,y).symmetric_eigen(val,vec);
isophotes(x,y,0) = vec(0,0);
isophotes(x,y,1) = vec(0,1);
}
nvisu.draw_quiver(isophotes,white,0.5f,10,9,0).display(disp);
}
}
if (save && file_o && !(iter%save)) img.save(file_o,iter);
if (disp) disp.resize().display(img);
}
// Save result and exit.
if (file_o) img.save(file_o);
return 0;
}
/*
#
# File : pde_heatflow2D.cpp
# ( C++ source file )
#
# Description : A simple Heat flow on 2D images.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
// Include library header file
#include "CImg.h"
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
#undef min
#undef max
// Make a simpler namespace alias if one wants to avoid 'using namespace cimg_library'
namespace cil = cimg_library;
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line arguments, and init images and displays
//-----------------------------------------------------------
cimg_usage("Perform a simple Heat Flow on 2D images");
cil::CImg<> img(cimg_option("-i",cimg_imagepath "milla.bmp","Input image")), veloc(img);
const double dt = cimg_option("-dt",3.0,"Adapting time step");
img.
noise(cimg_option("-ng",0.0,"Add gaussian noise"),0).
noise(cimg_option("-nu",0.0,"Add uniform noise"),1).
noise(cimg_option("-ns",0.0,"Add Salt&Pepper noise"),2);
cil::CImgDisplay profile(400,300,"Intensity Profile",0,false,true), disp(img,"Heat flow 2D",0,false,true);
disp.move((cil::CImgDisplay::screen_width() - disp.width() - profile.width())/2,
(cil::CImgDisplay::screen_height() - disp.height())/2);
profile.move(disp.window_x() + 8 + disp.window_width(), disp.window_y());
const float fwhite[] = { 255,255,255 };
bool run_PDE = true;
// Begin PDE iteration loop
//-------------------------
for (int iter = 0; !disp.is_closed() && !profile.is_closed() &&
!disp.is_keyQ() && !disp.is_keyESC() && !profile.is_keyQ() && !profile.is_keyESC();) {
// Compute one iteration of PDE explicit scheme
if (run_PDE) {
CImg_3x3(I,float);
cimg_forC(img,k) cimg_for3x3(img,x,y,0,k,I,float) veloc(x,y,k) = Inc + Ipc + Icn + Icp - 4*Icc;
float m, M = veloc.max_min(m);
const double xdt = dt/(M - m);
img += veloc*xdt;
cil::CImg<>(img).draw_text(2,2,"iter = %d",fwhite,0,1,13,iter).display(disp.wait(25));
}
// Plot (R,G,B) intensity profiles and display it
if (disp.mouse_x()>=0) {
const int
mx = disp.mouse_x(), my = disp.mouse_y(),
mnx = mx*profile.width()/disp.width();
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 }, white[] = { 255,255,255 };
cil::CImg<unsigned char>(profile.width(),profile.height(),1,3,0).
draw_graph(img.get_shared_row(my,0,0),red,1,1,0,255,0).
draw_graph(img.get_shared_row(my,0,1),green,1,1,0,255,0).
draw_graph(img.get_shared_row(my,0,2),blue,1,1,0,255,0).
draw_line(mnx,0,mnx,profile.height() - 1,white,0.5f,cil::cimg::rol(0xFF00FF00,iter%32)).
draw_text(2,2,"(x,y)=(%d,%d)",white,0,1,13,mx,my).
display(profile);
}
// Mouse button stops/starts PDE evolution.
if (disp.button() || profile.button()) { disp.set_button(); profile.set_button(); run_PDE = !run_PDE; }
profile.resize();
disp.resize(disp);
if (run_PDE) ++iter;
}
return 0;
}
/*
#
# File : plotter1d.cpp
# ( C++ source file )
#
# Description : A simple math formula plotter.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
// Include CImg library file and use its main namespace
#include "CImg.h"
using namespace cimg_library;
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line argument.
cimg_usage("Simple plotter of mathematical formulas");
const char *const formula = cimg_option("-f","sin(x/8) % cos(2*x)","Formula to plot");
const float x0 = cimg_option("-x0",-5.0f,"Minimal X-value");
const float x1 = cimg_option("-x1",5.0f,"Maximal X-value");
const int resolution = cimg_option("-r",1024,"Plot resolution");
const unsigned int nresolution = resolution>1?resolution:1024;
const unsigned int plot_type = cimg_option("-p",1,"Plot type");
const unsigned int vertex_type = cimg_option("-v",1,"Vertex type");
// Create plot data.
CImg<double> values(4,nresolution,1,1,0);
const unsigned int r = nresolution - 1;
cimg_forY(values,X) values(0,X) = x0 + X*(x1 - x0)/r;
cimg::eval(formula,values).move_to(values);
// Display interactive plot window.
values.display_graph(formula,plot_type,vertex_type,"X-axis",x0,x1,"Y-axis");
// Quit.
return 0;
}
/*
#
# File : scene3d.cpp
# ( C++ source file )
#
# Description : A simple program that demonstrates the use of the
# 3D functions of CImg, in conjonction with the Board library.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
// Uncomment the line below to use the Board library.
// ( You will need to link your code with the board library object ).
// ( Get the Board Library at : http://libboard.sourceforge.net/ )
//#define cimg_use_board
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
// Main procedure
//----------------
int main() {
// Define a simple 3D scene, composed of various basic objects (torus, cone, cube, ...)
//-------------------------------------------------------------------------------------
std::fprintf(stderr," - Create 3D Scene.\n");
// Define objects vertices and primitives.
CImgList<unsigned int> cube_prims, cone_prims, torus_prims, sphere_prims, plane_prims, scene_prims;
const CImg<float>
cube_pts = CImg<>::box3d(cube_prims,60,60,60).shift_object3d().shift_object3d(-50,50,0),
cone_pts = CImg<>::cone3d(cone_prims,30,40).shift_object3d().shift_object3d(50,50,0),
torus_pts = CImg<>::torus3d(torus_prims,30,10).shift_object3d().shift_object3d(-50,-50,0),
sphere_pts = CImg<>::sphere3d(sphere_prims,30).shift_object3d().shift_object3d(50,-50,0),
plane_pts = CImg<>::plane3d(plane_prims,200,200,20,20).shift_object3d().shift_object3d(0,0,40);
plane_prims.insert(plane_prims.get_reverse_object3d());
// Define objects colors and textures.
const CImgList<unsigned char>
cone_cols = CImgList<unsigned char>(cone_prims.size(),CImg<unsigned char>::vector(128,63,255)),
torus_cols = CImgList<unsigned char>(torus_prims.size(),CImg<unsigned char>::vector(255,55,163)),
sphere_cols = CImgList<unsigned char>(sphere_prims.size(),CImg<unsigned char>::vector(115,115,63)),
plane_cols = CImgList<unsigned char>(plane_prims.size(),CImg<unsigned char>::vector(60,120,180));
const CImg<unsigned char> texture = CImg<unsigned char>(cimg_imagepath "milla.bmp").resize(128,128);
CImgList<unsigned char> cube_cols;
cimglist_for(cube_prims,p) {
cube_cols.insert(texture,~0U,true);
cube_prims[p].append(CImg<unsigned int>::vector(0,0,127,0,127,127,0,127),'y');
}
// Define objects opacities.
const CImg<float>
cube_opacs(cube_prims.size(),1,1,1,1.0f),
cone_opacs(cone_prims.size(),1,1,1,0.8f),
torus_opacs(torus_prims.size(),1,1,1,0.6f),
sphere_opacs(sphere_prims.size(),1,1,1,0.4f),
plane_opacs(plane_prims.size(),1,1,1,0.4f);
// Append all object in a single 3D scene.
const CImg<float> scene_pts = CImg<float>().
append_object3d(scene_prims,cube_pts,cube_prims).
append_object3d(scene_prims,cone_pts,cone_prims).
append_object3d(scene_prims,torus_pts,torus_prims).
append_object3d(scene_prims,sphere_pts,sphere_prims).
append_object3d(scene_prims,plane_pts,plane_prims);
const CImgList<unsigned char> scene_cols = (+cube_cols,cone_cols,torus_cols,sphere_cols,plane_cols);
const CImg<float> scene_opacs = (cube_opacs,cone_opacs,torus_opacs,sphere_opacs,plane_opacs)>'x';
// Display object3D in a user-interacted window and get final position matrix.
std::fprintf(stderr," - Display 3D Scene.\n");
const CImg<unsigned char> visu = CImg<unsigned char>(3,512,512,1).fill(230,230,255).permute_axes("yzcx");
CImg<float> view_matrix = CImg<>::identity_matrix(4);
visu.display_object3d("3D Scene",scene_pts,scene_prims,scene_cols,scene_opacs,true,4,4,false,
500.0f,0,0,-5000,0.5f,0.1f,true,view_matrix.data());
// Save object 3D as OFF file.
std::fprintf(stderr," - Save .OFF 3D object file.\n");
scene_pts.save_off(scene_prims,scene_cols,"output.off");
// Save 3D view in SVG, EPS and FIG files.
// (using the Board library : https://github.com/c-koi/libboard ).
#ifdef cimg_use_board
// Define a Board instance
LibBoard::Board B;
// Set Background color of the board.
B.clear(230,230,255);
// Draw object both in 'visu' and in the board.
(view_matrix.crop(0,0,2,2))*=2;
(+visu).draw_object3d(B,visu.width()/2,visu.height()/2,visu.depth()/2,
view_matrix*scene_pts,scene_prims,scene_cols,scene_opacs,3).
display("Snapshot for Board");
// Save board into a vector graphics file format.
std::fprintf(stderr," - Save .SVG, .EPS and .FIG snapshots\n");
B.save("output.svg");
B.save("output.eps");
B.save("output.fig");
#endif
// Exit.
std::fprintf(stderr," - Exit.\n");
return 0;
}
/*
#
# File : spherical_function3d.cpp
# ( C++ source file )
#
# Description : An example that shows how to build custom 3D objects in CImg.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
/*---------------------------
Main procedure
--------------------------*/
int main() {
CImgList<unsigned char> object_colors;
CImgList<float> object_opacities;
// Define a 3D centered box.
CImg<float> object_vertices = CImg<float>(3,8,1,1, // Define the 8 vertices of the cube
-1,-1,-1, // (x0,y0,z0)
1,-1,-1, // (x1,y1,z1)
1,1,-1, // ...
-1,1,-1,
-1,-1,1,
1,-1,1,
1,1,1, // (x6,y6,z6)
-1,1,1).transpose(); // (x7,y7,z7)
CImgList<unsigned int> object_primitives(12,1,2,1,1, // Define the 12 segments of the cube
0,1, 1,2, 2,3, 3,0,
4,5, 5,6, 6,7, 7,4,
0,4, 1,5, 2,6, 3,7);
object_colors.insert(object_primitives.size(),CImg<unsigned char>::vector(32,64,255));
object_opacities.insert(object_primitives.size(),CImg<float>::vector(0.3f));
// Define the spherical function's vertices.
CImgList<float> spherical_vertices;
const float a = 1;
const unsigned int na = 132, nb = 132;
for (unsigned int v = 0; v<na; ++v)
for (unsigned int u = 0; u<nb; ++u) {
const float
alpha = (float)(u*2*cimg::PI/nb),
beta = (float)(-cimg::PI/2 + v*cimg::PI/na),
x = (float)((a*std::cos(beta))*std::cos(alpha)),
y = (float)((a*std::cos(beta))*std::sin(alpha)),
z = (float)(a*std::sin(beta)),
altitude = cimg::abs(1 + 0.8f*std::cos(3*alpha)*std::sin(4*beta));
spherical_vertices.insert(CImg<float>::vector(altitude*x,altitude*y,altitude*z));
}
// Define the spherical function's mesh.
CImgList<unsigned int> spherical_primitives;
for (unsigned int vv = 0; vv<na - 1; ++vv)
for (unsigned int uu = 0; uu<nb; ++uu) {
const int nv = (vv + 1)%na, nu = (uu + 1)%nb;
spherical_primitives.insert(CImg<unsigned int>::vector(nb*vv + nu,nb*nv + uu,nb*vv + uu));
spherical_primitives.insert(CImg<unsigned int>::vector(nb*vv + nu,nb*nv + nu,nb*nv + uu));
object_colors.insert(CImg<>::vector(0,255,255));
object_colors.insert(CImg<>::vector(100,200,255));
object_opacities.insert(2,CImg<>::vector(1));
}
// Merge 3D objects together.
object_vertices.append_object3d(object_primitives,spherical_vertices>'x',spherical_primitives);
char title[4096] = { 0 };
std::sprintf(title,"3D Spherical Function (%u vertices, %u primitives)",
object_vertices.width(),object_primitives.size());
CImgDisplay disp(640,480,title,0);
CImg<unsigned char>(disp.width(),disp.height(),1,3,220).
display_object3d(disp,object_vertices,object_primitives,object_colors,object_opacities,true,4,3,false,
500,0,0,-5000,0.1f,1.5f);
return 0;
}
/*
#
# File : tetris.cpp
# ( C++ source file )
#
# Description : A CImg version of the famous Tetris game.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "img/tetris.h"
#include "CImg.h"
using namespace cimg_library;
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read command line argument (if any)
cimg_usage("An implementation of the well known 'Tetris' game with CImg.");
unsigned int
blocdim = cimg_option("-blocdim",18,"Sprite bloc size"),
speed = cimg_option("-speed",20,"Initial speed"),
level = cimg_option("-level",0,"Level");
const char *geometry = cimg_option("-g","12x20","Size of the board");
unsigned int bwidth = 12,bheight = 20;
std::sscanf(geometry,"%u%*c%u",&bwidth,&bheight);
const CImg<unsigned char> dlogo = CImg<unsigned char>(data_logo,128,96,1,3,true);
if (cimg::dialog("CImg Tetris",
"Welcome to the CImg version of Tetris.\n"
"( by David Tschumperle )\n\n"
"Press 'Start' when you are ready to play !","Start","Quit",0,0,0,0,dlogo,true)) std::exit(0);
// Create sprite, background graphics and initial board data
const CImgList<unsigned char> pieces = CImgList<unsigned char>().
insert(CImg<unsigned char>(3,2).fill(1,1,1,0,0,1)).
insert(CImg<unsigned char>(3,2).fill(2,2,2,2,0,0)).
insert(CImg<unsigned char>(2,2).fill(3,3,3,3)).
insert(CImg<unsigned char>(4,1).fill(4,4,4,4)).
insert(CImg<unsigned char>(3,2).fill(5,5,0,0,5,5)).
insert(CImg<unsigned char>(3,2).fill(0,6,6,6,6,0)).
insert(CImg<unsigned char>(3,3).fill(0,7,0,7,7,7,0,7,0)).
insert(CImg<unsigned char>(2,1).fill(8,8)).
insert(CImg<unsigned char>(3,2).fill(9,9,9,0,9,0)).
insert(CImg<unsigned char>(2,2).fill(10,10,0,10)).
insert(CImg<unsigned char>(3,1).fill(11,11,11));
CImg<unsigned char> board(bwidth,bheight,1,1,0), background(board.width()*blocdim,board.height()*blocdim,1,3,0);
(background.noise(30).draw_plasma().noise(30).deriche(5,0,'y').shift(0,-background.height()/2,0,0,2).
deriche(5,0,'y'))/=1.5f;
if (level) (board.get_shared_rows(board.height() - level,board.height() - 1,0,0).noise(100))%=pieces.size() + 1;
// Create a set of small gradient-colored blocs used to draw the pieces.
CImgList<unsigned char> blocs(pieces.size(),blocdim,blocdim,1,3);
cimglist_for(blocs,l) {
CImg<unsigned char> color = CImg<unsigned char>(3,1,1,1,128).noise(127,1).cut(120,255);
float val;
cimg_forXYC(blocs[l],x,y,k)
blocs[l](x,y,k) = (unsigned char)((val=(color[k]*0.7f*(x + y + 5)/blocdim))>255?255:val);
blocs[l].draw_line(0,0,0,blocdim - 1,(color>>1).data()).
draw_line(0,blocdim - 1,blocdim - 1,blocdim - 1,(color>>1).data());
color = (CImg<unsigned int>(color)*=2).cut(0,255);
blocs[l].draw_line(0,0,(int)blocdim - 1,0,color.data()).
draw_line(blocdim - 1,0,blocdim - 1,blocdim - 1,color.data());
}
// Initialize window display and enter the main event loop
CImgDisplay disp(background,"CImg Tetris",0,false,true);
disp.move((CImgDisplay::screen_width() - disp.width())/2,
(CImgDisplay::screen_height() - disp.height())/2).hide_mouse();
const unsigned char white[3]={ 255, 255, 255 };
CImg<unsigned char> visu, nboard, piece, next, next_mask;
int cx = -1, cy = -1, cn = -1, nn = rand()%pieces.size(), time = 0, score = 0;
bool gameover = false, pause = false;
while (!gameover && !disp.is_closed() && !disp.is_keyESC() && !disp.is_keyQ()) {
if (!pause) {
// Draw the board on the display window.
nboard = board; visu = background;
if (cx>=0 && cy>=0)
cimg_forXY(piece,x,y) if (piece(x,y)) nboard(cx - piece.width()/2 + x,cy - piece.height()/2 + y)=piece(x,y);
cimg_forXY(board,xx,yy) if (nboard(xx,yy)) visu.draw_image(xx*blocdim,yy*blocdim,blocs[nboard(xx,yy) - 1]);
visu.draw_text(5,5,"Lines : %d",white,0,1,13,score,nn).draw_text(visu.width() - 75,5,"Next :",white,0,1,13);
if (next) visu.draw_image(visu.width() - next.width() - 2,10 - next.height()/2,next,next_mask).
display(disp.wait(20));
if (cn<0) {
// Introduce a new piece on the board (if necessary) and create representation of the next piece
board = nboard;
piece = pieces[cn=nn];
nn = rand()%pieces.size();
cx = board.width()/2;
cy = piece.height()/2;
next = CImg<unsigned char>(pieces[nn].width()*blocdim,pieces[nn].height()*blocdim,1,3,0);
cimg_forXY(pieces[nn],xi,yi)
if (pieces[nn](xi,yi)) next.draw_image(xi*blocdim,yi*blocdim,blocs[pieces[nn](xi,yi) - 1]);
next_mask = next.resize(-50,-50).get_norm().threshold(0);
// Detect tetris lines and do line removal animation if found.
cimg_forY(board,yyy) {
int Y = yyy*blocdim, line = 1;
cimg_forX(board,xxx) if (!board(xxx,yyy)) line=0;
if (line) {
board.draw_image(0,1,board.get_crop(0,0,board.width() - 1,yyy - 1));
if (!((++score)%1) && speed>1) --speed;
for (float alpha=0; alpha<=1; alpha+=0.07f)
CImg<unsigned char>(visu).draw_image(0,Y,background.get_crop(0,Y,visu.width() - 1,
Y + blocdim - 1),alpha).
display(disp.wait(20));
visu.draw_image(0,Y,background.get_crop(0,Y,visu.width() - 1,Y + blocdim - 1));
}
}
}
// Handle motion & collisions
const int ox = cx, oy = cy;
bool rotated = false, collision;
switch (disp.key()) {
case cimg::keyP: pause = true; break;
case cimg::keyARROWUP: piece.rotate(90); rotated = true; disp.set_key(); break;
case cimg::keyARROWLEFT: --cx; disp.set_key(); break;
case cimg::keyARROWRIGHT: ++cx; disp.set_key(); break;
}
if (cx - piece.width()/2<0) cx = piece.width()/2;
if (cy - piece.height()/2<0) cy = piece.height()/2;
if (cx + (piece.width() - 1)/2>=board.width()) cx = board.width() - 1 - (piece.width() - 1)/2;
// Detect collision along the X axis
collision = false;
cimg_forXY(piece,i,j)
if (piece(i,j) && board(cx - piece.width()/2 + i,cy - piece.height()/2 + j)) collision = true;
if (collision) { cx=ox; if (rotated) piece.rotate(-90); }
if (disp.key()==cimg::keyARROWDOWN || !((++time)%speed)) { ++cy; disp.set_key(); }
// Detect collisiong along the Y axis
collision = false;
cimg_forXY(piece,ii,jj)
if (piece(ii,jj) && (cy - piece.height()/2 + jj>=board.height() ||
board(cx - piece.width()/2 + ii,cy - piece.height()/2 + jj))) collision = true;
if (collision || cy + (piece.height() - 1)/2>=board.height()) { cy = oy; cn = -1; }
if (collision && cy==piece.height()/2) gameover = true;
} else {
// If game is paused (key 'P'), do a little text animation
float A = 0, B = 0;
CImg<float> pauselogo = CImg<unsigned char>().draw_text(0,0,"Game Paused\nPress a key",white);
disp.set_key(); while (!disp.is_closed() && !disp.key()) {
const CImg<float> pauserotated = pauselogo.get_rotate((float)(30*std::sin(A)),1,0).
resize((int)(-150 - 80*std::sin(B)),(int)(-150 - 80*std::sin(B)));
A+=0.08f; B+=0.043f;
CImg<unsigned char>(background).
draw_image((background.width() - pauserotated.width())/2,
(background.height() - pauserotated.height())/2,
pauserotated.get_resize(-100,-100,1,3,2),pauserotated,1,255).display(disp.wait(20));
if (disp.is_resized()) disp.resize();
}
disp.set_key();
pause = false;
}
background.shift(0,-20/(int)speed,0,0,2);
if (disp.is_resized()) disp.resize();
}
// End of game reached, display the score and do a 'game over' animation
cimg_forXYC(visu,x,y,k) if (x%2 || y%2) visu(x,y,k) = 0;
visu.display(disp);
char tmp[1024];
std::sprintf(tmp,"Game Over !\n\nYour score : %d",score);
cimg::dialog("CImg Tetris",tmp,"Quit");
return 0;
}
/*
#
# File : tron.cpp
# ( C++ source file )
#
# Description : A clone of the famous (and very simple) Tron game.
# This file is a part of the CImg Library project.
# ( http://cimg.eu )
#
# Copyright : David Tschumperlé
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#include "CImg.h"
using namespace cimg_library;
// Main procedure
//----------------
int main(int argc, char **argv) {
// Print usage, help and retrieve command line options
//-----------------------------------------------------
cimg_usage("A very simple Tron game, using the CImg Library");
cimg_help("--- Quick help ----------------------------\n"
" Player 1 (blue) :\n"
" Use keys 'Z' (up), 'S' (down), 'Q' (left)\n"
" and 'D' (right) to control your player.\n"
" Right 'CONTROL' key enables turbospeed\n"
" Player 2 (red) : \n"
" Use arrow keys to control your player.\n"
" 'TAB' key enables turbospeed.\n"
"-------------------------------------------");
const char *geom = cimg_option("-g","300x300","Size of the game board");
const int delay = cimg_option("-s",10,"Game speed (lower value means faster)");
const bool twoplayers = !cimg_option("-1",false,"One player only");
const int zoom = cimg_option("-z",1,"Zoom factor");
const bool full = cimg_option("-f",false,"Fullscreen mode");
unsigned int W = 400, H = 400;
std::sscanf(geom,"%u%*c%u",&W,&H);
// Define game colors and variables
//----------------------------------
const unsigned char blue[] = { 128,200,255}, red[] = { 255,0,0 }, white[] = { 255,255,255 };
int score1 = 0, score2 = 0, round_over = 0, ix1 = -1, iy1 = -1, x1 = 0, y1 = 0, u1 = 0, v1 = 0,
ix2 = -1, iy2 = -1, x2 = 0, y2 = 0, u2 = 0, v2 = 0;
bool start_round = true, turbo1 = false, turbo2 = false;
// Create background image
//--------------------------
CImg<unsigned char> background, img;
background.assign(64,64,1,3,0).noise(60).draw_plasma().resize(W,H).blur(2).normalize(0,128).
draw_rectangle(0,0,W-1,H-1,white,1.0f,~0U);
// Open display window
//---------------------
CImgDisplay disp(background,"* CImg-Tron *");
if (zoom>1) disp.resize(-100*zoom,-100*zoom);
if (full) disp.toggle_fullscreen().display(background);
// Start main game loop
//----------------------
while (!disp.is_closed() && !disp.is_keyESC()) {
// Init new game round if necessary
//----------------------------------
if (start_round) {
// Init game variables
round_over = 0;
ix1 = -1; iy1 = -1; x1 = 10; y1 = 10; u1 = 1; v1 = 0; turbo1 = false;
ix2 = -1; iy2 = -1; x2 = W - 11; y2 = H - 11; u2 = -1; v2 = 0; turbo2 = false;
img = background;
start_round = false;
// Display a simple pre-round page
CImg<unsigned char> logo, pressakey;
logo.draw_text(0,0," CImg-Tron ",white,0,1,33).resize(-100,-100,1,3);
CImg<unsigned char> tmp = (+background).draw_image((W - logo.width())/2,(H - logo.height())/2 - 20,
logo,logo.get_channel(0).dilate(6).normalize(0,1)).
draw_text(W/2 - 60,H/2 + 10,"Blue ( %u )",blue,0,1,13,score1).
draw_text(W/2 + 10,H/2 + 10,"Red ( %u )",red,0,1,13,score2);
pressakey.draw_text(0,0,"* Press a key to start round *",white);
for (float i = 0; i<1; i+=0.05f) ((+tmp)*=i).display(disp.wait(20));
disp.flush();
for (unsigned long t = 0; !disp.key() && !disp.is_closed(); ++t) {
if (!(t%10)) { if (t%20) disp.display(tmp);
else disp.display((+tmp).draw_image(W/2 - 70,H/2 + 50,pressakey,pressakey,1,255)); }
if (disp.wait(20).is_resized()) disp.resize(disp);
}
if (disp.is_keyESC()) disp.flush();
}
// Test collision between players and borders
if (x1<0 || x1>=img.width() || y1<0 || y1>=img.height() ||
img(x1,y1,0)!=background(x1,y1,0) ||
img(x1,y1,1)!=background(x1,y1,1) ||
img(x1,y1,2)!=background(x1,y1,2) ||
((ix1>=0 || iy1>=0) && (img(ix1,iy1,0)!=background(ix1,iy1,0) || // Collision test for turbo mode
img(ix1,iy1,1)!=background(ix1,iy1,1) ||
img(ix1,iy1,2)!=background(ix1,iy1,2)))) { round_over=1; score2++; }
if (twoplayers) {
if (x2<0 || x2>=img.width() || y2<0 || y2>=img.height() ||
img(x2,y2,0)!=background(x2,y2,0) ||
img(x2,y2,1)!=background(x2,y2,1) ||
img(x2,y2,2)!=background(x2,y2,2) ||
((ix2>=0 || iy2>=0) && (img(ix2,iy2,0)!=background(ix2,iy2,0) || // Collision test for turbo mode
img(ix2,iy2,1)!=background(ix2,iy2,1) ||
img(ix2,iy2,2)!=background(ix2,iy2,2)))) { round_over=2; score1++; }
}
// Draw new players positions
img.draw_point(x1,y1,blue);
if (ix1>=0 && iy1>=0) img.draw_point(ix1,iy1,blue);
if (twoplayers) {
img.draw_point(x2,y2,red);
if (ix2>=0 && iy2>=0) img.draw_point(ix2,iy2,red);
}
if (disp.is_resized()) disp.resize(disp);
img.display(disp);
// Update players positions
x1+=u1; y1+=v1;
if (turbo1) { ix1 = x1; iy1 = y1; x1+=u1; y1+=v1; } else { ix1 = iy1 = -1; }
if (twoplayers) {
x2+=u2; y2+=v2;
if (turbo2) { ix2 = x2; iy2 = y2; x2+=u2; y2+=v2; } else { ix2 = iy2 = -1; }
}
// Test keyboard events
int nu1 = u1, nv1 = v1, nu2 = u2, nv2 = v2;
if (disp.is_keyARROWLEFT()) { nu1 = -1; nv1 = 0; }
if (disp.is_keyARROWRIGHT()) { nu1 = 1; nv1 = 0; }
if (disp.is_keyARROWUP()) { nu1 = 0; nv1 = -1; }
if (disp.is_keyARROWDOWN()) { nu1 = 0; nv1 = 1; }
turbo1 = disp.is_keyCTRLRIGHT();
if (twoplayers) {
if (disp.is_keyQ()) { nu2 = -1; nv2 = 0; }
if (disp.is_keyD()) { nu2 = 1; nv2 = 0; }
if (disp.is_keyZ()) { nu2 = 0; nv2 = -1; }
if (disp.is_keyS()) { nu2 = 0; nv2 = 1; }
turbo2 = disp.is_keyTAB();
}
if (nu1!=-u1 && nv1!=-v1) { u1 = nu1; v1 = nv1; }
if (nu2!=-u2 && nv2!=-v2) { u2 = nu2; v2 = nv2; }
// Check if round is over.
if (round_over) {
const int xc = round_over==1?x1:x2, yc = round_over==1?y1:y2;
for (int r=0; r<50; r+=3) img.draw_circle(xc,yc,r,round_over==1?blue:red,r/300.0f).display(disp.wait(20));
for (int rr=0; rr<50; rr+=3)
((+img)*=(50 - rr)/50.0f).draw_circle(xc,yc,(50 + rr),round_over==1?blue:red,1/6.0f).display(disp.wait(20));
start_round = true;
}
// Wait a small amount of time
disp.wait(delay);
}
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment