diff --git a/CMakeLists.txt b/CMakeLists.txt index 5de286f35d..aee245bbfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,8 @@ option(BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE "Enable Dynamic Image extension, tests option(BOOST_GIL_ENABLE_EXT_IO "Enable IO extension, tests and examples (require libjpeg, libpng, libtiff)" ON) option(BOOST_GIL_ENABLE_EXT_NUMERIC "Enable Numeric extension, tests and examples" ON) option(BOOST_GIL_ENABLE_EXT_TOOLBOX "Enable Toolbox extension, tests and examples" ON) +option(BOOST_GIL_ENABLE_EXT_RASTERIZATION "Enable Rasterization extension and tests" ON) +option(BOOST_GIL_ENABLE_EXT_IMAGE_PROCESSING "Enable Image Processing extension (!) and tests" ON) option(BOOST_GIL_USE_CONAN "Use Conan to install dependencies" OFF) option(BOOST_GIL_USE_CLANG_TIDY "Set CMAKE_CXX_CLANG_TIDY property on targets to enable clang-tidy linting" OFF) set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard version to use (default is 11)") diff --git a/example/anisotropic_diffusion.cpp b/example/anisotropic_diffusion.cpp index c96533647c..04c95406bd 100644 --- a/example/anisotropic_diffusion.cpp +++ b/example/anisotropic_diffusion.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include "boost/gil/extension/image_processing/diffusion.hpp" #include #include #include diff --git a/example/histogram_equalization.md b/example/histogram_equalization.md index c3dcd57832..eb71568dac 100644 --- a/example/histogram_equalization.md +++ b/example/histogram_equalization.md @@ -7,6 +7,52 @@ Histogram equalization capabilities in GIL are demonstrated by the program `hist The program doesn't take any argument on the command line. +Hough line transform solves the equation of a line in reverse, but in *polar coordinates*! The implementation will make each pixel vote on all possible lines it could be part of, limited by input Hough parameters. + +A line in polar coordinates is represented by normal to it in polar coordinates, as shown in example here +https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html + +Since real line is the diagonal throughout the image, the angle of normal to it will 45 degrees. (1s represent real line, 5s represent normal to it). + +``` +1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0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 +``` + +It is obvious that the angle for the expected Hough transform is 45 degrees (angle between 5s and bottom 0s). Now we +need to find the length of 5s. Since 5s, 1s and bottom 0s form a right triangle, we know that bottom 0s are 32 in length +and is a hypotenuse! Using trivial trigonometry we know that the length we are searching for is 32 * cos(45). + `histogram_equalization` expects to find an image called `test_adaptive.png` in the current directory, and produces an image in return, where the equalization have been applied: `histogram_gray_equalized.png`. ## Specific requirements diff --git a/example/hough_transform_line.cpp b/example/hough_transform_line.cpp index 75c9e611b6..d67fff5b59 100644 --- a/example/hough_transform_line.cpp +++ b/example/hough_transform_line.cpp @@ -25,7 +25,7 @@ namespace gil = boost::gil; int main() { - std::ptrdiff_t size = 32; + const std::ptrdiff_t size = 32; gil::gray16_image_t input_image(size, size); auto input_view = gil::view(input_image); @@ -52,7 +52,7 @@ int main() double _5_degrees = gil::detail::pi / 36; auto theta_parameter = gil::make_theta_parameter(_45_degrees, _5_degrees, input_view.dimensions()); - auto expected_radius = static_cast(std::round(std::cos(_45_degrees) * size)); + auto expected_radius = static_cast(std::floor(std::cos(_45_degrees) * size)); auto radius_parameter = gil::hough_parameter::from_step_size(expected_radius, 7, 1); gil::gray32_image_t accumulator_array_image(theta_parameter.step_count, @@ -70,6 +70,9 @@ int main() theta_parameter.start_point + theta_index * theta_parameter.step_size; std::ptrdiff_t current_radius = radius_parameter.start_point + radius_parameter.step_size * radius_index; + if (current_theta == _45_degrees && current_radius == expected_radius) { + std::cout << "* "; + } std::cout << "theta: " << current_theta << " radius: " << current_radius << " accumulated value: " << accumulator_array(theta_index, radius_index)[0] << '\n'; diff --git a/include/boost/gil.hpp b/include/boost/gil.hpp index 087c9fe8de..9bfba80240 100644 --- a/include/boost/gil.hpp +++ b/include/boost/gil.hpp @@ -39,9 +39,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -49,14 +49,14 @@ #include #include #include -#include +#include "boost/gil/extension/image_processing/diffusion.hpp" #include #include #include #include #include -#include -#include +#include "boost/gil/extension/image_processing/hough_parameter.hpp" +#include "boost/gil/extension/image_processing/hough_transform.hpp" #include #include #include diff --git a/include/boost/gil/image_processing/diffusion.hpp b/include/boost/gil/extension/image_processing/diffusion.hpp similarity index 99% rename from include/boost/gil/image_processing/diffusion.hpp rename to include/boost/gil/extension/image_processing/diffusion.hpp index fb1c86a4d3..d40c875c64 100644 --- a/include/boost/gil/image_processing/diffusion.hpp +++ b/include/boost/gil/extension/image_processing/diffusion.hpp @@ -10,7 +10,7 @@ #ifndef BOOST_GIL_IMAGE_PROCESSING_DIFFUSION_HPP #define BOOST_GIL_IMAGE_PROCESSING_DIFFUSION_HPP -#include "boost/gil/detail/math.hpp" +#include #include #include #include diff --git a/include/boost/gil/image_processing/hough_parameter.hpp b/include/boost/gil/extension/image_processing/hough_parameter.hpp similarity index 99% rename from include/boost/gil/image_processing/hough_parameter.hpp rename to include/boost/gil/extension/image_processing/hough_parameter.hpp index 97fcd8cde5..66b031346a 100644 --- a/include/boost/gil/image_processing/hough_parameter.hpp +++ b/include/boost/gil/extension/image_processing/hough_parameter.hpp @@ -9,7 +9,7 @@ #ifndef BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP #define BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP -#include +#include "boost/gil/point.hpp" #include #include diff --git a/include/boost/gil/image_processing/hough_transform.hpp b/include/boost/gil/extension/image_processing/hough_transform.hpp similarity index 98% rename from include/boost/gil/image_processing/hough_transform.hpp rename to include/boost/gil/extension/image_processing/hough_transform.hpp index 982c28c1f9..39eb8dc1da 100644 --- a/include/boost/gil/image_processing/hough_transform.hpp +++ b/include/boost/gil/extension/image_processing/hough_transform.hpp @@ -10,8 +10,8 @@ #define BOOST_GIL_IMAGE_PROCESSING_HOUGH_TRANSFORM_HPP #include -#include -#include +#include +#include #include #include #include diff --git a/include/boost/gil/rasterization/circle.hpp b/include/boost/gil/extension/rasterization/circle.hpp similarity index 100% rename from include/boost/gil/rasterization/circle.hpp rename to include/boost/gil/extension/rasterization/circle.hpp diff --git a/include/boost/gil/rasterization/ellipse.hpp b/include/boost/gil/extension/rasterization/ellipse.hpp similarity index 100% rename from include/boost/gil/rasterization/ellipse.hpp rename to include/boost/gil/extension/rasterization/ellipse.hpp diff --git a/include/boost/gil/rasterization/line.hpp b/include/boost/gil/extension/rasterization/line.hpp similarity index 100% rename from include/boost/gil/rasterization/line.hpp rename to include/boost/gil/extension/rasterization/line.hpp diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 2c812d014b..761632decd 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -39,5 +39,4 @@ add_subdirectory(image) add_subdirectory(image_view) add_subdirectory(algorithm) add_subdirectory(image_processing) -add_subdirectory(histogram) -add_subdirectory(rasterization) +add_subdirectory(histogram) \ No newline at end of file diff --git a/test/core/Jamfile b/test/core/Jamfile index bc1e5f55d7..9305b8762c 100644 --- a/test/core/Jamfile +++ b/test/core/Jamfile @@ -33,4 +33,3 @@ build-project image_view ; build-project algorithm ; build-project image_processing ; build-project histogram ; -build-project rasterization ; diff --git a/test/core/image_processing/CMakeLists.txt b/test/core/image_processing/CMakeLists.txt index 680c41047c..a2a8e08fbc 100644 --- a/test/core/image_processing/CMakeLists.txt +++ b/test/core/image_processing/CMakeLists.txt @@ -19,10 +19,6 @@ foreach(_name box_filter median_filter sobel_scharr - anisotropic_diffusion - hough_parameter - hough_line_transform - hough_circle_transform convolve convolve_2d convolve_cols diff --git a/test/core/image_processing/Jamfile b/test/core/image_processing/Jamfile index 6f4d77f76c..562860e811 100644 --- a/test/core/image_processing/Jamfile +++ b/test/core/image_processing/Jamfile @@ -21,9 +21,6 @@ run hessian.cpp ; run sobel_scharr.cpp ; run box_filter.cpp ; run median_filter.cpp ; -run anisotropic_diffusion.cpp ; -run hough_line_transform.cpp ; -run hough_circle_transform.cpp ; run morphology.cpp ; run convolve.cpp ; run convolve_2d.cpp ; diff --git a/test/extension/CMakeLists.txt b/test/extension/CMakeLists.txt index 9f7883066f..df1cfd72b3 100644 --- a/test/extension/CMakeLists.txt +++ b/test/extension/CMakeLists.txt @@ -5,6 +5,14 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # +if(BOOST_GIL_ENABLE_EXT_RASTERIZATION) + add_subdirectory(rasterization) +endif() + +if(BOOST_GIL_ENABLE_EXT_IMAGE_PROCESSING) + add_subdirectory(image_processing) +endif() + if(BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE) add_subdirectory(dynamic_image) endif() diff --git a/test/extension/Jamfile b/test/extension/Jamfile index 5754513279..8c7790d2e2 100644 --- a/test/extension/Jamfile +++ b/test/extension/Jamfile @@ -11,3 +11,5 @@ build-project histogram ; build-project numeric ; build-project toolbox ; build-project io ; +build-project image_processing ; +build-project rasterization ; diff --git a/test/extension/image_processing/CMakeLists.txt b/test/extension/image_processing/CMakeLists.txt new file mode 100644 index 0000000000..62e6f79595 --- /dev/null +++ b/test/extension/image_processing/CMakeLists.txt @@ -0,0 +1,22 @@ +foreach(_name + anisotropic_diffusion + hough_circle_transform + hough_line_transform + hough_parameter) + set(_test t_ext_image_processing_${_name}) + set(_target test_ext_image_processing_${_name}) + + add_executable(${_target} "") + target_sources(${_target} PRIVATE ${_name}.cpp) + target_link_libraries(${_target} + PRIVATE + gil_compile_options + gil_include_directories + gil_dependencies) + target_compile_definitions(${_target} PRIVATE BOOST_GIL_USE_CONCEPT_CHECK) + add_test(NAME ${_test} COMMAND ${_target}) + + unset(_name) + unset(_target) + unset(_test) +endforeach() diff --git a/test/extension/image_processing/Jamfile b/test/extension/image_processing/Jamfile new file mode 100644 index 0000000000..6ab73640d1 --- /dev/null +++ b/test/extension/image_processing/Jamfile @@ -0,0 +1,14 @@ +# Boost.GIL (Generic Image Library) - tests +# +# Copyright 2020 Olzhas Zhumabek +# +# Use, modification and distribution are subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +import testing ; + +run anisotropic_diffusion.cpp ; +run hough_circle_transform.cpp ; +run hough_line_transform.cpp ; +run hough_parameter.cpp ; \ No newline at end of file diff --git a/test/core/image_processing/anisotropic_diffusion.cpp b/test/extension/image_processing/anisotropic_diffusion.cpp similarity index 98% rename from test/core/image_processing/anisotropic_diffusion.cpp rename to test/extension/image_processing/anisotropic_diffusion.cpp index 58a5c9d6ce..302b43de58 100644 --- a/test/core/image_processing/anisotropic_diffusion.cpp +++ b/test/extension/image_processing/anisotropic_diffusion.cpp @@ -5,11 +5,11 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -#include "../test_fixture.hpp" -#include "boost/gil/algorithm.hpp" +#include +#include #include #include -#include +#include #include #include #include diff --git a/test/core/image_processing/hough_circle_transform.cpp b/test/extension/image_processing/hough_circle_transform.cpp similarity index 97% rename from test/core/image_processing/hough_circle_transform.cpp rename to test/extension/image_processing/hough_circle_transform.cpp index 9b0a3563da..67156e51a1 100644 --- a/test/core/image_processing/hough_circle_transform.cpp +++ b/test/extension/image_processing/hough_circle_transform.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/test/core/image_processing/hough_line_transform.cpp b/test/extension/image_processing/hough_line_transform.cpp similarity index 96% rename from test/core/image_processing/hough_line_transform.cpp rename to test/extension/image_processing/hough_line_transform.cpp index f0ed992fa3..3be4194261 100644 --- a/test/core/image_processing/hough_line_transform.cpp +++ b/test/extension/image_processing/hough_line_transform.cpp @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include #include diff --git a/test/core/image_processing/hough_parameter.cpp b/test/extension/image_processing/hough_parameter.cpp similarity index 97% rename from test/core/image_processing/hough_parameter.cpp rename to test/extension/image_processing/hough_parameter.cpp index 8d1c7b4452..9fd4b4a95f 100644 --- a/test/core/image_processing/hough_parameter.cpp +++ b/test/extension/image_processing/hough_parameter.cpp @@ -7,7 +7,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // #include -#include +#include namespace gil = boost::gil; diff --git a/test/core/rasterization/CMakeLists.txt b/test/extension/rasterization/CMakeLists.txt similarity index 100% rename from test/core/rasterization/CMakeLists.txt rename to test/extension/rasterization/CMakeLists.txt diff --git a/test/core/rasterization/Jamfile b/test/extension/rasterization/Jamfile similarity index 100% rename from test/core/rasterization/Jamfile rename to test/extension/rasterization/Jamfile diff --git a/test/core/rasterization/circle.cpp b/test/extension/rasterization/circle.cpp similarity index 98% rename from test/core/rasterization/circle.cpp rename to test/extension/rasterization/circle.cpp index b4c85c7da4..33af44c491 100644 --- a/test/core/rasterization/circle.cpp +++ b/test/extension/rasterization/circle.cpp @@ -8,7 +8,7 @@ // #include -#include +#include "boost/gil/extension/rasterization/circle.hpp" #include #include diff --git a/test/core/rasterization/ellipse.cpp b/test/extension/rasterization/ellipse.cpp similarity index 99% rename from test/core/rasterization/ellipse.cpp rename to test/extension/rasterization/ellipse.cpp index 58b5f43458..495e40400a 100644 --- a/test/core/rasterization/ellipse.cpp +++ b/test/extension/rasterization/ellipse.cpp @@ -6,7 +6,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // #include -#include +#include "boost/gil.hpp" #include #include #include diff --git a/test/core/rasterization/line.cpp b/test/extension/rasterization/line.cpp similarity index 98% rename from test/core/rasterization/line.cpp rename to test/extension/rasterization/line.cpp index 42e3bf7469..92986edbf4 100644 --- a/test/core/rasterization/line.cpp +++ b/test/extension/rasterization/line.cpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include "boost/gil/point.hpp" +#include "boost/gil/extension/rasterization/line.hpp" #include #include