2
0
mirror of https://github.com/boostorg/gil.git synced 2026-01-19 04:12:11 +00:00

Merge pull request #673 from simmplecoder/gsoc_2020_fixup

* Fix Hough transform and move rasterization

Hough line transform had incorrect
rounding which lead to misleading message

* In depth explanation for Hough line

Added in depth explanation for
Hough line transform in the
associated markdown file

* Change "" includes into <>

* Move diffusion and Hough transform

Move anisotropic diffusion and
Hough transform into extension.
Adjust tests and cmakelists

* Edit Jamfile to new layout

* Add compile statements to Jamfile

* Remove migrated files

* Removed redundant lines
This commit is contained in:
Mateusz Łoskot
2022-06-03 07:48:11 +01:00
committed by GitHub
28 changed files with 122 additions and 34 deletions

View File

@@ -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)")

View File

@@ -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>

View File

@@ -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 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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 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

View File

@@ -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::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,
@@ -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';

View File

@@ -39,9 +39,9 @@
#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>
@@ -49,14 +49,14 @@
#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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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)

View File

@@ -33,4 +33,3 @@ build-project image_view ;
build-project algorithm ;
build-project image_processing ;
build-project histogram ;
build-project rasterization ;

View File

@@ -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

View File

@@ -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 ;

View File

@@ -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()

View File

@@ -11,3 +11,5 @@ build-project histogram ;
build-project numeric ;
build-project toolbox ;
build-project io ;
build-project image_processing ;
build-project rasterization ;

View File

@@ -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()

View File

@@ -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 ;

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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;

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>