Skip to content

Commit 843ea37

Browse files
authored
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
2 parents 98f4971 + 45da544 commit 843ea37

28 files changed

+122
-34
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ option(BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE "Enable Dynamic Image extension, tests
5656
option(BOOST_GIL_ENABLE_EXT_IO "Enable IO extension, tests and examples (require libjpeg, libpng, libtiff)" ON)
5757
option(BOOST_GIL_ENABLE_EXT_NUMERIC "Enable Numeric extension, tests and examples" ON)
5858
option(BOOST_GIL_ENABLE_EXT_TOOLBOX "Enable Toolbox extension, tests and examples" ON)
59+
option(BOOST_GIL_ENABLE_EXT_RASTERIZATION "Enable Rasterization extension and tests" ON)
60+
option(BOOST_GIL_ENABLE_EXT_IMAGE_PROCESSING "Enable Image Processing extension (!) and tests" ON)
5961
option(BOOST_GIL_USE_CONAN "Use Conan to install dependencies" OFF)
6062
option(BOOST_GIL_USE_CLANG_TIDY "Set CMAKE_CXX_CLANG_TIDY property on targets to enable clang-tidy linting" OFF)
6163
set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard version to use (default is 11)")

example/anisotropic_diffusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <boost/gil/algorithm.hpp>
1010
#include <boost/gil/extension/io/png.hpp>
1111
#include <boost/gil/image.hpp>
12-
#include <boost/gil/image_processing/diffusion.hpp>
12+
#include "boost/gil/extension/image_processing/diffusion.hpp"
1313
#include <boost/gil/image_view.hpp>
1414
#include <boost/gil/io/typedefs.hpp>
1515
#include <boost/gil/typedefs.hpp>

example/histogram_equalization.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,52 @@ Histogram equalization capabilities in GIL are demonstrated by the program `hist
77

88
The program doesn't take any argument on the command line.
99

10+
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.
11+
12+
A line in polar coordinates is represented by normal to it in polar coordinates, as shown in example here
13+
https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html
14+
15+
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).
16+
17+
```
18+
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
19+
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
20+
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
21+
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
22+
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
23+
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
24+
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
25+
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
26+
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
27+
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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 0 0 0 0 5 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
44+
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 1 0 0 0 0 0
45+
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 1 0 0 0 0
46+
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
47+
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
48+
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
49+
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
50+
```
51+
52+
It is obvious that the angle for the expected Hough transform is 45 degrees (angle between 5s and bottom 0s). Now we
53+
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
54+
and is a hypotenuse! Using trivial trigonometry we know that the length we are searching for is 32 * cos(45).
55+
1056
`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`.
1157

1258
## Specific requirements

example/hough_transform_line.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace gil = boost::gil;
2525

2626
int main()
2727
{
28-
std::ptrdiff_t size = 32;
28+
const std::ptrdiff_t size = 32;
2929
gil::gray16_image_t input_image(size, size);
3030
auto input_view = gil::view(input_image);
3131

@@ -52,7 +52,7 @@ int main()
5252
double _5_degrees = gil::detail::pi / 36;
5353
auto theta_parameter =
5454
gil::make_theta_parameter(_45_degrees, _5_degrees, input_view.dimensions());
55-
auto expected_radius = static_cast<std::ptrdiff_t>(std::round(std::cos(_45_degrees) * size));
55+
auto expected_radius = static_cast<std::ptrdiff_t>(std::floor(std::cos(_45_degrees) * size));
5656
auto radius_parameter =
5757
gil::hough_parameter<std::ptrdiff_t>::from_step_size(expected_radius, 7, 1);
5858
gil::gray32_image_t accumulator_array_image(theta_parameter.step_count,
@@ -70,6 +70,9 @@ int main()
7070
theta_parameter.start_point + theta_index * theta_parameter.step_size;
7171
std::ptrdiff_t current_radius =
7272
radius_parameter.start_point + radius_parameter.step_size * radius_index;
73+
if (current_theta == _45_degrees && current_radius == expected_radius) {
74+
std::cout << "* ";
75+
}
7376
std::cout << "theta: " << current_theta << " radius: " << current_radius
7477
<< " accumulated value: " << accumulator_array(theta_index, radius_index)[0]
7578
<< '\n';

include/boost/gil.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@
3939
#include <boost/gil/position_iterator.hpp>
4040
#include <boost/gil/premultiply.hpp>
4141
#include <boost/gil/promote_integral.hpp>
42-
#include <boost/gil/rasterization/circle.hpp>
43-
#include <boost/gil/rasterization/ellipse.hpp>
44-
#include <boost/gil/rasterization/line.hpp>
42+
#include <boost/gil/extension/rasterization/circle.hpp>
43+
#include <boost/gil/extension/rasterization/ellipse.hpp>
44+
#include <boost/gil/extension/rasterization/line.hpp>
4545
#include <boost/gil/rgb.hpp>
4646
#include <boost/gil/rgba.hpp>
4747
#include <boost/gil/step_iterator.hpp>
4848
#include <boost/gil/typedefs.hpp>
4949
#include <boost/gil/utilities.hpp>
5050
#include <boost/gil/virtual_locator.hpp>
5151
#include <boost/gil/image_processing/adaptive_histogram_equalization.hpp>
52-
#include <boost/gil/image_processing/diffusion.hpp>
52+
#include "boost/gil/extension/image_processing/diffusion.hpp"
5353
#include <boost/gil/image_processing/filter.hpp>
5454
#include <boost/gil/image_processing/harris.hpp>
5555
#include <boost/gil/image_processing/hessian.hpp>
5656
#include <boost/gil/image_processing/histogram_equalization.hpp>
5757
#include <boost/gil/image_processing/histogram_matching.hpp>
58-
#include <boost/gil/image_processing/hough_parameter.hpp>
59-
#include <boost/gil/image_processing/hough_transform.hpp>
58+
#include "boost/gil/extension/image_processing/hough_parameter.hpp"
59+
#include "boost/gil/extension/image_processing/hough_transform.hpp"
6060
#include <boost/gil/image_processing/morphology.hpp>
6161
#include <boost/gil/image_processing/numeric.hpp>
6262
#include <boost/gil/image_processing/scaling.hpp>

include/boost/gil/image_processing/diffusion.hpp renamed to include/boost/gil/extension/image_processing/diffusion.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef BOOST_GIL_IMAGE_PROCESSING_DIFFUSION_HPP
1111
#define BOOST_GIL_IMAGE_PROCESSING_DIFFUSION_HPP
1212

13-
#include "boost/gil/detail/math.hpp"
13+
#include <boost/gil/detail/math.hpp>
1414
#include <boost/gil/algorithm.hpp>
1515
#include <boost/gil/color_base_algorithm.hpp>
1616
#include <boost/gil/image.hpp>

include/boost/gil/image_processing/hough_parameter.hpp renamed to include/boost/gil/extension/image_processing/hough_parameter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP
1010
#define BOOST_GIL_IMAGE_PROCESSING_HOUGH_PARAMETER_HPP
1111

12-
#include <boost/gil/point.hpp>
12+
#include "boost/gil/point.hpp"
1313
#include <cmath>
1414
#include <cstddef>
1515

include/boost/gil/image_processing/hough_transform.hpp renamed to include/boost/gil/extension/image_processing/hough_transform.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define BOOST_GIL_IMAGE_PROCESSING_HOUGH_TRANSFORM_HPP
1111

1212
#include <algorithm>
13-
#include <boost/gil/image_processing/hough_parameter.hpp>
14-
#include <boost/gil/rasterization/circle.hpp>
13+
#include <boost/gil/extension/image_processing/hough_parameter.hpp>
14+
#include <boost/gil/extension/rasterization/circle.hpp>
1515
#include <cmath>
1616
#include <cstddef>
1717
#include <iterator>
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)