diff options
Diffstat (limited to 'src/boost/libs/gil/example')
28 files changed, 2178 insertions, 0 deletions
diff --git a/src/boost/libs/gil/example/CMakeLists.txt b/src/boost/libs/gil/example/CMakeLists.txt new file mode 100644 index 000000000..c16faf662 --- /dev/null +++ b/src/boost/libs/gil/example/CMakeLists.txt @@ -0,0 +1,45 @@ +# +# Copyright (c) 2017 Mateusz Loskot <mateusz at loskot dot net> +# All rights reserved. +# +# 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) +# +message(STATUS "Boost.GIL: Configuring examples") + +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) + file(GLOB_RECURSE _examples ${CMAKE_CURRENT_LIST_DIR}/*.cpp CONFIGURE_DEPEND) +else() + file(GLOB_RECURSE _examples ${CMAKE_CURRENT_LIST_DIR}/*.cpp) +endif() + +foreach(_example ${_examples}) + get_filename_component(_name ${_example} NAME_WE) + add_executable(example_${_name} ${_name}.cpp) + target_compile_definitions(example_${_name} PRIVATE BOOST_GIL_USE_CONCEPT_CHECK=1) + # Unfortunately, ALIAS of imported target is not supported + # see https://github.com/conan-io/conan/issues/2125 + if(BOOST_GIL_USE_CONAN) + target_link_libraries(example_${_name} + PRIVATE + gil_compile_options + gil_include_directories + Boost::disable_autolinking + Boost::filesystem + CONAN_PKG::libjpeg + CONAN_PKG::libpng + CONAN_PKG::libtiff) + else() + target_link_libraries(example_${_name} + PRIVATE + gil_compile_options + gil_include_directories + gil_dependencies) + endif() + + unset(_name) +endforeach() + +unset(_example) +unset(_examples) diff --git a/src/boost/libs/gil/example/Jamfile b/src/boost/libs/gil/example/Jamfile new file mode 100644 index 000000000..fc33ce319 --- /dev/null +++ b/src/boost/libs/gil/example/Jamfile @@ -0,0 +1,50 @@ +# Boost.GIL (Generic Image Library) - examples +# +# Copyright (c) 2018 Mateusz Loskot <mateusz@loskot.net> +# +# Use, modification and distribution is 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 ac ; +import regex ; +import testing ; + +using libjpeg : : : : true ; # work around bug on master + +project + : # requirements + ; + +# TODO: Add missing examples + +local sources = + adaptive_threshold.cpp + affine.cpp + convolution.cpp + convolve2d.cpp + dynamic_image.cpp + harris.cpp + hessian.cpp + histogram.cpp + interleaved_ptr.cpp + mandelbrot.cpp + packed_pixel.cpp + resize.cpp + sobel_scharr.cpp + threshold.cpp + x_gradient.cpp + ; + +local targets ; + +for local s in $(sources) +{ + targets += + [ compile $(s) : + [ ac.check-library /libjpeg//libjpeg : <library>/libjpeg//libjpeg : <build>no ] + ] + ; +} + +alias examples : $(targets) ; diff --git a/src/boost/libs/gil/example/README.md b/src/boost/libs/gil/example/README.md new file mode 100644 index 000000000..cee177088 --- /dev/null +++ b/src/boost/libs/gil/example/README.md @@ -0,0 +1,45 @@ +# Boost.GIL Examples + +This directory contains + +- examples of C++ programs using GIL +- configuration files for Boost.Build command line and CMake integration for popular IDEs. + +We provide Boost.Build (`Jamfile`) and CMake (`CMakeLists.txt`) +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. diff --git a/src/boost/libs/gil/example/adaptive_threshold.cpp b/src/boost/libs/gil/example/adaptive_threshold.cpp new file mode 100644 index 000000000..65f0f9ac1 --- /dev/null +++ b/src/boost/libs/gil/example/adaptive_threshold.cpp @@ -0,0 +1,33 @@ +// +// Copyright 2019 Miral Shah <miralshah2211@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) +// +#include <boost/gil.hpp> +#include <boost/gil/extension/io/png.hpp> +#include <iostream> + +using namespace boost::gil; + +int main() +{ + gray8_image_t img; + read_image("test_adaptive.png", img, png_tag{}); + gray8_image_t img_out(img.dimensions()); + + boost::gil::threshold_adaptive(const_view(img), view(img_out), 11, threshold_adaptive_method::mean, threshold_direction::regular, 2); + write_view("out-threshold-adaptive-mean.png", view(img_out), png_tag{}); + + boost::gil::threshold_adaptive(const_view(img), view(img_out), 11, threshold_adaptive_method::mean, threshold_direction::inverse, 2); + write_view("out-threshold-adaptive-mean-inv.png", view(img_out), png_tag{}); + + boost::gil::threshold_adaptive(const_view(img), view(img_out), 7, threshold_adaptive_method::gaussian, threshold_direction::regular, 2); + write_view("out-threshold-adaptive-gaussian.png", view(img_out), png_tag{}); + + boost::gil::threshold_adaptive(const_view(img), view(img_out), 11, threshold_adaptive_method::gaussian, threshold_direction::inverse, 2); + write_view("out-threshold-adaptive-gaussian-inv.png", view(img_out), png_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/affine.cpp b/src/boost/libs/gil/example/affine.cpp new file mode 100644 index 000000000..a54cfaa1d --- /dev/null +++ b/src/boost/libs/gil/example/affine.cpp @@ -0,0 +1,34 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/sampler.hpp> +#include <boost/gil/extension/numeric/resample.hpp> + +// Example for resample_pixels() in the numeric extension + +int main() +{ + namespace gil = boost::gil; + + gil::rgb8_image_t img; + gil::read_image("test.jpg", img, gil::jpeg_tag()); + + // test resample_pixels + // Transform the image by an arbitrary affine transformation using nearest-neighbor resampling + gil::rgb8_image_t transf(gil::rgb8_image_t::point_t(gil::view(img).dimensions() * 2)); + gil::fill_pixels(gil::view(transf), gil::rgb8_pixel_t(255, 0, 0)); // the background is red + + gil::matrix3x2<double> mat = + gil::matrix3x2<double>::get_translate(-gil::point<double>(200,250)) * + gil::matrix3x2<double>::get_rotate(-15*3.14/180.0); + gil::resample_pixels(const_view(img), gil::view(transf), mat, gil::nearest_neighbor_sampler()); + gil::write_view("out-affine.jpg", gil::view(transf), gil::jpeg_tag()); + + return 0; +} diff --git a/src/boost/libs/gil/example/b2/README.md b/src/boost/libs/gil/example/b2/README.md new file mode 100644 index 000000000..e4f56aaf8 --- /dev/null +++ b/src/boost/libs/gil/example/b2/README.md @@ -0,0 +1,40 @@ +# Boost.Build Configuration Examples + +Examples of `user-config.jam` for convenience of contributors and +users who wish to run complete build of Boost.GIL tests and examples. + +## Usage + +Copy any of the provided user configuration files to `%HOME%\user-config.jam` +on Windows or `$HOME/user-config.jam` on Linux. + +Refer to [Boost.Build User Manual](https://boostorg.github.io/build/) +for more details about use of configuration files. + +## Examples + +### `user-config-windows-vcpkg.jam` + +For Windows, provides minimal configuration to consume GIL dependencies +installed using [vcpkg](https://github.com/Microsoft/vcpkg) in `C:\vcpkg`: + +```console +C:\vcpkg --triplet x86-windows install libjpeg-turbo libpng tiff +C:\vcpkg --triplet x64-windows install libjpeg-turbo libpng tiff +``` + +The configuration recognises the two [vcpkg triplets](https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md) +corresponding to Boost.Build `address-model` variants, `32` and `64`. + + +```console +C:\boost-root> b2.exe toolset=msvc-14.2 address-model=64 libs/gil/test/extension/io//simple +Performing configuration checks +... + - libjpeg : yes + - zlib : yes + - libpng : yes + - libtiff : yes +``` + +Similarly, use `address-model=32` to request 32-bit build target. diff --git a/src/boost/libs/gil/example/b2/user-config-windows-vcpkg.jam b/src/boost/libs/gil/example/b2/user-config-windows-vcpkg.jam new file mode 100644 index 000000000..2844538cc --- /dev/null +++ b/src/boost/libs/gil/example/b2/user-config-windows-vcpkg.jam @@ -0,0 +1,53 @@ +project + : requirements + <address-model>32:<dll-path>C:/vcpkg/installed/x86-windows/bin + <address-model>64:<dll-path>C:/vcpkg/installed/x64-windows/bin + ; + +using libjpeg + : + : <include>C:/vcpkg/installed/x86-windows/include <search>C:/vcpkg/installed/x86-windows/lib + : <address-model>32 + ; + +using libjpeg + : + : <include>C:/vcpkg/installed/x64-windows/include <search>C:/vcpkg/installed/x64-windows/lib + : <address-model>64 + ; + +using libpng + : + : <include>C:/vcpkg/installed/x86-windows/include <search>C:/vcpkg/installed/x86-windows/lib + : <address-model>32 + ; + +using libpng + : + : <include>C:/vcpkg/installed/x64-windows/include <search>C:/vcpkg/installed/x64-windows/lib + : <address-model>64 + ; + +using libtiff + : + : <include>C:/vcpkg/installed/x86-windows/include <search>C:/vcpkg/installed/x86-windows/lib + : <address-model>32 + ; + +using libtiff + : + : <include>C:/vcpkg/installed/x64-windows/include <search>C:/vcpkg/installed/x64-windows/lib + : <address-model>64 + ; + +using zlib + : + : <include>C:/vcpkg/installed/x86-windows/include <search>C:/vcpkg/installed/x86-windows/lib + : <address-model>32 + ; + +using zlib + : + : <include>C:/vcpkg/installed/x64-windows/include <search>C:/vcpkg/installed/x64-windows/lib + : <address-model>64 + ; diff --git a/src/boost/libs/gil/example/clang-format/README.md b/src/boost/libs/gil/example/clang-format/README.md new file mode 100644 index 000000000..c7c68507b --- /dev/null +++ b/src/boost/libs/gil/example/clang-format/README.md @@ -0,0 +1,18 @@ +# Boost.GIL Clang-Format + +This is an _example_ of `.clang-format` file which offers _good enough_ +configuration and may be _useful_ when writing code for GIL, not required though. + +This is **not** a complete configuration! + +It does not cover all the recommended or preferred ways of formatting the code for GIL. +It may be necessary to manually tweak the formatting generated by this `.clang-format` file. +For example, there is a bug in clang-format that does not allow spacing and breaking +trailing return types properly ([here](http://lists.llvm.org/pipermail/cfe-users/2018-November/001421.html) +and [here](https://stackoverflow.com/a/57279663/151641)). +More in details can be found in the [brainstorm of .clang-format proposal](https://github.com/boostorg/gil/pull/87). + +It has been successfully used with clang-format 8 or later. + +If you wish to use this file with `clang-format`, copy it to the root directory of GIL +sources, to `libs/gil/.clang-format`. diff --git a/src/boost/libs/gil/example/cmake/CMakeSettings.json b/src/boost/libs/gil/example/cmake/CMakeSettings.json new file mode 100644 index 000000000..98947f9fe --- /dev/null +++ b/src/boost/libs/gil/example/cmake/CMakeSettings.json @@ -0,0 +1,433 @@ +{ + "_comment": { + "description": "Sample CMakeSettings.json for building Boost.GIL tests and examples. See https://go.microsoft.com//fwlink//?linkid=834763 for more information about CMake integration with Visual Studio 2017 and this file.", + "usage": "Copy to ${BOOST_ROOT}/libs/gil, then Visual Studio 2017 > File > Open > CMake > select ${BOOST_ROOT}/libs/gil/CMakeLists.txt" + }, + "environments": [ + { "BuildDir": "${workspaceRoot}\\_build" }, + { "InstallDir": "${workspaceRoot}\\_install" }, + { "DEFAULT_BUILD_TESTING": "OFF" }, + { "DEFAULT_Boost_ADDITIONAL_VERSIONS": "1.73;1.72;1.71" }, + { "DEFAULT_Boost_COMPILER": "-vc142;-vc141" }, + { "DEFAULT_Boost_DEBUG": "ON" }, + { "DEFAULT_GIL_BUILD_EXAMPLES": "ON" }, + { "DEFAULT_GIL_BUILD_HEADER_TESTS": "OFF" }, + { "DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE": "ON" }, + { "DEFAULT_GIL_ENABLE_EXT_IO": "ON" }, + { "DEFAULT_GIL_ENABLE_EXT_NUMERIC": "ON" }, + { "DEFAULT_GIL_ENABLE_EXT_TOOLBOX": "ON" }, + { "DEFAULT_GIL_USE_CONAN": "ON" }, + { "DEFAULT_GIL_USE_CLANG_TIDY": "OFF" } + ], + "configurations": [ + { + "name": "x64-Debug-Ninja", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_COMPILER", "value": "${env.DEFAULT_Boost_COMPILER}" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x64-Release-Ninja", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_COMPILER", "value": "${env.DEFAULT_Boost_COMPILER}" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x86-Debug-Ninja", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x86" ], + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x32" }, + { "name": "Boost_COMPILER", "value": "-vc142;-vc141" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "ON" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "ON" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "ON" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "ON" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "ON" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "ON" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "ON" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "OFF" } + ] + }, + { + "name": "x86-Release-Ninja", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ "msvc_x86" ], + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x32" }, + { "name": "Boost_COMPILER", "value": "${env.DEFAULT_Boost_COMPILER}" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x64-Debug-VS2019", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_COMPILER", "value": "${env.DEFAULT_Boost_COMPILER}" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x64-Release-VS2019", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Release", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_COMPILER", "value": "-vc142" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x86-Debug-VS2019", + "generator": "Visual Studio 16 2019", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x32" }, + { "name": "Boost_COMPILER", "value": "-vc142" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x86-Release-VS2019", + "generator": "Visual Studio 16 2019", + "configurationType": "Release", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x32" }, + { "name": "Boost_COMPILER", "value": "-vc142" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x64-Debug-VS2017", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_COMPILER", "value": "-vc141" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "${env.DEFAULT_GIL_USE_CONAN}" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x64-Release-VS2017", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Release", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "CMAKE_TOOLCHAIN_FILE", "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x86-Debug-VS2017", + "generator": "Visual Studio 15 2017", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "CMAKE_TOOLCHAIN_FILE", "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "x86-Release-VS2017", + "generator": "Visual Studio 15 2017", + "configurationType": "Release", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "buildCommandArgs": "-m", + "cmakeCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "CMAKE_TOOLCHAIN_FILE", "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "WSL-Debug-GCC", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "intelliSenseMode": "linux-gcc-x64", + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "WSL-Release-GCC", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "intelliSenseMode": "linux-gcc-x64", + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "WSL-Debug-clang", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_clang_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + }, + { + "name": "WSL-Release-clang", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${env.BuildDir}\\${name}", + "installRoot": "${env.InstallDir}\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_clang_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { "name": "BUILD_TESTING", "value": "${env.DEFAULT_BUILD_TESTING}"}, + { "name": "Boost_ADDITIONAL_VERSIONS", "value": "${env.DEFAULT_Boost_ADDITIONAL_VERSIONS}" }, + { "name": "Boost_ARCHITECTURE", "value": "-x64" }, + { "name": "Boost_DEBUG", "value": "${env.DEFAULT_Boost_DEBUG}" }, + { "name": "BOOST_GIL_BUILD_EXAMPLES", "value": "${env.DEFAULT_GIL_BUILD_EXAMPLES}" }, + { "name": "BOOST_GIL_BUILD_HEADER_TESTS", "value": "${env.DEFAULT_GIL_BUILD_HEADER_TESTS}" }, + { "name": "BOOST_GIL_ENABLE_EXT_DYNAMIC_IMAGE", "value": "${env.DEFAULT_GIL_ENABLE_EXT_DYNAMIC_IMAGE}" }, + { "name": "BOOST_GIL_ENABLE_EXT_IO", "value": "${env.DEFAULT_GIL_ENABLE_EXT_IO}" }, + { "name": "BOOST_GIL_ENABLE_EXT_NUMERIC", "value": "${env.DEFAULT_GIL_ENABLE_EXT_NUMERIC}" }, + { "name": "BOOST_GIL_ENABLE_EXT_TOOLBOX", "value": "${env.DEFAULT_GIL_ENABLE_EXT_TOOLBOX}" }, + { "name": "BOOST_GIL_USE_CONAN", "value": "OFF" }, + { "name": "BOOST_GIL_USE_CLANG_TIDY", "value": "${env.DEFAULT_GIL_USE_CLANG_TIDY}" } + ] + } + ] +} diff --git a/src/boost/libs/gil/example/cmake/README.md b/src/boost/libs/gil/example/cmake/README.md new file mode 100644 index 000000000..d66758073 --- /dev/null +++ b/src/boost/libs/gil/example/cmake/README.md @@ -0,0 +1,39 @@ +# CMake Configuration Examples + +Examples of configuration files for CMake integrations in popular IDEs are provided +for convenience of users and contributors who wish to build, run and debug +Boost.GIL tests and examples in the IDEs of their choice. + +## Visual Studio + +Example [CMakeSettings.json](CMakeSettings.json) file is provided for +the [CMake support in Visual Studio](https://go.microsoft.com//fwlink//?linkid=834763). + +Currently, the `CMakeSettings.json` provides configurations for the following +CMake generators: +- Ninja (default) +- Visual Studio 2017 and 2019 +- `Unix Makefiles` targeting Windows Subsystem for Linux (WSL) - requires Visual Studio 2019 IDE. + +Usage: + +1. Copy [CMakeSettings.json](CMakeSettings.json) to `${BOOST_ROOT}/libs/gil`. +2. In Visual Studio > File > Open > Folder... and select `${BOOST_ROOT}/libs/gil`. +3. Follow the [CMake support in Visual Studio](https://go.microsoft.com//fwlink//?linkid=834763) documentation. +4. [CMakeSettings.json schema reference](https://docs.microsoft.com/en-us/cpp/build/cmakesettings-reference?view=vs-2017) + to learn more about the configuration file itself. + +Optionally, edit [CMakeSettings.json](CMakeSettings.json) and tweak any options you require. + +## Visual Studio Code + +Example of [cmake-variants.yaml](cmake-variants.yaml) file is provided for +the [CMake Tools](https://github.com/vector-of-bool/vscode-cmake-tools) extension. + +Usage: + +1. Copy [cmake-variants.yaml](cmake-variants.yaml) to `${BOOST_ROOT}/libs/gil`. +2. Run `code ${BOOST_ROOT}/libs/gil` and the set of variants will be loaded. +3. Follow the [CMake Tools documentation](https://vector-of-bool.github.io/docs/vscode-cmake-tools/index.html). + +Optionally, edit [cmake-variants.yaml](cmake-variants.yaml)and tweak any options you require. diff --git a/src/boost/libs/gil/example/cmake/cmake-variants.yaml b/src/boost/libs/gil/example/cmake/cmake-variants.yaml new file mode 100644 index 000000000..c0638accc --- /dev/null +++ b/src/boost/libs/gil/example/cmake/cmake-variants.yaml @@ -0,0 +1,67 @@ +buildType: + default: debug + choices: + debug: + short: Debug + long: Emit debug information + buildType: Debug + release: + short: Release + long: Optimize generated code + buildType: RelWithDebInfo + +io: + default: 'no' + choices: + 'no': + short: No IO + long: Disable IO extension + settings: + BOOST_GIL_ENABLE_EXT_IO: no + 'yes': + short: IO + long: Enable IO extension + settings: + BOOST_GIL_ENABLE_EXT_IO: yes + +numeric: + default: 'no' + choices: + 'no': + short: No Numeric + long: Disable Numeric extension + settings: + BOOST_GIL_ENABLE_EXT_NUMERIC: no + 'yes': + short: Numeric + long: Enable Numeric extension + settings: + BOOST_GIL_ENABLE_EXT_NUMERIC: yes + +toolbox: + default: 'no' + choices: + 'no': + short: No Toolbox + long: Disable Toolbox extension + settings: + BOOST_GIL_ENABLE_EXT_TOOLBOX: no + 'yes': + short: Toolbox + long: Enable Toolbox extension + settings: + BOOST_GIL_ENABLE_EXT_TOOLBOX: yes + +headers: + default: 'no' + choices: + 'no': + short: No Header Tests + long: Disable header tests extension + settings: + BOOST_GIL_BUILD_HEADER_TESTS: no + 'yes': + short: Header Tests + long: Enable header tests extension + settings: + BOOST_GIL_BUILD_HEADER_TESTS: yes diff --git a/src/boost/libs/gil/example/convolution.cpp b/src/boost/libs/gil/example/convolution.cpp new file mode 100644 index 000000000..4844f35aa --- /dev/null +++ b/src/boost/libs/gil/example/convolution.cpp @@ -0,0 +1,69 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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 + +int main() { + using namespace boost::gil; + + rgb8_image_t img; + read_image("test.jpg", img, jpeg_tag{}); + + // Convolve the rows and the columns of the image with a fixed kernel + rgb8_image_t convolved(img); + + // radius-1 Gaussian kernel, size 9 + float gaussian_1[]={0.00022923296f,0.0059770769f,0.060597949f,0.24173197f,0.38292751f, + 0.24173197f,0.060597949f,0.0059770769f,0.00022923296f}; + /* + // radius-2 Gaussian kernel, size 15 + float gaussian_2[]={ + 0.00048869418f,0.0024031631f,0.0092463447f, + 0.027839607f,0.065602221f,0.12099898f,0.17469721f, + 0.19744757f, + 0.17469721f,0.12099898f,0.065602221f,0.027839607f, + 0.0092463447f,0.0024031631f,0.00048869418f + }; + //radius-3 Gaussian kernel, size 23 + float gaussian_3[]={ + 0.00016944126f,0.00053842377f,0.0015324751f,0.0039068931f, + 0.0089216027f,0.018248675f,0.033434924f,0.054872241f, + 0.080666073f,0.10622258f,0.12529446f, + 0.13238440f, + 0.12529446f,0.10622258f,0.080666073f, + 0.054872241f,0.033434924f,0.018248675f,0.0089216027f, + 0.0039068931f,0.0015324751f,0.00053842377f,0.00016944126f + }; + //radius-4 Gaussian kernel, size 29 + float gaussian_4[]={ + 0.00022466264f,0.00052009715f,0.0011314391f,0.0023129794f, + 0.0044433107f,0.0080211498f,0.013606987f,0.021691186f, + 0.032493830f,0.045742013f,0.060509924f,0.075220309f, + 0.087870099f,0.096459411f,0.099505201f,0.096459411f,0.087870099f, + 0.075220309f,0.060509924f,0.045742013f,0.032493830f, + 0.021691186f,0.013606987f,0.0080211498f,0.0044433107f, + 0.0023129794f,0.0011314391f,0.00052009715f,0.00022466264f, + }; + */ + + kernel_1d_fixed<float,9> kernel(gaussian_1,4); + convolve_rows_fixed<rgb32f_pixel_t>(const_view(convolved),kernel,view(convolved)); + convolve_cols_fixed<rgb32f_pixel_t>(const_view(convolved),kernel,view(convolved)); + write_view("out-convolution.jpg", view(convolved), jpeg_tag{}); + + // This is how to use a resizable kernel + kernel_1d<float> kernel2(gaussian_1,9,4); + convolve_rows<rgb32f_pixel_t>(const_view(img),kernel2,view(img)); + convolve_cols<rgb32f_pixel_t>(const_view(img),kernel2,view(img)); + write_view("out-convolution2.jpg", view(img), jpeg_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/convolve2d.cpp b/src/boost/libs/gil/example/convolve2d.cpp new file mode 100644 index 000000000..338f49a3a --- /dev/null +++ b/src/boost/libs/gil/example/convolve2d.cpp @@ -0,0 +1,41 @@ +#include <vector> +#include <iostream> +#include <boost/gil/extension/numeric/kernel.hpp> +#include <boost/gil/extension/numeric/convolve.hpp> +#include <boost/gil/extension/io/png.hpp> + +#include <boost/gil/extension/io/jpeg.hpp> +using namespace boost::gil; +using namespace std; +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()); + + std::vector<float> v(9, 1.0f / 9.0f); + 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{}); + + + //------------------------------------// + 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(); + + return 0; +} diff --git a/src/boost/libs/gil/example/dynamic_image.cpp b/src/boost/libs/gil/example/dynamic_image.cpp new file mode 100644 index 000000000..0b3c5da45 --- /dev/null +++ b/src/boost/libs/gil/example/dynamic_image.cpp @@ -0,0 +1,23 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/dynamic_image/any_image.hpp> +#include <boost/gil/extension/io/jpeg.hpp> +#include <boost/mp11.hpp> + +int main() +{ + namespace gil = boost::gil; + + using my_images_t = boost::mp11::mp_list<gil::gray8_image_t, gil::rgb8_image_t, gil::gray16_image_t, gil::rgb16_image_t>; + gil::any_image<my_images_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()); +} diff --git a/src/boost/libs/gil/example/harris.cpp b/src/boost/libs/gil/example/harris.cpp new file mode 100644 index 000000000..f860105d2 --- /dev/null +++ b/src/boost/libs/gil/example/harris.cpp @@ -0,0 +1,207 @@ +// +// Copyright 2019 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) +// +#include <boost/gil/image.hpp> +#include <boost/gil/image_view.hpp> +#include <boost/gil/extension/io/png.hpp> +#include <boost/gil/image_processing/numeric.hpp> +#include <boost/gil/image_processing/harris.hpp> +#include <boost/gil/extension/numeric/convolve.hpp> +#include <vector> +#include <functional> +#include <set> +#include <iostream> +#include <fstream> + +namespace gil = boost::gil; + +// some images might produce artifacts +// when converted to grayscale, +// which was previously observed on +// canny edge detector for test input +// used for this example +gil::gray8_image_t to_grayscale(gil::rgb8_view_t original) +{ + gil::gray8_image_t output_image(original.dimensions()); + auto output = gil::view(output_image); + constexpr double max_channel_intensity = (std::numeric_limits<std::uint8_t>::max)(); + for (long int y = 0; y < original.height(); ++y) { + for (long int x = 0; x < original.width(); ++x) { + // scale the values into range [0, 1] and calculate linear intensity + double red_intensity = original(x, y).at(std::integral_constant<int, 0>{}) + / max_channel_intensity; + double green_intensity = original(x, y).at(std::integral_constant<int, 1>{}) + / max_channel_intensity; + double blue_intensity = original(x, y).at(std::integral_constant<int, 2>{}) + / max_channel_intensity; + auto linear_luminosity = 0.2126 * red_intensity + + 0.7152 * green_intensity + + 0.0722 * blue_intensity; + + // perform gamma adjustment + double gamma_compressed_luminosity = 0; + if (linear_luminosity < 0.0031308) { + gamma_compressed_luminosity = linear_luminosity * 12.92; + } else { + gamma_compressed_luminosity = 1.055 * std::pow(linear_luminosity, 1 / 2.4) - 0.055; + } + + // since now it is scaled, descale it back + output(x, y) = gamma_compressed_luminosity * max_channel_intensity; + } + } + + return output_image; +} + +void apply_gaussian_blur(gil::gray8_view_t input_view, gil::gray8_view_t output_view) +{ + constexpr static auto filterHeight = 5ull; + constexpr static auto filterWidth = 5ull; + constexpr static double filter[filterHeight][filterWidth] = + { + 2, 4, 6, 4, 2, + 4, 9, 12, 9, 4, + 5, 12, 15, 12, 5, + 4, 9, 12, 9, 4, + 2, 4, 5, 4, 2, + }; + constexpr double factor = 1.0 / 159; + constexpr double bias = 0.0; + + const auto height = input_view.height(); + const auto width = input_view.width(); + for (long x = 0; x < width; ++x) { + for (long y = 0; y < height; ++y) { + double intensity = 0.0; + for (size_t filter_y = 0; filter_y < filterHeight; ++filter_y) { + for (size_t filter_x = 0; filter_x < filterWidth; ++filter_x) { + int image_x = x - filterWidth / 2 + filter_x; + int image_y = y - filterHeight / 2 + filter_y; + if (image_x >= input_view.width() || image_x < 0 + || image_y >= input_view.height() || image_y < 0) { + continue; + } + auto& pixel = input_view(image_x, image_y); + intensity += pixel.at(std::integral_constant<int, 0>{}) + * filter[filter_y][filter_x]; + } + } + auto& pixel = output_view(gil::point_t(x, y)); + pixel = (std::min)((std::max)(int(factor * intensity + bias), 0), 255); + } + + } +} + +std::vector<gil::point_t> suppress( + gil::gray32f_view_t harris_response, + double harris_response_threshold) +{ + std::vector<gil::point_t> corner_points; + for (gil::gray32f_view_t::coord_t y = 1; y < harris_response.height() - 1; ++y) + { + for (gil::gray32f_view_t::coord_t x = 1; x < harris_response.width() - 1; ++x) + { + auto value = [](gil::gray32f_pixel_t pixel) { + return pixel.at(std::integral_constant<int, 0>{}); + }; + double values[9] = { + value(harris_response(x - 1, y - 1)), + value(harris_response(x, y - 1)), + value(harris_response(x + 1, y - 1)), + value(harris_response(x - 1, y)), + value(harris_response(x, y)), + value(harris_response(x + 1, y)), + value(harris_response(x - 1, y + 1)), + value(harris_response(x, y + 1)), + value(harris_response(x + 1, y + 1)) + }; + + auto maxima = *std::max_element( + values, + values + 9, + [](double lhs, double rhs) + { + return lhs < rhs; + } + ); + + if (maxima == value(harris_response(x, y)) + && std::count(values, values + 9, maxima) == 1 + && maxima >= harris_response_threshold) + { + corner_points.emplace_back(x, y); + } + } + } + + return corner_points; +} + +int main(int argc, char* argv[]) +{ + if (argc != 6) + { + std::cout << "usage: " << argv[0] << " <input.png> <odd-window-size>" + " <discrimination-constant> <harris-response-threshold> <output.png>\n"; + return -1; + } + + std::size_t window_size = std::stoul(argv[2]); + double discrimnation_constant = std::stof(argv[3]); + long harris_response_threshold = std::stol(argv[4]); + + gil::rgb8_image_t input_image; + + gil::read_image(argv[1], input_image, gil::png_tag{}); + + auto input_view = gil::view(input_image); + 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); + gil::gray16s_image_t x_gradient_image(grayscaled.dimensions()); + gil::gray16s_image_t y_gradient_image(grayscaled.dimensions()); + + auto x_gradient = gil::view(x_gradient_image); + auto y_gradient = gil::view(y_gradient_image); + auto scharr_x = gil::generate_dx_scharr(); + gil::detail::convolve_2d(smoothed, scharr_x, x_gradient); + auto scharr_y = gil::generate_dy_scharr(); + gil::detail::convolve_2d(smoothed, scharr_y, y_gradient); + + gil::gray32f_image_t m11(x_gradient.dimensions()); + gil::gray32f_image_t m12_21(x_gradient.dimensions()); + gil::gray32f_image_t m22(x_gradient.dimensions()); + gil::compute_tensor_entries( + x_gradient, + y_gradient, + gil::view(m11), + gil::view(m12_21), + gil::view(m22) + ); + + gil::gray32f_image_t harris_response(x_gradient.dimensions()); + auto gaussian_kernel = gil::generate_gaussian_kernel(window_size, 0.84089642); + gil::compute_harris_responses( + gil::view(m11), + gil::view(m12_21), + gil::view(m22), + gaussian_kernel, + discrimnation_constant, + gil::view(harris_response) + ); + + auto corner_points = suppress(gil::view(harris_response), harris_response_threshold); + for (auto point: corner_points) + { + input_view(point) = gil::rgb8_pixel_t(0, 0, 0); + input_view(point).at(std::integral_constant<int, 1>{}) = 255; + } + gil::write_view(argv[5], input_view, gil::png_tag{}); +} diff --git a/src/boost/libs/gil/example/hessian.cpp b/src/boost/libs/gil/example/hessian.cpp new file mode 100644 index 000000000..d12f51ddb --- /dev/null +++ b/src/boost/libs/gil/example/hessian.cpp @@ -0,0 +1,208 @@ +#include <boost/gil/image.hpp> +#include <boost/gil/image_view.hpp> +#include <boost/gil/image_processing/numeric.hpp> +#include <boost/gil/image_processing/hessian.hpp> +#include <boost/gil/extension/io/png.hpp> +#include <vector> +#include <functional> +#include <set> +#include <iostream> +#include <fstream> + +namespace gil = boost::gil; + +// some images might produce artifacts +// when converted to grayscale, +// which was previously observed on +// canny edge detector for test input +// used for this example. +// the algorithm here follows sRGB gamma definition +// taken from here (luminance calculation): +// https://en.wikipedia.org/wiki/Grayscale +gil::gray8_image_t to_grayscale(gil::rgb8_view_t original) +{ + gil::gray8_image_t output_image(original.dimensions()); + auto output = gil::view(output_image); + constexpr double max_channel_intensity = (std::numeric_limits<std::uint8_t>::max)(); + for (long int y = 0; y < original.height(); ++y) + { + for (long int x = 0; x < original.width(); ++x) + { + // scale the values into range [0, 1] and calculate linear intensity + auto& p = original(x, y); + double red_intensity = p.at(std::integral_constant<int, 0>{}) + / max_channel_intensity; + double green_intensity = p.at(std::integral_constant<int, 1>{}) + / max_channel_intensity; + double blue_intensity = p.at(std::integral_constant<int, 2>{}) + / max_channel_intensity; + auto linear_luminosity = 0.2126 * red_intensity + + 0.7152 * green_intensity + + 0.0722 * blue_intensity; + + // perform gamma adjustment + double gamma_compressed_luminosity = 0; + if (linear_luminosity < 0.0031308) + { + gamma_compressed_luminosity = linear_luminosity * 12.92; + } else + { + gamma_compressed_luminosity = 1.055 * std::pow(linear_luminosity, 1 / 2.4) - 0.055; + } + + // since now it is scaled, descale it back + output(x, y) = gamma_compressed_luminosity * max_channel_intensity; + } + } + + return output_image; +} + +void apply_gaussian_blur(gil::gray8_view_t input_view, gil::gray8_view_t output_view) +{ + constexpr static auto filter_height = 5ull; + constexpr static auto filter_width = 5ull; + constexpr static double filter[filter_height][filter_width] = + { + 2, 4, 6, 4, 2, + 4, 9, 12, 9, 4, + 5, 12, 15, 12, 5, + 4, 9, 12, 9, 4, + 2, 4, 5, 4, 2, + }; + constexpr double factor = 1.0 / 159; + constexpr double bias = 0.0; + + const auto height = input_view.height(); + const auto width = input_view.width(); + for (std::ptrdiff_t x = 0; x < width; ++x) + { + for (std::ptrdiff_t y = 0; y < height; ++y) + { + double intensity = 0.0; + for (std::ptrdiff_t filter_y = 0; filter_y < filter_height; ++filter_y) + { + for (std::ptrdiff_t filter_x = 0; filter_x < filter_width; ++filter_x) + { + int image_x = x - filter_width / 2 + filter_x; + int image_y = y - filter_height / 2 + filter_y; + if (image_x >= input_view.width() || image_x < 0 || + image_y >= input_view.height() || image_y < 0) + { + continue; + } + const auto& pixel = input_view(image_x, image_y); + intensity += pixel.at(std::integral_constant<int, 0>{}) + * filter[filter_y][filter_x]; + } + } + auto& pixel = output_view(gil::point_t(x, y)); + pixel = (std::min)((std::max)(int(factor * intensity + bias), 0), 255); + } + + } +} + +std::vector<gil::point_t> suppress( + gil::gray32f_view_t harris_response, + double harris_response_threshold) +{ + std::vector<gil::point_t> corner_points; + for (gil::gray32f_view_t::coord_t y = 1; y < harris_response.height() - 1; ++y) + { + for (gil::gray32f_view_t::coord_t x = 1; x < harris_response.width() - 1; ++x) + { + auto value = [](gil::gray32f_pixel_t pixel) { + return pixel.at(std::integral_constant<int, 0>{}); + }; + double values[9] = { + value(harris_response(x - 1, y - 1)), + value(harris_response(x, y - 1)), + value(harris_response(x + 1, y - 1)), + value(harris_response(x - 1, y)), + value(harris_response(x, y)), + value(harris_response(x + 1, y)), + value(harris_response(x - 1, y + 1)), + value(harris_response(x, y + 1)), + value(harris_response(x + 1, y + 1)) + }; + + auto maxima = *std::max_element( + values, + values + 9, + [](double lhs, double rhs) + { + return lhs < rhs; + } + ); + + if (maxima == value(harris_response(x, y)) + && std::count(values, values + 9, maxima) == 1 + && maxima >= harris_response_threshold) + { + corner_points.emplace_back(x, y); + } + } + } + + return corner_points; +} + +int main(int argc, char* argv[]) { + if (argc != 5) + { + std::cout << "usage: " << argv[0] << " <input.png> <odd-window-size>" + " <hessian-response-threshold> <output.png>\n"; + return -1; + } + + std::size_t window_size = std::stoul(argv[2]); + long hessian_determinant_threshold = std::stol(argv[3]); + + gil::rgb8_image_t input_image; + + gil::read_image(argv[1], input_image, gil::png_tag{}); + + auto input_view = gil::view(input_image); + 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); + gil::gray16s_image_t x_gradient_image(grayscaled.dimensions()); + gil::gray16s_image_t y_gradient_image(grayscaled.dimensions()); + + auto x_gradient = gil::view(x_gradient_image); + auto y_gradient = gil::view(y_gradient_image); + auto scharr_x = gil::generate_dx_scharr(); + gil::detail::convolve_2d(smoothed, scharr_x, x_gradient); + auto scharr_y = gil::generate_dy_scharr(); + gil::detail::convolve_2d(smoothed, scharr_y, y_gradient); + + gil::gray32f_image_t m11(x_gradient.dimensions()); + gil::gray32f_image_t m12_21(x_gradient.dimensions()); + gil::gray32f_image_t m22(x_gradient.dimensions()); + gil::compute_hessian_entries( + x_gradient, + y_gradient, + gil::view(m11), + gil::view(m12_21), + gil::view(m22) + ); + + gil::gray32f_image_t hessian_response(x_gradient.dimensions()); + auto gaussian_kernel = gil::generate_gaussian_kernel(window_size, 0.84089642); + gil::compute_hessian_responses( + gil::view(m11), + gil::view(m12_21), + gil::view(m22), + gaussian_kernel, + gil::view(hessian_response) + ); + + auto corner_points = suppress(gil::view(hessian_response), hessian_determinant_threshold); + for (auto point: corner_points) { + input_view(point) = gil::rgb8_pixel_t(0, 0, 0); + input_view(point).at(std::integral_constant<int, 1>{}) = 255; + } + gil::write_view(argv[4], input_view, gil::png_tag{}); +} diff --git a/src/boost/libs/gil/example/histogram.cpp b/src/boost/libs/gil/example/histogram.cpp new file mode 100644 index 000000000..b1b489642 --- /dev/null +++ b/src/boost/libs/gil/example/histogram.cpp @@ -0,0 +1,49 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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 <algorithm> +#include <fstream> + +// Example file to demonstrate a way to compute histogram + +using namespace boost::gil; + +template <typename GrayView, typename R> +void gray_image_hist(GrayView const& img_view, R& hist) +{ + for (auto it = img_view.begin(); it != img_view.end(); ++it) + ++hist[*it]; + + // Alternatively, prefer the algorithm with lambda + // for_each_pixel(img_view, [&hist](gray8_pixel_t const& pixel) { + // ++hist[pixel]; + // }); +} + +template <typename V, typename R> +void get_hist(const V& img_view, R& hist) { + gray_image_hist(color_converted_view<gray8_pixel_t>(img_view), hist); +} + +int main() { + rgb8_image_t img; + read_image("test.jpg", img, jpeg_tag()); + + int histogram[256]; + std::fill(histogram,histogram + 256, 0); + get_hist(const_view(img), histogram); + + std::fstream histo_file("out-histogram.txt", std::ios::out); + for(std::size_t ii = 0; ii < 256; ++ii) + histo_file << histogram[ii] << std::endl; + histo_file.close(); + + return 0; +} diff --git a/src/boost/libs/gil/example/interleaved_ptr.cpp b/src/boost/libs/gil/example/interleaved_ptr.cpp new file mode 100644 index 000000000..df80003b8 --- /dev/null +++ b/src/boost/libs/gil/example/interleaved_ptr.cpp @@ -0,0 +1,69 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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 +// +#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 + +// FIXME: Review and remove if possible: gcc doesn't compile unless we forward-declare at_c before we include gil... +namespace boost { namespace gil { + template <typename ChannelReference, typename Layout> struct interleaved_ref; + template <typename ColorBase> struct element_reference_type; + + template <int K, typename ChannelReference, typename Layout> + typename element_reference_type<interleaved_ref<ChannelReference,Layout>>::type + at_c(const interleaved_ref<ChannelReference,Layout>& p); +} } + +#include <boost/gil.hpp> +#include <boost/gil/extension/io/jpeg.hpp> + +#include <iostream> + +#include "interleaved_ptr.hpp" + +int main(int argc, char* argv[]) +{ + using namespace boost::gil; + + using rgb8_interleaved_ptr = interleaved_ptr<unsigned char*, rgb_layout_t>; + using rgb8c_interleaved_ptr = interleaved_ptr<unsigned char const*, rgb_layout_t>; + + boost::function_requires<MutablePixelIteratorConcept<rgb8_interleaved_ptr>>(); + boost::function_requires<PixelIteratorConcept<rgb8c_interleaved_ptr>>(); + boost::function_requires<MemoryBasedIteratorConcept<memory_based_step_iterator<rgb8_interleaved_ptr>> >(); + + boost::function_requires<MutablePixelConcept<rgb8_interleaved_ptr::value_type>>(); + boost::function_requires<PixelConcept<rgb8c_interleaved_ptr::value_type>>(); + + using rgb8_interleaved_view_t = type_from_x_iterator<rgb8_interleaved_ptr >::view_t; + using rgb8c_interleaved_view_t = type_from_x_iterator<rgb8c_interleaved_ptr>::view_t; + + boost::function_requires<MutableImageViewConcept<rgb8_interleaved_view_t>>(); + boost::function_requires<ImageViewConcept<rgb8c_interleaved_view_t>>(); + + rgb8_image_t img; + read_image("test.jpg", img, jpeg_tag{}); + + // Get a raw pointer to the RGB buffer + unsigned char* raw_ptr=&view(img)[0][0]; + + // Construct a view from it, without casting it to rgb8_pixel_t* + rgb8_interleaved_view_t src_view=interleaved_view(img.width(),img.height(),rgb8_interleaved_ptr(raw_ptr), + view(img).pixels().row_size()); + + // Apply view transformations and algorithms on it + write_view("out-interleaved_ptr.jpg",nth_channel_view(flipped_up_down_view(src_view),1), jpeg_tag{}); + + return 0; +} + + diff --git a/src/boost/libs/gil/example/interleaved_ptr.hpp b/src/boost/libs/gil/example/interleaved_ptr.hpp new file mode 100644 index 000000000..a60fc9d43 --- /dev/null +++ b/src/boost/libs/gil/example/interleaved_ptr.hpp @@ -0,0 +1,201 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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 +// +#ifndef BOOST_GIL_EXAMPLE_INTERLEAVED_PTR_HPP +#define BOOST_GIL_EXAMPLE_INTERLEAVED_PTR_HPP + +#include <boost/gil.hpp> +#include <boost/mp11.hpp> + +#include <type_traits> + +#include "interleaved_ref.hpp" + +// Example on how to create a pixel iterator + +namespace boost { namespace gil { + +// A model of an interleaved pixel iterator. Contains an iterator to the first channel of the current pixel +// +// Models: +// MutablePixelIteratorConcept +// PixelIteratorConcept +// boost_concepts::RandomAccessTraversalConcept +// PixelBasedConcept +// HomogeneousPixelBasedConcept +// PixelBasedConcept +// ByteAdvanceableConcept +// HasDynamicXStepTypeConcept + +template <typename ChannelPtr, // Models Channel Iterator (examples: unsigned char* or const unsigned char*) + typename Layout> // A layout (includes the color space and channel ordering) +struct interleaved_ptr : boost::iterator_facade + < + interleaved_ptr<ChannelPtr, Layout>, + pixel<typename std::iterator_traits<ChannelPtr>::value_type, Layout>, + boost::random_access_traversal_tag, + interleaved_ref<typename std::iterator_traits<ChannelPtr>::reference, Layout> const + > +{ +private: + using parent_t = boost::iterator_facade + < + interleaved_ptr<ChannelPtr, Layout>, + pixel<typename std::iterator_traits<ChannelPtr>::value_type, Layout>, + boost::random_access_traversal_tag, + interleaved_ref + < + typename std::iterator_traits<ChannelPtr>::reference, + Layout + > const + >; + + using channel_t = typename std::iterator_traits<ChannelPtr>::value_type; + +public: + using reference = typename parent_t::reference; + using difference_type = typename parent_t::difference_type; + + interleaved_ptr() {} + interleaved_ptr(const interleaved_ptr& ptr) : _channels(ptr._channels) {} + template <typename CP> interleaved_ptr(const interleaved_ptr<CP,Layout>& ptr) : _channels(ptr._channels) {} + + interleaved_ptr(const ChannelPtr& channels) : _channels(channels) {} + + // Construct from a pointer to the reference type. Not required by concepts but important + interleaved_ptr(reference* pix) : _channels(&((*pix)[0])) {} + interleaved_ptr& operator=(reference* pix) { _channels=&((*pix)[0]); return *this; } + + /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference + /// We require our own reference because it is registered in iterator_traits + reference operator[](difference_type d) const { return memunit_advanced_ref(*this,d*sizeof(channel_t));} + + // Put this for every iterator whose reference is a proxy type + reference operator->() const { return **this; } + + // Channels accessor (not required by any concept) + const ChannelPtr& channels() const { return _channels; } + ChannelPtr& channels() { return _channels; } + + // Not required by concepts but useful + static const std::size_t num_channels = mp11::mp_size<typename Layout::color_space_t>::value; +private: + ChannelPtr _channels; + friend class boost::iterator_core_access; + template <typename CP, typename L> friend struct interleaved_ptr; + + void increment() { _channels+=num_channels; } + void decrement() { _channels-=num_channels; } + void advance(std::ptrdiff_t d) { _channels+=num_channels*d; } + + std::ptrdiff_t distance_to(const interleaved_ptr& it) const { return (it._channels-_channels)/num_channels; } + bool equal(const interleaved_ptr& it) const { return _channels==it._channels; } + + reference dereference() const { return reference(_channels); } +}; + +///////////////////////////// +// PixelIteratorConcept +///////////////////////////// + +// To get from the channel pointer a channel pointer to const, we have to go through the channel traits, which take a model of channel +// So we can get a model of channel from the channel pointer via iterator_traits. Notice that we take the iterator_traits::reference and not +// iterator_traits::value_type. This is because sometimes multiple reference and pointer types share the same value type. An example of this is +// GIL's planar reference and iterator ("planar_pixel_reference" and "planar_pixel_iterator") which share the class "pixel" as the value_type. The +// class "pixel" is also the value type for interleaved pixel references. Here we are dealing with channels, not pixels, but the principles still apply. +template <typename ChannelPtr, typename Layout> +struct const_iterator_type<interleaved_ptr<ChannelPtr,Layout>> { +private: + using channel_ref_t = typename std::iterator_traits<ChannelPtr>::reference; + using channel_const_ptr_t = typename channel_traits<channel_ref_t>::const_pointer; +public: + using type = interleaved_ptr<channel_const_ptr_t, Layout>; +}; + +template <typename ChannelPtr, typename Layout> +struct iterator_is_mutable<interleaved_ptr<ChannelPtr,Layout>> : std::true_type {}; +template <typename Channel, typename Layout> +struct iterator_is_mutable<interleaved_ptr<const Channel*,Layout>> : std::false_type {}; + +template <typename ChannelPtr, typename Layout> +struct is_iterator_adaptor<interleaved_ptr<ChannelPtr,Layout>> : std::false_type {}; + +///////////////////////////// +// PixelBasedConcept +///////////////////////////// + +template <typename ChannelPtr, typename Layout> +struct color_space_type<interleaved_ptr<ChannelPtr,Layout>> +{ + using type = typename Layout::color_space_t; +}; + +template <typename ChannelPtr, typename Layout> +struct channel_mapping_type<interleaved_ptr<ChannelPtr,Layout>> +{ + using type = typename Layout::channel_mapping_t; +}; + +template <typename ChannelPtr, typename Layout> +struct is_planar<interleaved_ptr<ChannelPtr,Layout>> : std::false_type {}; + +///////////////////////////// +// HomogeneousPixelBasedConcept +///////////////////////////// + +template <typename ChannelPtr, typename Layout> +struct channel_type<interleaved_ptr<ChannelPtr, Layout>> +{ + using type = typename std::iterator_traits<ChannelPtr>::value_type; +}; + +///////////////////////////// +// ByteAdvanceableConcept +///////////////////////////// + +template <typename ChannelPtr, typename Layout> +inline std::ptrdiff_t memunit_step(const interleaved_ptr<ChannelPtr,Layout>&) { + return sizeof(typename std::iterator_traits<ChannelPtr>::value_type)* // size of each channel in bytes + interleaved_ptr<ChannelPtr,Layout>::num_channels; // times the number of channels +} + +template <typename ChannelPtr, typename Layout> +inline std::ptrdiff_t memunit_distance(const interleaved_ptr<ChannelPtr,Layout>& p1, const interleaved_ptr<ChannelPtr,Layout>& p2) { + return memunit_distance(p1.channels(),p2.channels()); +} + +template <typename ChannelPtr, typename Layout> +inline void memunit_advance(interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { + memunit_advance(p.channels(), diff); +} + +template <typename ChannelPtr, typename Layout> +inline interleaved_ptr<ChannelPtr,Layout> memunit_advanced(const interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { + interleaved_ptr<ChannelPtr,Layout> ret=p; + memunit_advance(ret, diff); + return ret; +} + +template <typename ChannelPtr, typename Layout> +inline typename interleaved_ptr<ChannelPtr,Layout>::reference memunit_advanced_ref(const interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { + interleaved_ptr<ChannelPtr,Layout> ret=p; + memunit_advance(ret, diff); + return *ret; +} + +///////////////////////////// +// HasDynamicXStepTypeConcept +///////////////////////////// + +template <typename ChannelPtr, typename Layout> +struct dynamic_x_step_type<interleaved_ptr<ChannelPtr, Layout>> +{ + using type = memory_based_step_iterator<interleaved_ptr<ChannelPtr, Layout>>; +}; +} } // namespace boost::gil + +#endif diff --git a/src/boost/libs/gil/example/interleaved_ref.hpp b/src/boost/libs/gil/example/interleaved_ref.hpp new file mode 100644 index 000000000..837e7f222 --- /dev/null +++ b/src/boost/libs/gil/example/interleaved_ref.hpp @@ -0,0 +1,158 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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 +// +#ifndef BOOST_GIL_EXAMPLE_INTERLEAVED_REF_HPP +#define BOOST_GIL_EXAMPLE_INTERLEAVED_REF_HPP + +#include <boost/gil.hpp> +#include <boost/gil/extension/dynamic_image/dynamic_image_all.hpp> + +#include <type_traits> + +// Example on how to create a new model of a pixel reference + +namespace boost { namespace gil { + +// A model of an interleaved pixel reference. Holds a pointer to the first channel +// MODELS: +// MutableHomogeneousPixelConcept +// MutableHomogeneousColorBaseConcept +// MutableColorBaseConcept +// HomogeneousColorBaseConcept +// ColorBaseConcept +// HomogeneousPixelBasedConcept +// PixelBasedConcept +// +// For planar reference proxies to work properly, all of their methods must be const-qualified +// and their iterator's reference type must be const-qualified. +// Mutability of the reference proxy is part of its type (in this case, depends on the mutability of ChannelReference) + +/// \tparam ChannelReference - Models ChannelConcept. +/// A channel reference, unsigned char& or const unsigned char& +/// \tparam Layout - A layout (includes the color space and channel ordering) +template <typename ChannelReference, typename Layout> +struct interleaved_ref +{ +private: + using channel_t = typename channel_traits<ChannelReference>::value_type; + using channel_pointer_t = typename channel_traits<ChannelReference>::pointer; + using channel_reference_t = typename channel_traits<ChannelReference>::reference; + using channel_const_reference_t = typename channel_traits<ChannelReference>::const_reference; + +public: + using layout_t = Layout; // Required by ColorBaseConcept + + // Copy construction from a compatible type. The copy constructor of references is shallow. The channels themselves are not copied. + interleaved_ref(const interleaved_ref& p) : _channels(p._channels) {} + template <typename P> interleaved_ref(const P& p) : _channels(p._channels) { check_compatible<P>(); } + + template <typename P> bool operator==(const P& p) const { check_compatible<P>(); return static_equal(*this,p); } + template <typename P> bool operator!=(const P& p) const { return !(*this==p); } + +// Required by MutableColorBaseConcept + + // Assignment from a compatible type + const interleaved_ref& operator=(const interleaved_ref& p) const { static_copy(p,*this); return *this; } + template <typename P> const interleaved_ref& operator=(const P& p) const { check_compatible<P>(); static_copy(p,*this); return *this; } + +// Required by PixelConcept + using value_type = pixel<channel_t, layout_t>; + using reference = interleaved_ref; + using const_reference = interleaved_ref<channel_const_reference_t, layout_t>; + static const bool is_mutable = channel_traits<ChannelReference>::is_mutable; + +// Required by HomogeneousPixelConcept + ChannelReference operator[](std::size_t i) const { return _channels[i]; } + +// Custom constructor (not part of any concept) + explicit interleaved_ref(channel_pointer_t channels) : _channels(channels) {} +// This is needed for the reference proxy to work properly + const interleaved_ref* operator->() const { return this; } +private: + channel_pointer_t _channels; + + template <typename Pixel> static void check_compatible() { gil_function_requires<PixelsCompatibleConcept<Pixel,interleaved_ref>>(); } +}; + +// Required by ColorBaseConcept +template <typename ChannelReference, typename Layout, int K> +struct kth_element_type<interleaved_ref<ChannelReference, Layout>, K> +{ + using type = ChannelReference; +}; + +template <typename ChannelReference, typename Layout, int K> +struct kth_element_reference_type<interleaved_ref<ChannelReference, Layout>, K> +{ + using type = ChannelReference; +}; + +template <typename ChannelReference, typename Layout, int K> +struct kth_element_const_reference_type<interleaved_ref<ChannelReference, Layout>, K> +{ + using type = ChannelReference; + // XXX: using type = typename channel_traits<ChannelReference>::const_reference; +}; + +// Required by ColorBaseConcept +template <int K, typename ChannelReference, typename Layout> +typename element_reference_type<interleaved_ref<ChannelReference,Layout>>::type +at_c(const interleaved_ref<ChannelReference,Layout>& p) { return p[K]; }; + +// Required by HomogeneousColorBaseConcept +template <typename ChannelReference, typename Layout> +typename element_reference_type<interleaved_ref<ChannelReference,Layout>>::type +dynamic_at_c(const interleaved_ref<ChannelReference,Layout>& p, std::size_t n) { return p[n]; }; + +namespace detail { + struct swap_fn_t { + template <typename T> void operator()(T& x, T& y) const { + using std::swap; + swap(x,y); + } + }; +} + +// Required by MutableColorBaseConcept. The default std::swap does not do the right thing for proxy references - it swaps the references, not the values +template <typename ChannelReference, typename Layout> +void swap(const interleaved_ref<ChannelReference,Layout>& x, const interleaved_ref<ChannelReference,Layout>& y) { + static_for_each(x,y,detail::swap_fn_t()); +}; + +// Required by PixelConcept +template <typename ChannelReference, typename Layout> +struct is_pixel<interleaved_ref<ChannelReference,Layout>> : public std::true_type {}; + + +// Required by PixelBasedConcept +template <typename ChannelReference, typename Layout> +struct color_space_type<interleaved_ref<ChannelReference, Layout>> +{ + using type = typename Layout::color_space_t; +}; + +// Required by PixelBasedConcept +template <typename ChannelReference, typename Layout> +struct channel_mapping_type<interleaved_ref<ChannelReference, Layout>> +{ + using type = typename Layout::channel_mapping_t; +}; + +// Required by PixelBasedConcept +template <typename ChannelReference, typename Layout> +struct is_planar<interleaved_ref<ChannelReference,Layout>> : std::false_type {}; + +// Required by HomogeneousPixelBasedConcept +template <typename ChannelReference, typename Layout> +struct channel_type<interleaved_ref<ChannelReference, Layout>> +{ + using type = typename channel_traits<ChannelReference>::value_type; +}; + +} } // namespace boost::gil + +#endif diff --git a/src/boost/libs/gil/example/mandelbrot.cpp b/src/boost/libs/gil/example/mandelbrot.cpp new file mode 100644 index 000000000..0bcfc2ea1 --- /dev/null +++ b/src/boost/libs/gil/example/mandelbrot.cpp @@ -0,0 +1,75 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/typedefs.hpp> +#include <boost/gil/extension/io/jpeg.hpp> + +// Example for convolve_rows() and convolve_cols() in the numeric extension + +using namespace boost::gil; + +// Models a Unary Function +template <typename P> // Models PixelValueConcept +struct mandelbrot_fn +{ + using point_t = boost::gil::point_t; + using const_t = mandelbrot_fn; + using value_type = P; + using reference = value_type; + using const_reference = value_type; + using argument_type = point_t; + using result_type = reference; + static constexpr bool is_mutable =false; + + value_type _in_color,_out_color; + point_t _img_size; + static const int MAX_ITER=100; // max number of iterations + + mandelbrot_fn() {} + mandelbrot_fn(const point_t& sz, const value_type& in_color, const value_type& out_color) : _in_color(in_color), _out_color(out_color), _img_size(sz) {} + + result_type operator()(const point_t& p) const { + // normalize the coords to (-2..1, -1.5..1.5) + // (actually make y -1.0..2 so it is asymmetric, so we can verify some view factory methods) + double t=get_num_iter(point<double>(p.x/(double)_img_size.x*3-2, p.y/(double)_img_size.y*3-1.0f));//1.5f)); + t=pow(t,0.2); + + value_type ret; + for (int k=0; k<num_channels<P>::value; ++k) + ret[k]=(typename channel_type<P>::type)(_in_color[k]*t + _out_color[k]*(1-t)); + return ret; + } + +private: + double get_num_iter(const point<double>& p) const { + point<double> Z(0,0); + for (int i=0; i<MAX_ITER; ++i) { + Z = point<double>(Z.x*Z.x - Z.y*Z.y + p.x, 2*Z.x*Z.y + p.y); + if (Z.x*Z.x + Z.y*Z.y > 4) + return i/(double)MAX_ITER; + } + return 0; + } +}; + +int main() +{ + using deref_t = mandelbrot_fn<rgb8_pixel_t>; + using point_t = deref_t::point_t; + using locator_t = virtual_2d_locator<deref_t,false>; + using my_virt_view_t = image_view<locator_t>; + + boost::function_requires<PixelLocatorConcept<locator_t>>(); + gil_function_requires<StepIteratorConcept<locator_t::x_iterator>>(); + + point_t dims(200,200); + my_virt_view_t mandel(dims, locator_t(point_t(0,0), point_t(1,1), deref_t(dims, rgb8_pixel_t(255,0,255), rgb8_pixel_t(0,255,0)))); + write_view("out-mandelbrot.jpg",mandel, jpeg_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/packed_pixel.cpp b/src/boost/libs/gil/example/packed_pixel.cpp new file mode 100644 index 000000000..573b66850 --- /dev/null +++ b/src/boost/libs/gil/example/packed_pixel.cpp @@ -0,0 +1,59 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/extension/io/jpeg.hpp> + +#include <algorithm> + +// This test file demonstrates how to use packed pixel formats in GIL. +// A "packed" pixel is a pixel whose channels are bit ranges. +// Here we create an RGB image whose pixel has 16-bits, such as: +// bits [0..6] are the blue channel +// bits [7..13] are the green channel +// bits [14..15] are the red channel +// We read a regular 8-bit RGB image, convert it to packed BGR772, convert it back to 8-bit RGB and save it to a file. +// Since the red channel is only two bits the color loss should be observable in the result +// +// This test file also demonstrates how to use bit-aligned images - these are images whose pixels themselves are not byte aligned. +// For example, an rgb222 image has a pixel whose size is 6 bits. Bit-aligned images are more complicated than packed images. They +// require a special proxy class to represent pixel reference and pixel iterator (packed images use C++ reference and C pointer respectively). +// The alignment parameter in the constructor of bit-aligned images is in bit units. For example, if you want your bit-aligned image to have 4-byte +// alignment of its rows use alignment of 32, not 4. +// +// To demonstrate that image view transformations work on packed images, we save the result transposed. + +using namespace boost; +using namespace boost::gil; + +int main() { + bgr8_image_t img; + read_image("test.jpg",img, jpeg_tag{}); + + //////////////////////////////// + // define a bgr772 image. It is a "packed" image - its channels are not byte-aligned, but its pixels are. + //////////////////////////////// + + using bgr772_image_t = packed_image3_type<uint16_t, 7,7,2, bgr_layout_t>::type; + bgr772_image_t bgr772_img(img.dimensions()); + copy_and_convert_pixels(const_view(img),view(bgr772_img)); + + // Save the result. JPEG I/O does not support the packed pixel format, so convert it back to 8-bit RGB + write_view("out-packed_pixel_bgr772.jpg",color_converted_view<bgr8_pixel_t>(transposed_view(const_view(bgr772_img))), jpeg_tag{}); + + //////////////////////////////// + // define a gray1 image (one-bit per pixel). It is a "bit-aligned" image - its pixels are not byte aligned. + //////////////////////////////// + + using gray1_image_t = bit_aligned_image1_type<1, gray_layout_t>::type; + gray1_image_t gray1_img(img.dimensions()); + copy_and_convert_pixels(const_view(img),view(gray1_img)); + + // Save the result. JPEG I/O does not support the packed pixel format, so convert it back to 8-bit RGB + write_view("out-packed_pixel_gray1.jpg",color_converted_view<gray8_pixel_t>(transposed_view(const_view(gray1_img))), jpeg_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/resize.cpp b/src/boost/libs/gil/example/resize.cpp new file mode 100644 index 000000000..2dc0bf199 --- /dev/null +++ b/src/boost/libs/gil/example/resize.cpp @@ -0,0 +1,29 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/sampler.hpp> +#include <boost/gil/extension/numeric/resample.hpp> + +// Example for resize_view() in the numeric extension + +int main() +{ + namespace bg = boost::gil; + + bg::rgb8_image_t img; + bg::read_image("test.jpg", img, bg::jpeg_tag{}); + + // test resize_view + // Scale the image to 100x100 pixels using bilinear resampling + bg::rgb8_image_t square100x100(100, 100); + bg::resize_view(bg::const_view(img), bg::view(square100x100), bg::bilinear_sampler{}); + bg::write_view("out-resize.jpg", bg::const_view(square100x100), bg::jpeg_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/sobel_scharr.cpp b/src/boost/libs/gil/example/sobel_scharr.cpp new file mode 100644 index 000000000..10e15c223 --- /dev/null +++ b/src/boost/libs/gil/example/sobel_scharr.cpp @@ -0,0 +1,45 @@ +#include <boost/gil/typedefs.hpp> +#include <boost/gil/image_processing/numeric.hpp> +#include <boost/gil/extension/io/png.hpp> +#include <boost/gil/extension/numeric/convolve.hpp> +#include <string> +#include <iostream> + +namespace gil = boost::gil; + +int main(int argc, char* argv[]) +{ + if (argc != 5) + { + std::cerr << "usage: " << argv[0] << ": <input.png> <sobel|scharr> <output-x.png> <output-y.png>\n"; + return -1; + } + + gil::gray8_image_t input_image; + gil::read_image(argv[1], input_image, gil::png_tag{}); + auto input = gil::view(input_image); + auto filter_type = std::string(argv[2]); + + gil::gray16_image_t dx_image(input_image.dimensions()); + auto dx = gil::view(dx_image); + gil::gray16_image_t dy_image(input_image.dimensions()); + auto dy = gil::view(dy_image); + if (filter_type == "sobel") + { + gil::detail::convolve_2d(input, gil::generate_dx_sobel(1), dx); + gil::detail::convolve_2d(input, gil::generate_dy_sobel(1), dy); + } + else if (filter_type == "scharr") + { + gil::detail::convolve_2d(input, gil::generate_dx_scharr(1), dx); + gil::detail::convolve_2d(input, gil::generate_dy_scharr(1), dy); + } + else + { + std::cerr << "unrecognized gradient filter type. Must be either sobel or scharr\n"; + return -1; + } + + gil::write_view(argv[3], dx, gil::png_tag{}); + gil::write_view(argv[4], dy, gil::png_tag{}); +} diff --git a/src/boost/libs/gil/example/test.jpg b/src/boost/libs/gil/example/test.jpg Binary files differnew file mode 100644 index 000000000..d7e4490c4 --- /dev/null +++ b/src/boost/libs/gil/example/test.jpg diff --git a/src/boost/libs/gil/example/test_adaptive.png b/src/boost/libs/gil/example/test_adaptive.png Binary files differnew file mode 100644 index 000000000..d72dd68f7 --- /dev/null +++ b/src/boost/libs/gil/example/test_adaptive.png diff --git a/src/boost/libs/gil/example/threshold.cpp b/src/boost/libs/gil/example/threshold.cpp new file mode 100644 index 000000000..565ff1ca1 --- /dev/null +++ b/src/boost/libs/gil/example/threshold.cpp @@ -0,0 +1,29 @@ +// +// Copyright 2019 Miral Shah <miralshah2211@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) +// +#include <boost/gil/extension/io/jpeg.hpp> +#include <boost/gil/image_processing/threshold.hpp> + +using namespace boost::gil; + +int main() +{ + rgb8_image_t img; + read_image("test.jpg",img, jpeg_tag{}); + rgb8_image_t img_out(img.dimensions()); + +// performing binary threshold on each channel of the image +// if the pixel value is more than 150 than it will be set to 255 else to 0 + boost::gil::threshold_binary(const_view(img), view(img_out), 150, 255); + write_view("out-threshold-binary.jpg", view(img_out), jpeg_tag{}); + +// if the pixel value is more than 150 than it will be set to 150 else no change + boost::gil::threshold_truncate(const_view(img), view(img_out), 150, threshold_truncate_mode::threshold); + write_view("out-threshold-binary_inv.jpg", view(img_out), jpeg_tag{}); + + return 0; +} diff --git a/src/boost/libs/gil/example/x_gradient.cpp b/src/boost/libs/gil/example/x_gradient.cpp new file mode 100644 index 000000000..111d40b9e --- /dev/null +++ b/src/boost/libs/gil/example/x_gradient.cpp @@ -0,0 +1,59 @@ +// +// Copyright 2005-2007 Adobe Systems Incorporated +// +// 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/extension/io/jpeg.hpp> + +// Example to demonstrate a way to compute gradients along x-axis + +using namespace boost::gil; + +template <typename Out> +struct halfdiff_cast_channels { + template <typename T> Out operator()(const T& in1, const T& in2) const { + return Out((in2-in1)/2); + } +}; + + +template <typename SrcView, typename DstView> +void x_gradient(SrcView const& src, DstView const& dst) +{ + using dst_channel_t = typename channel_type<DstView>::type; + + for (int y = 0; y < src.height(); ++y) + { + typename SrcView::x_iterator src_it = src.row_begin(y); + typename DstView::x_iterator dst_it = dst.row_begin(y); + + for (int x = 1; x < src.width() - 1; ++x) + { + static_transform(src_it[x - 1], src_it[x + 1], dst_it[x], + halfdiff_cast_channels<dst_channel_t>()); + } + } +} + +template <typename SrcView, typename DstView> +void x_luminosity_gradient(SrcView const& src, DstView const& dst) +{ + using gray_pixel_t = pixel<typename channel_type<SrcView>::type, gray_layout_t>; + x_gradient(color_converted_view<gray_pixel_t>(src), dst); +} + +int main() +{ + rgb8_image_t img; + read_image("test.jpg",img, jpeg_tag{}); + + gray8s_image_t img_out(img.dimensions()); + fill_pixels(view(img_out),int8_t(0)); + + x_luminosity_gradient(const_view(img), view(img_out)); + write_view("out-x_gradient.jpg",color_converted_view<gray8_pixel_t>(const_view(img_out)), jpeg_tag{}); + + return 0; +} |