Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Move GSoC 2020 features to extension #673

Merged
merged 8 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
2 changes: 1 addition & 1 deletion example/anisotropic_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <boost/gil/algorithm.hpp>
#include <boost/gil/extension/io/png.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/image_processing/diffusion.hpp>
#include "boost/gil/extension/image_processing/diffusion.hpp"
#include <boost/gil/image_view.hpp>
#include <boost/gil/io/typedefs.hpp>
#include <boost/gil/typedefs.hpp>
Expand Down
46 changes: 46 additions & 0 deletions example/histogram_equalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
Expand Down
7 changes: 5 additions & 2 deletions example/hough_transform_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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::ptrdiff_t>(std::round(std::cos(_45_degrees) * size));
auto expected_radius = static_cast<std::ptrdiff_t>(std::floor(std::cos(_45_degrees) * size));
auto radius_parameter =
gil::hough_parameter<std::ptrdiff_t>::from_step_size(expected_radius, 7, 1);
gil::gray32_image_t accumulator_array_image(theta_parameter.step_count,
Expand All @@ -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';
Expand Down
12 changes: 6 additions & 6 deletions include/boost/gil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@
#include <boost/gil/position_iterator.hpp>
#include <boost/gil/premultiply.hpp>
#include <boost/gil/promote_integral.hpp>
#include <boost/gil/rasterization/circle.hpp>
#include <boost/gil/rasterization/ellipse.hpp>
#include <boost/gil/rasterization/line.hpp>
#include <boost/gil/extension/rasterization/circle.hpp>
#include <boost/gil/extension/rasterization/ellipse.hpp>
#include <boost/gil/extension/rasterization/line.hpp>
#include <boost/gil/rgb.hpp>
#include <boost/gil/rgba.hpp>
#include <boost/gil/step_iterator.hpp>
#include <boost/gil/typedefs.hpp>
#include <boost/gil/utilities.hpp>
#include <boost/gil/virtual_locator.hpp>
#include <boost/gil/image_processing/adaptive_histogram_equalization.hpp>
#include <boost/gil/image_processing/diffusion.hpp>
#include "boost/gil/extension/image_processing/diffusion.hpp"
#include <boost/gil/image_processing/filter.hpp>
#include <boost/gil/image_processing/harris.hpp>
#include <boost/gil/image_processing/hessian.hpp>
#include <boost/gil/image_processing/histogram_equalization.hpp>
#include <boost/gil/image_processing/histogram_matching.hpp>
#include <boost/gil/image_processing/hough_parameter.hpp>
#include <boost/gil/image_processing/hough_transform.hpp>
#include "boost/gil/extension/image_processing/hough_parameter.hpp"
#include "boost/gil/extension/image_processing/hough_transform.hpp"
#include <boost/gil/image_processing/morphology.hpp>
#include <boost/gil/image_processing/numeric.hpp>
#include <boost/gil/image_processing/scaling.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/gil/detail/math.hpp>
#include <boost/gil/algorithm.hpp>
#include <boost/gil/color_base_algorithm.hpp>
#include <boost/gil/image.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP
#define BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP

#include <boost/gil/point.hpp>
#include "boost/gil/point.hpp"
#include <cmath>
#include <cstddef>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define BOOST_GIL_IMAGE_PROCESSING_HOUGH_TRANSFORM_HPP

#include <algorithm>
#include <boost/gil/image_processing/hough_parameter.hpp>
#include <boost/gil/rasterization/circle.hpp>
#include <boost/gil/extension/image_processing/hough_parameter.hpp>
#include <boost/gil/extension/rasterization/circle.hpp>
#include <cmath>
#include <cstddef>
#include <iterator>
Expand Down
3 changes: 1 addition & 2 deletions test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion test/core/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ build-project image_view ;
build-project algorithm ;
build-project image_processing ;
build-project histogram ;
build-project rasterization ;
4 changes: 0 additions & 4 deletions test/core/image_processing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/core/image_processing/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
8 changes: 8 additions & 0 deletions test/extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions test/extension/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ build-project histogram ;
build-project numeric ;
build-project toolbox ;
build-project io ;
build-project image_processing ;
build-project rasterization ;
22 changes: 22 additions & 0 deletions test/extension/image_processing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions test/extension/image_processing/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Boost.GIL (Generic Image Library) - tests
#
# Copyright 2020 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
#
# 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 ;
Original file line number Diff line number Diff line change
Expand Up @@ -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 <core/test_fixture.hpp>
#include <boost/gil/algorithm.hpp>
#include <boost/gil/color_base_algorithm.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/image_processing/diffusion.hpp>
#include <boost/gil/extension/image_processing/diffusion.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/pixel.hpp>
#include <boost/gil/typedefs.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <boost/core/lightweight_test.hpp>

#include <boost/gil/image.hpp>
#include <boost/gil/image_processing/hough_transform.hpp>
#include <boost/gil/extension/image_processing/hough_transform.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/typedefs.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <boost/core/lightweight_test.hpp>
#include <boost/gil/detail/math.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/image_processing/hough_transform.hpp>
#include <boost/gil/extension/image_processing/hough_transform.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/point.hpp>
#include <boost/gil/rasterization/line.hpp>
#include <boost/gil/extension/rasterization/line.hpp>
#include <boost/gil/typedefs.hpp>
#include <cmath>
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/core/lightweight_test.hpp>
#include <boost/gil/image_processing/hough_parameter.hpp>
#include <boost/gil/extension/image_processing/hough_parameter.hpp>

namespace gil = boost::gil;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//

#include <boost/core/lightweight_test.hpp>
#include <boost/gil/rasterization/circle.hpp>
#include "boost/gil/extension/rasterization/circle.hpp"
#include <cstddef>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/core/lightweight_test.hpp>
#include <boost/gil.hpp>
#include "boost/gil.hpp"
#include <array>
#include <cmath>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <algorithm>
#include <boost/core/lightweight_test.hpp>
#include <boost/gil/point.hpp>
#include <boost/gil/rasterization/line.hpp>
#include "boost/gil/point.hpp"
#include "boost/gil/extension/rasterization/line.hpp"

#include <cmath>
#include <cstddef>
Expand Down