mirror of
https://github.com/boostorg/gil.git
synced 2026-01-19 04:12:11 +00:00
Ensure all examples build without error (#628)
* Added all missing examples, dodgy Jamfile still * Fixed attributions and Jamfile indent * One readme per example: synopsis, build and exec reqs * Cleaned up example/convolve2d.cpp * Added example target to root Jamfile Closes #436
This commit is contained in:
1
Jamfile
1
Jamfile
@@ -7,4 +7,5 @@
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# please order by name to ease maintenance
|
||||
build-project example ;
|
||||
build-project test ;
|
||||
|
||||
@@ -11,6 +11,7 @@ import regex ;
|
||||
import testing ;
|
||||
|
||||
using libjpeg : : : : true ; # work around bug on master
|
||||
using libpng : : : : true ;
|
||||
|
||||
project
|
||||
: # requirements
|
||||
@@ -19,6 +20,7 @@ project
|
||||
# TODO: Add missing examples
|
||||
|
||||
local sources =
|
||||
adaptive_he.cpp
|
||||
adaptive_threshold.cpp
|
||||
affine.cpp
|
||||
anisotropic_diffusion.cpp
|
||||
@@ -27,12 +29,18 @@ local sources =
|
||||
dynamic_image.cpp
|
||||
harris.cpp
|
||||
hessian.cpp
|
||||
histogram_equalization.cpp
|
||||
histogram_matching.cpp
|
||||
histogram.cpp
|
||||
hough_transform_circle.cpp
|
||||
hough_transform_line.cpp
|
||||
interleaved_ptr.cpp
|
||||
mandelbrot.cpp
|
||||
morphology.cpp
|
||||
packed_pixel.cpp
|
||||
rasterizer_circle.cpp
|
||||
rasterizer_ellipse.cpp
|
||||
rasterizer_line.cpp
|
||||
resize.cpp
|
||||
sobel_scharr.cpp
|
||||
threshold.cpp
|
||||
@@ -44,11 +52,13 @@ local targets ;
|
||||
|
||||
for local s in $(sources)
|
||||
{
|
||||
targets +=
|
||||
[ compile $(s) :
|
||||
[ ac.check-library /libjpeg//libjpeg : <library>/libjpeg//libjpeg : <build>no ]
|
||||
]
|
||||
;
|
||||
targets +=
|
||||
[ exe [ regex.replace $(s) ".cpp" "" ] :
|
||||
$(s)
|
||||
/libjpeg//libjpeg
|
||||
/libpng//libpng
|
||||
]
|
||||
;
|
||||
}
|
||||
|
||||
alias examples : $(targets) ;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
This directory contains
|
||||
|
||||
- examples of C++ programs using GIL
|
||||
- a documentation file describing the synopsis, build and execution requirements for each example
|
||||
- configuration files for Boost.Build command line and CMake integration for popular IDEs.
|
||||
|
||||
We provide Boost.Build (`Jamfile`) and CMake (`CMakeLists.txt`)
|
||||
@@ -10,36 +11,4 @@ configurations to build the examples.
|
||||
See the [CONTRIBUTING.md](../CONTRIBUTING.md)
|
||||
for details on how to run `b2` and `cmake` for Boost.GIL.
|
||||
|
||||
Each example is build as a separate executable.
|
||||
Each executable generates its output as `out-<example_name>.jpg`.
|
||||
For example, the `resize.cpp` example generates the image `out-resize.jpg`.
|
||||
|
||||
The following C++ examples are included:
|
||||
|
||||
1. `resize.cpp`
|
||||
Scales an image using bilinear or nearest-neighbour resampling.
|
||||
|
||||
2. `affine.cpp`
|
||||
Performs an arbitrary affine transformation on the image.
|
||||
|
||||
3. `convolution.cpp`
|
||||
Convolves the image with a Gaussian kernel.
|
||||
|
||||
4. `mandelbrot.cpp`
|
||||
Creates a synthetic image defining the Mandelbrot set.
|
||||
|
||||
5. `interleaved_ptr.cpp`
|
||||
Illustrates how to create a custom pixel reference and iterator.
|
||||
Creates a GIL image view over user-supplied data without the need to cast to GIL pixel type.
|
||||
|
||||
6. `x_gradient.cpp`
|
||||
Horizontal gradient, from the tutorial
|
||||
|
||||
7. `histogram.cpp`
|
||||
Algorithm to compute the histogram of an image
|
||||
|
||||
8. `packed_pixel.cpp`
|
||||
Illustrates how to create a custom pixel model - a pixel whose channel size is not divisible by bytes.
|
||||
|
||||
9. `dynamic_image.cpp`
|
||||
Example of using images whose type is instantiated at run time.
|
||||
Each example is built as a separate executable.
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
// Demonstrates Adaptive Histogram Equalization (AHE)
|
||||
|
||||
// See also:
|
||||
// histogram.cpp - General use of histograms in GIL
|
||||
// histogram_equalization.cpp - Regular Histogram Equalization
|
||||
// histogram_matching.cpp - Reference-based histogram computation
|
||||
|
||||
int main()
|
||||
{
|
||||
gray8_image_t img;
|
||||
|
||||
20
example/adaptive_he.md
Normal file
20
example/adaptive_he.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Adaptive Histogram Equalization
|
||||
|
||||
Adaptive Histogram Equalization (AHE) capabilities in GIL are demonstrated by the program `adaptive_he`, compiled from the sources `example/adaptive_he.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`adaptive_he`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`adaptive_he` expects to find an image called `test_adaptive.png` in the current directory, and produces the image `out-adaptive.png` in return.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `adaptive_he` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
|
||||
@@ -5,12 +5,22 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
// Demonstrates Adaptive Thresholding
|
||||
|
||||
// threshold_adaptive works following either the mean or the gaussian method, and accepts also a direction
|
||||
// The direction indicates whether the pixels are assigned the max value when their values are greater
|
||||
// than the threshold (regular), or when they are less than the threshold (inverse)
|
||||
// threshold_adaptive is defined in include/boost/gil/image_processing/threshold.hpp
|
||||
// See also:
|
||||
// threshold.cpp - Simple thresholding
|
||||
|
||||
int main()
|
||||
{
|
||||
gray8_image_t img;
|
||||
|
||||
23
example/adaptive_threshold.md
Normal file
23
example/adaptive_threshold.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Adaptive Thresholding
|
||||
|
||||
Adaptive Thresholding capabilities in GIL are demonstrated by the program `adaptive_threshold`, compiled from the sources `example/adaptive_threshold.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`adaptive_threshold`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`adaptive_threshold` expects to find an image called `test_adaptive.png` in the current directory, and produces one image for each thresholding method:
|
||||
- `out-threshold-adaptive-mean.png`
|
||||
- `out-threshold-adaptive-mean-inv.png`
|
||||
- `out-threshold-adaptive-gaussian.png`
|
||||
- `out-threshold-adaptive-gaussian-inv.png`.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `adaptive_threshold` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
@@ -5,12 +5,17 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/gil/extension/numeric/sampler.hpp>
|
||||
#include <boost/gil/extension/numeric/resample.hpp>
|
||||
|
||||
// Example for resample_pixels() in the numeric extension
|
||||
// Performs an arbitrary affine transformation on the image.
|
||||
|
||||
// This example relies on the matrices and functions available in GIL to define the operation,
|
||||
// in include/boost/gil/extension/numeric/affine.hpp
|
||||
// and calls resample_pixels(), avaiable in the numeric extension, to apply it
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
19
example/affine.md
Normal file
19
example/affine.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Affine transformation
|
||||
|
||||
Affine transformation capabilities in GIL are demonstrated by the program `affine`, compiled from the sources `example/affine.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`affine`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`affine` expects to find an image called `test.jpg` in the current directory, and produces an image in return, where the transformations have been applied: `out-affine.jpg`
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `affine` expects to find an image called `test.jpg` in the current directory.
|
||||
@@ -5,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil/algorithm.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <boost/gil/image.hpp>
|
||||
@@ -20,6 +21,12 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates Anisotropic Diffusion
|
||||
|
||||
// This example uses the Perona-Malik's diffusion algorithm, which is the default in GIL.
|
||||
// In addition, Gaussian conductivity and two wide range conductivity functions are also available.
|
||||
// see include/boost/gil/image_processing/diffusion.hpp
|
||||
|
||||
void gray_version(std::string const& input_path, std::string const& output_path,
|
||||
unsigned int iteration_count, float kappa)
|
||||
{
|
||||
|
||||
22
example/anisotropic_diffusion.md
Normal file
22
example/anisotropic_diffusion.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Anisotropic diffusion
|
||||
|
||||
Anisotropic diffusion capabilities in GIL are demonstrated by the program `anisotropic_diffusion`, compiled from the sources `example/anisotropic_diffusion.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`anisoptropic_diffusion input.png output.png gray|rgb iterations kappa`
|
||||
- The first parameter must be the full path to an existing image in the JPEG format for `anisoptropic_diffusion` to process
|
||||
- The second parameter is the full path to the output image of `anisotropic_diffusion`. The directory will *not* be created and must exist.
|
||||
- The third parameter is the colour space: either `gray` or `rgb`
|
||||
- The fourth parameter is the number of iterations, which *must* be a positive integer
|
||||
- The fifth and last parameter is the value of the kappa constant
|
||||
|
||||
Note that both the input and the ouput images must be in the PNG format.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`anisotropic_diffusion` has no specific execution requirements.
|
||||
@@ -4,12 +4,24 @@
|
||||
// Distributed under 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
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/gil/extension/numeric/kernel.hpp>
|
||||
#include <boost/gil/extension/numeric/convolve.hpp>
|
||||
|
||||
// Example for convolve_rows() and convolve_cols() in the numeric extension
|
||||
// Convolves the image with a Gaussian kernel.
|
||||
|
||||
// Note that the kernel can be fixed or resizable:
|
||||
// kernel_1d_fixed<float, N> k(matrix, centre) produces a fixed kernel
|
||||
// kernel_1d<float> k(matrix, size, centre) produces a resizable kernel
|
||||
|
||||
// Work can be done row by row and column by column, as in this example,
|
||||
// using the functions convolve_rows and convolve_cols (or their _fixed counterpart)
|
||||
// but the header boost/gil/extension/numeric/convolve.hpp also offers the function convolve_1d which combines the two.
|
||||
|
||||
// See also:
|
||||
// convolve2d.cpp - Convolution with 2d kernels
|
||||
|
||||
int main() {
|
||||
using namespace boost::gil;
|
||||
|
||||
19
example/convolution.md
Normal file
19
example/convolution.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Convolution
|
||||
|
||||
Convolution capabilities in GIL are demonstrated by the program `convolution`, compiled from the sources `example/convolution.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`convolution`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`convolution` expects to find an image called `test.jpg` in the current directory, and produces two images in return, where the filters have been applied: `out-convolution.jpg` and `out-convolution2.jpg`
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `convolution` expects to find an image called `test.jpg` in the current directory.
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// Copyright 2019 Miral Shah <miralshah2211@gmail.com>
|
||||
//
|
||||
// Distributed under 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
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <boost/gil/extension/numeric/kernel.hpp>
|
||||
@@ -5,14 +13,23 @@
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
|
||||
using namespace boost::gil;
|
||||
using namespace std;
|
||||
|
||||
// Convolves the image with a 2d kernel.
|
||||
|
||||
// Note that the kernel can be fixed or resizable:
|
||||
// kernel_2d_fixed<float, N> k(elements, centre_y, centre_x) produces a fixed kernel
|
||||
// kernel_2d<float> k(elements, size, centre_y, centre_x) produces a resizable kernel
|
||||
// The size of the kernel matrix is deduced as the square root of the number of the elements (9 elements yield a 3x3 matrix)
|
||||
|
||||
// See also:
|
||||
// convolution.cpp - Convolution with 2d kernels
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
//gray8_image_t img;
|
||||
//read_image("test_adaptive.png", img, png_tag{});
|
||||
//gray8_image_t img_out(img.dimensions());
|
||||
|
||||
gray8_image_t img;
|
||||
read_image("src_view.png", img, png_tag{});
|
||||
gray8_image_t img_out(img.dimensions()), img_out1(img.dimensions());
|
||||
@@ -21,21 +38,16 @@ int main()
|
||||
detail::kernel_2d<float> kernel(v.begin(), v.size(), 1, 1);
|
||||
detail::convolve_2d(view(img), kernel, view(img_out1));
|
||||
|
||||
//write_view("out-convolve2d.png", view(img_out), png_tag{});
|
||||
write_view("out-convolve2d.png", view(img_out1), jpeg_tag{});
|
||||
write_view("out-convolve2d.png", view(img_out1), png_tag{});
|
||||
|
||||
|
||||
//------------------------------------//
|
||||
std::vector<float> v1(3, 1.0f / 3.0f);
|
||||
kernel_1d<float> kernel1(v1.begin(), v1.size(), 1);
|
||||
|
||||
detail::convolve_1d<gray32f_pixel_t>(const_view(img), kernel1, view(img_out), boundary_option::extend_zero);
|
||||
write_view("out-convolve_option_extend_zero.png", view(img_out), png_tag{});
|
||||
|
||||
if (equal_pixels(view(img_out1), view(img_out)))cout << "convolve_option_extend_zero" << endl;
|
||||
|
||||
cout << "done\n";
|
||||
cin.get();
|
||||
if (equal_pixels(view(img_out1), view(img_out)))
|
||||
cout << "convolve_option_extend_zero" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
22
example/convolve2d.md
Normal file
22
example/convolve2d.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Convolution (2d kernel)
|
||||
|
||||
2d kernel convolution capabilities in GIL are demonstrated by the program `convolve2d`, compiled from the sources `example/convolve2d.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`convolve2d`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`convolve2d` expects to find an image called `src_view.png` in the current directory, and produces two images in return, where the filters have been applied: `out-convolve2d.png` and `out-convolve_option_extend_zero.png`
|
||||
|
||||
Note that the user is expected to press a key to end the program.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `convolve2d` expects to find an image called `src_view.png` in the current directory.
|
||||
@@ -5,18 +5,23 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/dynamic_image/any_image.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/mp11.hpp>
|
||||
|
||||
// Demonstrates how to use images whose type is instantiated at run time.
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace gil = boost::gil;
|
||||
|
||||
gil::any_image<gil::gray8_image_t, gil::rgb8_image_t, gil::gray16_image_t, gil::rgb16_image_t> dynamic_image;
|
||||
gil::read_image("test.jpg", dynamic_image, gil::jpeg_tag());
|
||||
|
||||
// Save the image upside down, preserving its native color space and channel depth
|
||||
auto view = gil::flipped_up_down_view(gil::const_view(dynamic_image));
|
||||
|
||||
gil::write_view("out-dynamic_image.jpg", view, gil::jpeg_tag());
|
||||
}
|
||||
|
||||
19
example/dynamic_image.md
Normal file
19
example/dynamic_image.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Dynamic Image
|
||||
|
||||
Dynamic image manipulation capabilities in GIL are demonstrated by the program `dynamic_image`, compiled from the sources `example/dynamic_image.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`dynamic_image`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`dynamic_image` expects to find an image called `test.jpg` in the current directory, and produces an image in return, where the a flip has been applied: `out-dynamic_image.jpg`.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured
|
||||
|
||||
### Execution requirements
|
||||
- `dynamic_image` expects to find an image called `test.jpg` in the current directory.
|
||||
@@ -5,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <boost/gil/extension/numeric/convolve.hpp>
|
||||
#include <boost/gil/image.hpp>
|
||||
@@ -23,6 +24,8 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates Harris corner detection
|
||||
|
||||
// some images might produce artifacts
|
||||
// when converted to grayscale,
|
||||
// which was previously observed on
|
||||
@@ -157,11 +160,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
gil::rgb8_image_t input_image;
|
||||
|
||||
gil::read_image(argv[1], input_image, gil::png_tag{});
|
||||
gil::read_image(argv[1], input_image, gil::png_tag{});
|
||||
auto original_image = input_image;
|
||||
auto original_view = gil::view(original_image);
|
||||
auto input_view = gil::view(input_image);
|
||||
auto grayscaled = to_grayscale(input_view);
|
||||
auto grayscaled = to_grayscale(input_view);
|
||||
gil::gray8_image_t smoothed_image(grayscaled.dimensions());
|
||||
auto smoothed = gil::view(smoothed_image);
|
||||
apply_gaussian_blur(gil::view(grayscaled), smoothed);
|
||||
|
||||
21
example/harris.md
Normal file
21
example/harris.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Harris Corner Detection
|
||||
|
||||
Harris corner detection capabilities in GIL are demonstrated by the program `harris`, compiled from the sources `example/harris.cpp` and `hvstack.hpp`.
|
||||
|
||||
## Synopsis
|
||||
`harris input.png window-size discriminant harris-threshold output.png`
|
||||
|
||||
- The first parameter must be the full path to an existing image in the PNG format for `harris` to process
|
||||
- The second parameter is the size of the window containing the pixels to analyse and must be an odd number (e.g. 9 for a 3x3 matrix)
|
||||
- The third parameter is the empirically-defined discriminant constant, usually between 0.04 and 0.06
|
||||
- The fourth parameter is the harris threshold used to identify the optimal values
|
||||
- The fifth and last parameter is the full path to the output image of `harris`. The directory will *not* be created and must exist.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured
|
||||
|
||||
### Execution requirements
|
||||
- `harris` has no specific execution requirements.
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// Copyright 2019 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
// Distributed under 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
|
||||
//
|
||||
|
||||
#include <boost/gil/image.hpp>
|
||||
#include <boost/gil/image_view.hpp>
|
||||
#include <boost/gil/image_processing/numeric.hpp>
|
||||
@@ -11,6 +19,8 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates Hessian feature (blob) detection
|
||||
|
||||
// some images might produce artifacts
|
||||
// when converted to grayscale,
|
||||
// which was previously observed on
|
||||
|
||||
20
example/hessian.md
Normal file
20
example/hessian.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Hessian Feature Detection
|
||||
|
||||
Hessian feature detection capabilities in GIL are demonstrated by the program `hessian`, compiled from the sources `example/hessian.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`hessian input.png window-size hessian-threshold output.png`
|
||||
|
||||
- The first parameter must be the full path to an existing image in the PNG format for `hessian` to process
|
||||
- The second parameter is the size of the window containing the pixels to analyse and must be an odd number (e.g. 9 for a 3x3 matrix)
|
||||
- The third parameter is the hessian threshold used to identify the optimal values
|
||||
- The fourth and last parameter is the full path to the output image of `hessian`. The directory will *not* be created and must exist.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured
|
||||
|
||||
### Execution requirements
|
||||
- `hessian` has no specific execution requirements.
|
||||
@@ -14,10 +14,13 @@
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
/*
|
||||
This file explains how to use the histogram class and some of its features
|
||||
that can be applied for a variety of tasks.
|
||||
*/
|
||||
// Explains how to use the histogram class and some of its features
|
||||
// that can be applied for a variety of tasks.
|
||||
|
||||
// See also:
|
||||
// histogram_equalization.cpp - Regular Histogram Equalization
|
||||
// adaptive_he.cpp - Adaptive Histogram Equalization
|
||||
// histogram_matching.cpp - Reference-based histogram computation
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -34,7 +37,7 @@ int main()
|
||||
h, // Histogram to be filled
|
||||
1, // Histogram bin widths
|
||||
false, // Specify whether to accumulate over the values already present in h (default = false)
|
||||
true, // Specify whether to have a sparse or continuous histogram (default = true)
|
||||
true, // Specify whether to have a sparse (true) or continuous histogram (false) (default = true)
|
||||
false, // Specify if image mask is to be specified
|
||||
{{}}, // Mask as a 2D vector. Used only if prev argument specified
|
||||
{0}, // Lower limit on the values in histogram (default numeric_limit::min() on axes)
|
||||
|
||||
20
example/histogram.md
Normal file
20
example/histogram.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Histogram
|
||||
|
||||
Histogram capabilities in GIL are demonstrated by the program `histogram`, compiled from the sources `example/histogram.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`histogram`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`histogram` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
The program doesn't produce any output.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `histogram` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
@@ -1,9 +1,24 @@
|
||||
//
|
||||
// Copyright 2020 Debabrata Mandal <mandaldebabrata123@gmail.com>
|
||||
//
|
||||
// Distributed under 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
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <boost/gil/image_processing/histogram_equalization.hpp>
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
// Demonstrates Histogram Equalization
|
||||
|
||||
// See also:
|
||||
// histogram.cpp - General use of histograms in GIL
|
||||
// adaptive_he.cpp - Adaptive Histogram Equalization
|
||||
// histogram_matching.cpp - Reference-based histogram computation
|
||||
|
||||
int main()
|
||||
{
|
||||
gray8_image_t img;
|
||||
|
||||
19
example/histogram_equalization.md
Normal file
19
example/histogram_equalization.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Histogram Equalization
|
||||
|
||||
Histogram equalization capabilities in GIL are demonstrated by the program `histogram_equalization`, compiled from the sources `example/histogram_equalization.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`histogram_equalization`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`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
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `histogram_equalization` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
@@ -14,6 +14,13 @@
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
// Demonstrates Histogram Matching
|
||||
|
||||
// See also:
|
||||
// histogram_equalization.cpp - Regular Histogram Equalization
|
||||
// adaptive_he.cpp - Adaptive Histogram Equalization
|
||||
// histogram.cpp - General use of histograms in GIL
|
||||
|
||||
std::vector<std::vector<bool>> get_mask(gray8_view_t const& mask)
|
||||
{
|
||||
std::vector<std::vector<bool>> mask_vec(mask.height(), std::vector<bool>(mask.width(), 0));
|
||||
|
||||
19
example/histogram_matching.md
Normal file
19
example/histogram_matching.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Histogram Matching
|
||||
|
||||
Histogram matching capabilities in GIL are demonstrated by the program `histogram_matching`, compiled from the sources `example/histogram_matching.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`histogram_matching`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`histogram_matching` 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_matching.png`.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
- `histogram_matching` expects to find an image called `test_adaptive.png` in the current directory.
|
||||
@@ -1,4 +1,3 @@
|
||||
// Boost.GIL (Generic Image Library) - tests
|
||||
//
|
||||
// Copyright 2020 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
@@ -6,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates how to use a Hough transform to identify a circle
|
||||
|
||||
// Note this relies on the brute force approach, which today is the only one available in GIL
|
||||
// The function hough_circle_transform_brute, defined in include/boost/gil/image_processing/hough_transform.cpp,
|
||||
// accepts a greyscale edge map, the three Hough parameters allowing to do the drawing and the voting,
|
||||
// an accumulator in the form of an iterator of views of the parameter space and a utility rasterizer to produce the points.
|
||||
// The example outputs the voting cell of the centre of a circle drawn programatically.
|
||||
// See also:
|
||||
// hough_transform_line.cpp - Hough transform to detect lines
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::size_t size = 128;
|
||||
|
||||
18
example/hough_transform_circle.md
Normal file
18
example/hough_transform_circle.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Hough Circle Transform
|
||||
|
||||
Hough circle transform capabilities in GIL are demonstrated by the program `hough_transform_circle`, compiled from the sources `example/hough_transform_circle.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`hough_transform_circle`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
The program outputs the voting cell of the centre of a circle drawn programatically.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above.
|
||||
|
||||
### Execution requirements
|
||||
`hough_transform_circle` doesn't have any specific execution requirements.
|
||||
@@ -1,4 +1,3 @@
|
||||
// Boost.GIL (Generic Image Library) - tests
|
||||
//
|
||||
// Copyright 2020 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
@@ -6,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <cmath>
|
||||
@@ -14,6 +14,15 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates the Hough transform to detect lines
|
||||
|
||||
// The algorithm itself is implemented in include/boost/gil/image_processing/hough_transform.hpp.
|
||||
// It follows the regular algorithm, using Hesse notation, and steps around each point using the minimal visible angle
|
||||
// defined as atan2(1, d), where d is whichever dimension in the input image is the longest.
|
||||
// The function make_theta_parameter, defined in include/boost/gil/image_processing/hough_parameter.hpp, allows to generate the parameter accordingly.
|
||||
// See also:
|
||||
// hough_transform_circle.cpp - Hough transform to detect circles
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ptrdiff_t size = 32;
|
||||
@@ -38,11 +47,9 @@ int main()
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
double minimum_theta_step = std::atan(1.0 / size);
|
||||
// this is the expected theta
|
||||
double _45_degrees = gil::detail::pi / 4;
|
||||
double _5_degrees = gil::detail::pi / 36;
|
||||
std::size_t step_count = 5;
|
||||
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));
|
||||
|
||||
18
example/hough_transform_line.md
Normal file
18
example/hough_transform_line.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Hough Line Transform
|
||||
|
||||
Hough line transform capabilities in GIL are demonstrated by the program `hough_transform_line`, compiled from the sources `example/hough_transform_line.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`hough_transform_line`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
The program outputs the expected theta and radius, followed by every step of the search.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above.
|
||||
|
||||
### Execution requirements
|
||||
`hough_transform_line` doesn't have any specific execution requirements.
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// // Copyright 2021 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
// Distributed under 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
|
||||
//
|
||||
|
||||
#include "boost/gil/image_view_factory.hpp"
|
||||
#include <boost/gil/image.hpp>
|
||||
#include <boost/gil/image_view.hpp>
|
||||
|
||||
@@ -5,13 +5,17 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#ifdef WIN32
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#pragma warning(disable : 4244) //
|
||||
#pragma warning(disable : 4996) // MSFT declared it deprecated
|
||||
#endif
|
||||
|
||||
// Example file to demonstrate how to create a model of a pixel iterator
|
||||
// Illustrates how to create a custom pixel reference and iterator.
|
||||
// Creates a GIL image view over user-supplied data without the need to cast to GIL pixel type.
|
||||
// The pixel iterator itself is implemented in interleaved_ptr.hpp, with the reference defined in interleaved_ref.hpp.
|
||||
|
||||
|
||||
// FIXME: Review and remove if possible: gcc doesn't compile unless we forward-declare at_c before we include gil...
|
||||
namespace boost { namespace gil {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#ifndef BOOST_GIL_EXAMPLE_INTERLEAVED_PTR_HPP
|
||||
#define BOOST_GIL_EXAMPLE_INTERLEAVED_PTR_HPP
|
||||
|
||||
|
||||
19
example/interleaved_ptr.md
Normal file
19
example/interleaved_ptr.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Custom pixel reference and iteraror: Interleaved Pointer
|
||||
|
||||
Definition of custom pixel reference and iterator capabilities in GIL are demonstrated by the program `interleaved_ptr`, compiled from the sources `example/interleaved_ptr.cpp`, `interleaved_ptr.hpp` and `interleaved_ref.hpp`.
|
||||
|
||||
## Synopsis
|
||||
`interleaved_ptr`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
The program expects to find an image, `test.jpg` in the current directory, and produces the image `out-interleaved_ptr.jpg` in return, that has been generated using the custom pixel reference and iterator objects.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`interleaved_ptr` expects to find an image, `test.jpg` in the current directory.
|
||||
@@ -5,6 +5,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#ifndef BOOST_GIL_EXAMPLE_INTERLEAVED_REF_HPP
|
||||
#define BOOST_GIL_EXAMPLE_INTERLEAVED_REF_HPP
|
||||
|
||||
|
||||
@@ -5,11 +5,16 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil/image.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
|
||||
// Example for convolve_rows() and convolve_cols() in the numeric extension
|
||||
// Creates a synthetic image defining the Mandelbrot set.
|
||||
// The example relies on a virtual_2d_locator to iterate over the pixels in the destination view.
|
||||
// The pixels (of type rgb8_pixel_t) are generated programmatically, and the code shows how to access
|
||||
// the colour channels and set them to arbitrary values.
|
||||
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
|
||||
19
example/mandelbrot.md
Normal file
19
example/mandelbrot.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Mandelbrot
|
||||
|
||||
Pixel iteration using `virtual_2d_locators` capabilities in GIL are demonstrated by the program `mandelbrot`, compiled from the sources `example/mandelbrot.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`mandelbrot`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
The program produces the image `out-mandelbrot.jpg` that has been generated using the `virtual_2d_locator` object.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`mandelbrot` has no specific execution requirements.
|
||||
@@ -5,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <iostream>
|
||||
@@ -12,12 +13,26 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
// Demonstrates a number of morphological operations
|
||||
// The structuring element is defined as an instance of a kernel_2d<float>:
|
||||
// Default structuring element is SE = [1,1,1]
|
||||
// |1,1,1|
|
||||
// [1,1,1]
|
||||
// SE(1,1)(center pixel) is the one which coincides with the currently
|
||||
// considered pixel of the image to be convolved. The structuring element can be
|
||||
// easily changed by the user.
|
||||
// The example demonstrates the following morphological operations:
|
||||
// - black_hat
|
||||
// - top_hat
|
||||
// - morphological_gradient
|
||||
// - dilation
|
||||
// - erosion
|
||||
// - opening
|
||||
// - closing
|
||||
// - binary
|
||||
// These operations are defined in include/boost/gil/image_processing/morphology.hpp
|
||||
|
||||
namespace gil = boost::gil;
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
31
example/morphology.md
Normal file
31
example/morphology.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Morphology
|
||||
|
||||
Morphological operations capabilities in GIL are demonstrated by the program `morphology`, compiled from the sources `example/morphology.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`morphology input.png output-image-template operation1 [operation2 ... operationN]`
|
||||
|
||||
- The first parameter must be the full path to an existing image in the PNG format for `morphology` to process
|
||||
- The second parameter is the pattern to use to name the output files. For example, a template of `out-` will generate files like `out-erosion.png`. Note that a full path can be given here, but that the directory must exist, as `morphology` will *not* create it.
|
||||
- The rest of the parameters are operation names, separated by a space. Each operation triggers the output of a file, whose name follows the pattern: `_output-image-template_-_operation_-.png`. For example, the line `morphology input.png out- erosion` will produce the image `out-erosion.png`.
|
||||
|
||||
The morphological operations available are the following:
|
||||
- black_hat
|
||||
- top_hat
|
||||
- morphological_gradient
|
||||
- dilation
|
||||
- erosion
|
||||
- opening
|
||||
- closing
|
||||
- binary
|
||||
|
||||
The operations can be provided in any order, only note that if `binary` is supplied, it will be applied first.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`morphology` has no specific execution requirements.
|
||||
@@ -5,6 +5,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
19
example/packed_pixel.md
Normal file
19
example/packed_pixel.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Packed Pixel
|
||||
|
||||
Packed pixel formats capabilities in GIL are demonstrated by the program `packed_pixel`, compiled from the sources `example/packed_pixel.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`packed_pixel`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`packed_pixel` expects to find an image called `input.jpg` in the current directory in JPEG format, and produces two images in the current directory in return, `out-packed_pixel_bgr772.jpg` and `out-packed_pixel_gray1.jpg`.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`packed_pixel` expects to find an image called `input.jpg` in the current directory in JPEG format.
|
||||
@@ -1,4 +1,3 @@
|
||||
// Boost.GIL (Generic Image Library) - tests
|
||||
//
|
||||
// Copyright 2020 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
@@ -6,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
#include <cmath>
|
||||
@@ -14,6 +14,15 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates the use of a rasterizer to generate an image of a circle
|
||||
// The various rasterizers available are defined in include/boost/gil/rasterization/circle.hpp,
|
||||
// include/boost/gil/rasterization/ellipse.hpp and include/boost/gil/rasterization/line.hpp
|
||||
// This example uses a trigonometric rasterizer; GIL also offers the rasterizer midpoint_circle_rasterizer,
|
||||
// which implements the Midpoint algorithm.
|
||||
// See also:
|
||||
// rasterizer_ellipse.cpp - Demonstrates the use of a rasterizer to generate an image of an ellipse
|
||||
// rasterizer_line.cpp - Demonstrates the use of a rasterizer to generate an image of a line
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::ptrdiff_t size = 256;
|
||||
|
||||
19
example/rasterizer_circle.md
Normal file
19
example/rasterizer_circle.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Circle rasterizeration
|
||||
|
||||
Circle rasterization capabilities in GIL are demonstrated by the program `rasterizer_circle`, compiled from the sources `example/rasterizer_circle.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`rasterizer_circle`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`rasterizer_circle` produces an image in the current directory called `circle.png`, in the PNG format.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`rasterizer_circle` doesn't have any specific execution requirements.
|
||||
@@ -5,11 +5,23 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/gil.hpp>
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates the use of a rasterizer to generate an image of an ellipse
|
||||
// The various rasterizers available are defined in include/boost/gil/rasterization/circle.hpp,
|
||||
// include/boost/gil/rasterization/ellipse.hpp and include/boost/gil/rasterization/line.hpp
|
||||
// The rasterizer used is a generalisation of the midpoint algorithm often used for drawing circle.
|
||||
// This examples also shows how to create images with various pixel depth, as well as the behaviour
|
||||
// in case of the rasterization of a curve that doesn't fit in a view.
|
||||
// See also:
|
||||
// rasterizer_circle.cpp - Demonstrates the use of a rasterizer to generate an image of a circle
|
||||
// rasterizer_line.cpp - Demonstrates the use of a rasterizer to generate an image of a line
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// Syntax for usage :-
|
||||
|
||||
22
example/rasterizer_ellipse.md
Normal file
22
example/rasterizer_ellipse.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Ellipse rasterizeration
|
||||
|
||||
Ellipse rasterization capabilities in GIL are demonstrated by the program `rasterizer_ellipse`, compiled from the sources `example/rasterizer_ellipse.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`rasterizer_ellipse`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`rasterizer_ellipse` produces three images in the current directory:
|
||||
- `rasterized_ellipse_gray.jpg`, in the JPEG format, wich is a greyscale image of an ellipse
|
||||
- `rasterized_ellipse_rgb.jpg`, in the JPEG format, wich is an RGB image of an ellipse
|
||||
- `rasterized_ellipse_rgb_out_of_bound.jpg`, in the JPEG format, wich is an RGB image of an ellipse bigger than the containinig view.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`rasterizer_ellipse` doesn't have any specific execution requirements.
|
||||
@@ -1,4 +1,3 @@
|
||||
// Boost.GIL (Generic Image Library) - tests
|
||||
//
|
||||
// Copyright 2020 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
@@ -6,6 +5,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates the use of a rasterizer to generate an image of a line
|
||||
// The various rasterizers available are defined in include/boost/gil/rasterization/circle.hpp,
|
||||
// include/boost/gil/rasterization/ellipse.hpp and include/boost/gil/rasterization/line.hpp
|
||||
// The rasterizer used implements the Bresenham's line algorithm.
|
||||
// Multiple images are created, all of the same size, but with areas of different sizes passed to the rasterizer, resulting in different lines.
|
||||
// See also:
|
||||
// rasterizer_circle.cpp - Demonstrates the use of a rasterizer to generate an image of a circle
|
||||
// rasterizer_ellipse.cpp - Demonstrates the use of a rasterizer to generate an image of an ellipse
|
||||
|
||||
|
||||
const std::ptrdiff_t size = 256;
|
||||
|
||||
void line_bresenham(std::ptrdiff_t width, std::ptrdiff_t height, const std::string& output_name)
|
||||
|
||||
23
example/rasterizer_line.md
Normal file
23
example/rasterizer_line.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Line rasterizeration
|
||||
|
||||
Line rasterization capabilities in GIL are demonstrated by the program `rasterizer_line`, compiled from the sources `example/rasterizer_line.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`rasterizer_line`
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
`rasterizer_line` produces four images of different lines in the current directory:
|
||||
- `line-bresenham-256-256.png`, in the PNG format
|
||||
- `line-bresenham-256-128.png`, in the PNG format
|
||||
- `line-bresenham-256-1.png`, in the PNG format
|
||||
- `line-bresenham-1-256.png`, in the PNG format.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`rasterizer_line` doesn't have any specific execution requirements.
|
||||
@@ -5,12 +5,16 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/gil/extension/numeric/sampler.hpp>
|
||||
#include <boost/gil/extension/numeric/resample.hpp>
|
||||
|
||||
// Example for resize_view() in the numeric extension
|
||||
// Demonstrates how to scale an image using bilinear sampling
|
||||
// This example relies on the function resize_view(), available in include/boost/gil/extension/numeric/resample.hpp,
|
||||
// to apply the resampling.
|
||||
// This example demonstrates bilinear sampling; include/boost/gil/extension/numeric/sample.hpp also offers nearest-neighbour sampling.
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
19
example/resize.md
Normal file
19
example/resize.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Resize
|
||||
|
||||
Resizing capabilities in GIL are demonstrated by the program `resize`, compiled from the sources `example/resize.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`resize`
|
||||
|
||||
This program expects to find an image called `test.jpg`, in JPEG format, in the current directory, and produces a scaled down version of this image, called `out-resize.jpg`, in JPEG format in the current directory.
|
||||
|
||||
The program doesn't take any argument on the command line.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`resize` expects to find an image called `test.jpg`, in JPEG format, in the current directory.
|
||||
@@ -1,3 +1,11 @@
|
||||
//
|
||||
// // Copyright 2019 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
|
||||
//
|
||||
// Distributed under 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
|
||||
//
|
||||
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
#include <boost/gil/image_processing/numeric.hpp>
|
||||
#include <boost/gil/extension/io/png.hpp>
|
||||
@@ -7,6 +15,11 @@
|
||||
|
||||
namespace gil = boost::gil;
|
||||
|
||||
// Demonstrates the use of Sobel and Scharr filters to detect edges
|
||||
// The example generates a couple of images representing respectively the result of
|
||||
// applying the filter horizontally and vertically.
|
||||
// The functions generating the filters (or kernels) are defined in include/boost/gil/image_processing/numeric.hpp.
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 5)
|
||||
|
||||
20
example/sobel_scharr.md
Normal file
20
example/sobel_scharr.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Sobel and Scharr filters for edge detection
|
||||
|
||||
Edge detection via Sobel and Scharr filters capabilities in GIL are demonstrated by the program `sobel_scharr`, compiled from the sources `example/sobel_scharr.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`sobel_scharr input.png sobel|scharr output-x.png output-y.png`
|
||||
|
||||
- The first argument must be the full path to an existing image in PNG format
|
||||
- The second argument is the type of the filter to apply, either `sobel` or `scharr`
|
||||
- The third argument is the full path to an image of the result of applying the filter in the x direction. The directory will *not* be created and must exist
|
||||
- The fourth and last argument is the full path to an image of the result of applying the filter in the y direction. The directory will *not* be created and must exist.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The PNG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`sobek_scharr` doesn't have any specific execution requirements.
|
||||
@@ -5,11 +5,26 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
#include <boost/gil/image_processing/threshold.hpp>
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
// Demonstrates thresholding
|
||||
// Thresholding can either attribute an arbitrary value to pixels whose values are greater than the threshold
|
||||
// or can truncate the pixel values at an arbitrary maximum.
|
||||
// In particular, the function threshold_truncate accepts a mode and a direction.
|
||||
// Passing threshold_truncate_mode::threshold effectively truncates the values to the threshold, whereas
|
||||
// threshold_truncate_mode::zero sets them to 0.
|
||||
// The combination of mode and direction controls which pixels are modified:
|
||||
// - threshold and regular: truncates the pixels whose values are greater than the threshold
|
||||
// - threshold and inverse: truncates the pixels whose values are less than the threshold
|
||||
// - zero and regular: zeroes the pixels whose values are less than the threshold
|
||||
// - zero and inverse: zeroes the pixels whose values are greater than the threshold
|
||||
// See also:
|
||||
// adaptive_threshold.cpp - Adaptive thresholding
|
||||
|
||||
int main()
|
||||
{
|
||||
rgb8_image_t img;
|
||||
|
||||
19
example/threshold.md
Normal file
19
example/threshold.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Thresholding
|
||||
|
||||
Thresholding capabilities in GIL are demonstrated by the program `threshold`, compiled from the sources `example/threshold.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`threshold`
|
||||
|
||||
The program expects to find an image in the JPEG format in the current directory named `input.jpg`, and produces two images in JPEG format in the current directory in return, named `out-threshold-binary.jpg` and `out-threshold-binary-inv.jpg`, where a thresholding and an inverse thresholding, respectively, has been applied.
|
||||
|
||||
The program doesn't take any command line arguments.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`threshold` expects to find an image in the JPEG format in the current directory.
|
||||
@@ -5,13 +5,15 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
// Example file to demonstrate a way to compute histogram
|
||||
// Demonstrates a way to compute a histogram
|
||||
// This example relies on a colour-converting view to work with a greyscale view
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
|
||||
19
example/tutorial_histogram.md
Normal file
19
example/tutorial_histogram.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Histogram computation
|
||||
|
||||
Histogram computation capabilities in GIL are demonstrated by the program `tutorial_histogram`, compiled from the sources `example/tutorial_histogram.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`tutorial_histogram`
|
||||
|
||||
The program expects to find an image in the JPEG format in the current directory named `input.jpg`, and produces a text file named `out-histogram.txt`, in the current direction, where the histogram has been calculated..
|
||||
|
||||
The program doesn't take any command line arguments.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`tutorial_histogram` expects to find an image in the JPEG format in the current directory.
|
||||
@@ -5,9 +5,18 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/gil/extension/io/jpeg.hpp>
|
||||
|
||||
// Example to demonstrate a way to compute gradients along x-axis
|
||||
// Demonstrates how to compute gradients along the x-axis
|
||||
// This example converts the input image to a greyscale view via color_converted_view,
|
||||
// and then relies on the function static_transform to apply the operation halfdiff_cast_channels.
|
||||
// The result is captured in a view, initially blacked out via a call to fill_pixels (defined in
|
||||
// include/boost/gil/algorithm.hpp)
|
||||
// static_transform is defined in include/boost/gil/color_based_algorithm.hpp and applies an operation
|
||||
// to either a single source or two sources and a destination (as is the case here).
|
||||
// In this example, the gradient is calculated as half the difference between the two pixels surrounding x
|
||||
// in the loop in x_gradient.
|
||||
|
||||
using namespace boost::gil;
|
||||
|
||||
|
||||
19
example/x_gradient.md
Normal file
19
example/x_gradient.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Gradients calculations
|
||||
|
||||
Gradients calculations capabilities in GIL are demonstrated by the program `x_gradient`, compiled from the sources `example/x_gradient.cpp`.
|
||||
|
||||
## Synopsis
|
||||
`x_gradient`
|
||||
|
||||
The program expects to find an image in the JPEG format in the current directory named `input.jpg`, and produces an image in JPEG format in the current directory in return, named `out-x_gradient.jpg`, where the gradients have been captured.
|
||||
|
||||
The program doesn't take any command line arguments.
|
||||
|
||||
## Specific requirements
|
||||
|
||||
### Build requirements
|
||||
- A C++ compiler compliant with C++11 or above
|
||||
- The JPEG library installed and configured.
|
||||
|
||||
### Execution requirements
|
||||
`x_gradient` expects to find an image in the JPEG format in the current directory.
|
||||
@@ -166,9 +166,7 @@ void non_overlapping_interpolated_clahe(
|
||||
|
||||
std::vector<coord_t> sample_x;
|
||||
coord_t sample_x1 = tile_width_x / 2;
|
||||
coord_t sample_x2 = (tile_width_x + 1) / 2;
|
||||
coord_t sample_y1 = tile_width_y / 2;
|
||||
coord_t sample_y2 = (tile_width_y + 1) / 2;
|
||||
|
||||
auto extend_left = tile_width_x;
|
||||
auto extend_top = tile_width_y;
|
||||
|
||||
@@ -169,8 +169,6 @@ void histogram_matching(
|
||||
source_channel_t src_pixel_max = std::numeric_limits<source_channel_t>::max();
|
||||
ref_channel_t ref_pixel_min = std::numeric_limits<ref_channel_t>::min();
|
||||
ref_channel_t ref_pixel_max = std::numeric_limits<ref_channel_t>::max();
|
||||
dst_channel_t dst_pixel_min = std::numeric_limits<dst_channel_t>::min();
|
||||
dst_channel_t dst_pixel_max = std::numeric_limits<dst_channel_t>::max();
|
||||
|
||||
for (std::size_t i = 0; i < channels; i++)
|
||||
{
|
||||
|
||||
@@ -87,8 +87,6 @@ void hough_circle_transform_brute(const ImageView& input,
|
||||
const hough_parameter<std::ptrdiff_t>& y_parameter,
|
||||
ForwardIterator d_first, Rasterizer rasterizer)
|
||||
{
|
||||
const auto width = input.width();
|
||||
const auto height = input.height();
|
||||
for (std::size_t radius_index = 0; radius_index < radius_parameter.step_count; ++radius_index)
|
||||
{
|
||||
const auto radius = radius_parameter.start_point +
|
||||
|
||||
Reference in New Issue
Block a user