From 8465d5463168a507fdd16d600b62c3efa51269fd Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Wed, 10 Aug 2022 18:37:20 +0200 Subject: [PATCH 01/20] ci: partially replace Ubuntu 18.04 on GHA with Ubuntu 20.04 (#716) GitHub started the deprecation process for Ubuntu 18.04 Action runners on 2022-08-08, and Ubuntu 18.04 will be completely unsupported by 2022-12-01 (if things proceed as planned). See for the announcement and more information on that. So this commit replace those Ubuntu 18.04 runners with the next newest Ubuntu 20.04 runner that have shown to still work with the newer version. The other five GHA jobs with Ubuntu 18.04 (gcc-6, gcc-7, clang++-3.9, clang++-4.0, clang++-5.0) still need to be dealt with separately later. --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cf10bd9e..a49372079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,14 +28,16 @@ jobs: - toolset: gcc compiler: g++-8 cxxstd: "14" - os: ubuntu-18.04 + os: ubuntu-20.04 install: g++-8 - toolset: gcc-9 cxxstd: "14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 + install: g++-9 - toolset: gcc-10 cxxstd: "14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 + install: g++-10 - toolset: clang compiler: clang++-3.9 cxxstd: "14" @@ -54,12 +56,12 @@ jobs: - toolset: clang compiler: clang++-6.0 cxxstd: "14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 install: clang-6.0 - toolset: clang compiler: clang++-7 cxxstd: "14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 install: clang-7 - toolset: clang compiler: clang++-8 From 1f89d622e3755d472232591ee5a341564af85d91 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Fri, 12 Aug 2022 09:21:13 +0200 Subject: [PATCH 02/20] ci: replace macOS 10.15 with macOS 11 in CI pipelines (#717) * ci: replace macOS 10.15 with macOS 11 in CI workflow GitHub started the deprecation process for macOS 10.15 runners on 2022-05-31, and macOS 10.15 will be completely unsupported by 2022-08-30 (if things proceed as planned). See for more information on the removal of the macOS 10.15 images. This issue already hit us during the build for PR #716, because at that time there was a scheduled brownout for macOS 10.15 builds to raise awareness of the upcoming removal. * ci: remove Azure pipeline build configuration See . --- .azure-pipelines.yml | 71 ------------------- .ci/azure-pipelines/steps-check-cmake.yml | 9 --- .../steps-cmake-build-and-test.yml | 51 ------------- .ci/azure-pipelines/steps-install-boost.yml | 41 ----------- .ci/azure-pipelines/steps-install-conan.yml | 17 ----- .ci/azure-pipelines/steps-install-gcc.yml | 18 ----- .github/workflows/ci.yml | 2 +- README.md | 8 +-- 8 files changed, 5 insertions(+), 212 deletions(-) delete mode 100644 .azure-pipelines.yml delete mode 100644 .ci/azure-pipelines/steps-check-cmake.yml delete mode 100644 .ci/azure-pipelines/steps-cmake-build-and-test.yml delete mode 100644 .ci/azure-pipelines/steps-install-boost.yml delete mode 100644 .ci/azure-pipelines/steps-install-conan.yml delete mode 100644 .ci/azure-pipelines/steps-install-gcc.yml diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml deleted file mode 100644 index 0a5e394f5..000000000 --- a/.azure-pipelines.yml +++ /dev/null @@ -1,71 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2018-2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -variables: - #system.debug: true - configuration: release - -trigger: - - master - - develop - - azure-pipelines - - ml/* - -jobs: - - job: 'ubuntu1804_gcc6_cxx14_cmake' - pool: - vmImage: 'ubuntu-18.04' - steps: - - template: .ci/azure-pipelines/steps-install-gcc.yml - parameters: - major_version: '6' - - script: which g++ && g++ --version - displayName: 'Check GCC' - - template: .ci/azure-pipelines/steps-check-cmake.yml - - script: | - sudo -E apt-get update - sudo -E apt-get -yq --no-install-suggests --no-install-recommends install libpng-dev libjpeg-dev libtiff5-dev libraw-dev - displayName: 'Install dependencies' - - template: .ci/azure-pipelines/steps-install-boost.yml - - template: .ci/azure-pipelines/steps-cmake-build-and-test.yml - parameters: - cxxver: '14' - - - job: 'ubuntu1804_gcc8_cxx14_cmake' - pool: - vmImage: 'ubuntu-18.04' - steps: - - template: .ci/azure-pipelines/steps-install-gcc.yml - parameters: - major_version: '8' - - script: which g++ && g++ --version - displayName: 'Check GCC' - - template: .ci/azure-pipelines/steps-check-cmake.yml - - script: | - sudo -E apt-get update - sudo -E apt-get -yq --no-install-suggests --no-install-recommends install libpng-dev libjpeg-dev libtiff5-dev libraw-dev - displayName: 'Install dependencies' - - template: .ci/azure-pipelines/steps-install-boost.yml - - template: .ci/azure-pipelines/steps-cmake-build-and-test.yml - parameters: - cxxver: '14' - - - job: 'macos1015_xcode11_cmake' - pool: - vmImage: 'macOS-10.15' - steps: - - script: which clang++ && clang++ --version - displayName: 'Check clang' - - template: .ci/azure-pipelines/steps-check-cmake.yml - - template: .ci/azure-pipelines/steps-install-conan.yml - parameters: - python: python3 - - template: .ci/azure-pipelines/steps-install-boost.yml - parameters: - toolset: darwin - - template: .ci/azure-pipelines/steps-cmake-build-and-test.yml - parameters: - use_conan: 'ON' diff --git a/.ci/azure-pipelines/steps-check-cmake.yml b/.ci/azure-pipelines/steps-check-cmake.yml deleted file mode 100644 index 8b4cd9109..000000000 --- a/.ci/azure-pipelines/steps-check-cmake.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2018-2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -steps: - - script: cmake --version - displayName: 'Check CMake' diff --git a/.ci/azure-pipelines/steps-cmake-build-and-test.yml b/.ci/azure-pipelines/steps-cmake-build-and-test.yml deleted file mode 100644 index a4454faaf..000000000 --- a/.ci/azure-pipelines/steps-cmake-build-and-test.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2018-2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -parameters: - # defaults, if not specified - configuration: 'Release' - cxxver: '14' - enable_ext_io: 'OFF' - enable_ext_numeric: 'ON' - enable_ext_toolbox: 'ON' - use_conan: 'OFF' - -steps: - - script: | - export BOOST_ROOT=$(Build.SourcesDirectory)/boost-root - export BOOST_INCLUDEDIR=$BOOST_ROOT - export BOOST_LIBRARYDIR=$BOOST_ROOT/lib - cmake -H. -B_build -DCMAKE_BUILD_TYPE=${{ parameters.configuration }} -DCMAKE_CXX_STANDARD=${{ parameters.cxxver }} -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_NO_SYSTEM_PATHS=ON -DBOOST_GIL_USE_CONAN=${{ parameters.use_conan }} -DBOOST_GIL_ENABLE_EXT_IO=${{ parameters.enable_ext_io }} -DBOOST_GIL_ENABLE_EXT_NUMERIC=${{ parameters.enable_ext_numeric }} -DBOOST_GIL_ENABLE_EXT_TOOLBOX=${{ parameters.enable_ext_toolbox }} - workingDirectory: $(Build.SourcesDirectory)/boost-root/libs/gil - displayName: 'Run CMake to configure build on Unix' - condition: ne(variables['Agent.OS'], 'Windows_NT') - - - script: | - set BOOST_ROOT=$(Build.SourcesDirectory)\boost-root - set BOOST_INCLUDEDIR=%BOOST_ROOT% - set BOOST_LIBRARYDIR=%BOOST_ROOT%\lib - cmake -H. -B_build -DCMAKE_BUILD_TYPE=${{ parameters.configuration }} -DCMAKE_CXX_STANDARD=${{ parameters.cxxver }} -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_ADDITIONAL_VERSIONS="1.70;1.71" -DBoost_ARCHITECTURE=-x32 -DBoost_NO_SYSTEM_PATHS=ON -DBOOST_GIL_USE_CONAN=${{ parameters.use_conan }} -DBOOST_GIL_ENABLE_EXT_IO=${{ parameters.enable_ext_io }} -DBOOST_GIL_ENABLE_EXT_NUMERIC=${{ parameters.enable_ext_numeric }} -DBOOST_GIL_ENABLE_EXT_TOOLBOX=${{ parameters.enable_ext_toolbox }} - workingDirectory: $(Build.SourcesDirectory)/boost-root/libs/gil - displayName: 'Run CMake to configure build on Windows' - condition: eq(variables['Agent.OS'], 'Windows_NT') - - - script: cmake --build _build --config ${{ parameters.configuration }} -j 4 - workingDirectory: $(Build.SourcesDirectory)/boost-root/libs/gil - displayName: 'Run CMake to build' - - - script: cd _build && ctest -V --output-on-failure --build-config ${{ parameters.configuration }} - workingDirectory: $(Build.SourcesDirectory)/boost-root/libs/gil - displayName: 'Run CTest to test' - condition: ne(variables['Agent.OS'], 'Darwin') - - - script: | - # Set DYLD_FALLBACK_LIBRARY_PATH to avoid 'dyld: Library not loaded: libboost_*.dylib' error - export DYLD_FALLBACK_LIBRARY_PATH=$(Build.SourcesDirectory)/boost-root/stage/lib:$DYLD_FALLBACK_LIBRARY_PATH - echo "DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH" - cd _build && ctest -V --output-on-failure --build-config ${{ parameters.configuration }} - workingDirectory: $(Build.SourcesDirectory)/boost-root/libs/gil - displayName: 'Run CTest to test on macOS' - condition: eq(variables['Agent.OS'], 'Darwin') diff --git a/.ci/azure-pipelines/steps-install-boost.yml b/.ci/azure-pipelines/steps-install-boost.yml deleted file mode 100644 index f92173730..000000000 --- a/.ci/azure-pipelines/steps-install-boost.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2018-2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -parameters: - # defaults, if not specified - variant: 'release' - toolset: 'gcc' - -steps: - # The $BSD_DIR is the same path as $(Build.SourcesDirectory) - # but guaranteed in Unix format /a/b/c on every OS. - - bash: | - export BSD_DIR=$PWD - cd .. - export GIL_DIR=$PWD/gil - echo "Copying $BSD_DIR to $GIL_DIR" - cp -a $BSD_DIR $GIL_DIR - cd $BSD_DIR - $GIL_DIR/.ci/get-boost.sh $(Build.SourceBranchName) $GIL_DIR - displayName: 'Download Boost' - - - script: | - cd boost-root - ./bootstrap.sh - sudo ./b2 headers - sudo ./b2 -j4 toolset=${{ parameters.toolset }} variant=${{ parameters.variant }} --with-filesystem stage - ls stage/lib - displayName: 'Install Boost on Unix' - condition: ne(variables['Agent.OS'], 'Windows_NT') - - - script: | - cd boost-root - call .\bootstrap.bat - .\b2 headers - .\b2 -j4 address-model=32 variant=${{ parameters.variant }} --layout=system --with-filesystem stage - dir stage\lib - displayName: 'Install Boost on Windows' - condition: eq(variables['Agent.OS'], 'Windows_NT') diff --git a/.ci/azure-pipelines/steps-install-conan.yml b/.ci/azure-pipelines/steps-install-conan.yml deleted file mode 100644 index 70507a4bb..000000000 --- a/.ci/azure-pipelines/steps-install-conan.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2018-2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -parameters: - python: 'python' # default, if not specified - -steps: - - script: | - ${{ parameters.python }} --version - ${{ parameters.python }} -m ensurepip - ${{ parameters.python }} -m pip install --upgrade pip - ${{ parameters.python }} -m pip install --upgrade conan - conan --version - displayName: 'Install Conan' diff --git a/.ci/azure-pipelines/steps-install-gcc.yml b/.ci/azure-pipelines/steps-install-gcc.yml deleted file mode 100644 index 2f11eb5d8..000000000 --- a/.ci/azure-pipelines/steps-install-gcc.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Azure Pipelines for Boost.GIL -# -# Copyright 2019 Mateusz Loskot -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -# -parameters: - # defaults, if not specified - major_version: 8 - -steps: - - bash: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update -qq - sudo apt-get install g++-${{ parameters.major_version }} - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ parameters.major_version }} 90 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ parameters.major_version }} 90 - displayName: 'Install GCC' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a49372079..9d4760dae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: os: ubuntu-20.04 - toolset: clang cxxstd: "14,17" - os: macos-10.15 + os: macos-11 runs-on: ${{matrix.os}} diff --git a/README.md b/README.md index d71fe15a1..b46d70a57 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ [![Conan](https://img.shields.io/badge/on-conan-blue.svg)](https://bintray.com/bincrafters/public-conan/boost_gil%3Abincrafters) [![Vcpkg](https://img.shields.io/badge/on-vcpkg-blue.svg)](https://github.com/Microsoft/vcpkg/tree/master/ports/boost-gil) -Documentation | GitHub Actions | AppVeyor | Azure Pipelines | Regression | Codecov ---------------|----------------|----------|-----------------|------------|---------- -[![develop](https://img.shields.io/badge/doc-develop-blue.svg)](https://boostorg.github.io/gil/develop/) | [![GitHub Actions](https://github.com/boostorg/gil/workflows/CI/badge.svg?branch=develop)](https://github.com/boostorg/gil/actions?query=branch:develop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/w4k19d8io2af168h/branch/develop?svg=true)](https://ci.appveyor.com/project/stefanseefeld/gil/branch/develop) | [![Azure](https://dev.azure.com/boostorg/gil/_apis/build/status/boostorg.gil?branchName=develop)](https://dev.azure.com/boostorg/gil/_build/latest?definitionId=7&branchName=develop) | [![gil](https://img.shields.io/badge/gil-develop-blue.svg)](http://www.boost.org/development/tests/develop/developer/gil.html) | [![codecov](https://codecov.io/gh/boostorg/gil/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/boostorg/gil/branch/develop) -[![master](https://img.shields.io/badge/doc-master-blue.svg)](https://boostorg.github.io/gil/) | [![GitHub Actions](https://github.com/boostorg/gil/workflows/CI/badge.svg?branch=master)](https://github.com/boostorg/gil/actions?query=branch:master) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/w4k19d8io2af168h?svg=true)](https://ci.appveyor.com/project/stefanseefeld/gil/branch/master) | [![Azure](https://dev.azure.com/boostorg/gil/_apis/build/status/boostorg.gil?branchName=master)](https://dev.azure.com/boostorg/gil/_build/latest?definitionId=7&branchName=master) | [![gil](https://img.shields.io/badge/gil-master-blue.svg)](http://www.boost.org/development/tests/master/developer/gil.html) | [![codecov](https://codecov.io/gh/boostorg/gil/branch/master/graphs/badge.svg)](https://app.codecov.io/gh/boostorg/gil/branch/master) +Documentation | GitHub Actions | AppVeyor | Regression | Codecov +--------------|----------------|----------|------------|---------- +[![develop](https://img.shields.io/badge/doc-develop-blue.svg)](https://boostorg.github.io/gil/develop/) | [![GitHub Actions](https://github.com/boostorg/gil/workflows/CI/badge.svg?branch=develop)](https://github.com/boostorg/gil/actions?query=branch:develop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/w4k19d8io2af168h/branch/develop?svg=true)](https://ci.appveyor.com/project/stefanseefeld/gil/branch/develop) | [![gil](https://img.shields.io/badge/gil-develop-blue.svg)](http://www.boost.org/development/tests/develop/developer/gil.html) | [![codecov](https://codecov.io/gh/boostorg/gil/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/boostorg/gil/branch/develop) +[![master](https://img.shields.io/badge/doc-master-blue.svg)](https://boostorg.github.io/gil/) | [![GitHub Actions](https://github.com/boostorg/gil/workflows/CI/badge.svg?branch=master)](https://github.com/boostorg/gil/actions?query=branch:master) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/w4k19d8io2af168h?svg=true)](https://ci.appveyor.com/project/stefanseefeld/gil/branch/master) | [![gil](https://img.shields.io/badge/gil-master-blue.svg)](http://www.boost.org/development/tests/master/developer/gil.html) | [![codecov](https://codecov.io/gh/boostorg/gil/branch/master/graphs/badge.svg)](https://app.codecov.io/gh/boostorg/gil/branch/master) # Boost.GIL From 135edcfad336c226ab3341c5384283043dcd6606 Mon Sep 17 00:00:00 2001 From: Sam Darwin Date: Wed, 5 Oct 2022 03:16:45 -0600 Subject: [PATCH 03/20] docs: Support newer version of Sphinx (#719) --- doc/_static/boost.css | 19 +++++++++++++++++++ doc/_templates/layout.html | 3 +++ 2 files changed, 22 insertions(+) diff --git a/doc/_static/boost.css b/doc/_static/boost.css index 28f893599..582f421eb 100644 --- a/doc/_static/boost.css +++ b/doc/_static/boost.css @@ -714,3 +714,22 @@ span.purple { color: purple; } span.gold { color: gold; } span.silver { color: silver; } /* lighter gray */ span.gray { color: #808080; } /* light gray */ + +/* 2022 fix */ + +ol.simple ol p, +ol.simple ul p, +ul.simple ol p, +ul.simple ul p { + margin-top: 0; +} + +ol.simple > li:not(:first-child) > p, +ul.simple > li:not(:first-child) > p { + margin-top: 0; +} + +ol.simple p, +ul.simple p { + margin-bottom: 0; +} diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index 6be6d55e2..9aada3d2a 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -49,6 +49,9 @@ {%- for scriptfile in script_files %} {%- endfor %} + + + {%- if use_opensearch %} Date: Thu, 6 Oct 2022 22:49:45 +0200 Subject: [PATCH 04/20] docs: Fix HTML syntax Patch via e-mail from @sdarwin to refine PR #719 Thank you Sam! --- doc/_templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index 9aada3d2a..17281c735 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -51,7 +51,7 @@ {%- endfor %} - + {%- if use_opensearch %} Date: Mon, 14 Nov 2022 11:15:10 +0100 Subject: [PATCH 05/20] ci: Update actions/checkout in GitHub Actions workflows to v3 (#720) --- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 3 +-- .github/workflows/docs.yaml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d4760dae..0f8d379dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages if: matrix.install @@ -142,7 +142,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Boost shell: cmd diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3bd330aba..a21a27549 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,7 @@ jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: install packages @@ -52,4 +52,3 @@ jobs: uses: codecov/codecov-action@v1.2.1 with: files: ../boost-root/coverage.info - \ No newline at end of file diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 9a20e7c55..1308258f9 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,7 +9,7 @@ jobs: build-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ./.github/actions/docs-prerequisites - uses: ./.github/actions/setup-boost - uses: ./.github/actions/generate-doc From 712b827edbe60a1eb6c13b1a677e7d2a4f74a116 Mon Sep 17 00:00:00 2001 From: Christoph Gringmuth Date: Tue, 7 Feb 2023 14:10:38 +0100 Subject: [PATCH 06/20] fix: Convolution in convolve_2d (#723) Fixes #722 --- include/boost/gil/detail/math.hpp | 2 +- .../boost/gil/image_processing/convolve.hpp | 2 +- test/core/image_processing/convolve_2d.cpp | 93 +++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/include/boost/gil/detail/math.hpp b/include/boost/gil/detail/math.hpp index 700136edc..5515adb2e 100644 --- a/include/boost/gil/detail/math.hpp +++ b/include/boost/gil/detail/math.hpp @@ -15,7 +15,7 @@ namespace boost { namespace gil { namespace detail { static constexpr double pi = 3.14159265358979323846; -static constexpr std::array dx_sobel = {{-1, 0, 1, -2, 0, 2, -1, 0, 1}}; +static constexpr std::array dx_sobel = {{1, 0, -1, 2, 0, -2, 1, 0, -1}}; static constexpr std::array dx_scharr = {{-1, 0, 1, -1, 0, 1, -1, 0, 1}}; static constexpr std::array dy_sobel = {{1, 2, 1, 0, 0, 0, -1, -2, -1}}; static constexpr std::array dy_scharr = {{1, 1, 1, 0, 0, 0, -1, -1, -1}}; diff --git a/include/boost/gil/image_processing/convolve.hpp b/include/boost/gil/image_processing/convolve.hpp index a6369c89a..91384f162 100644 --- a/include/boost/gil/image_processing/convolve.hpp +++ b/include/boost/gil/image_processing/convolve.hpp @@ -400,7 +400,7 @@ void convolve_2d_impl(SrcView const& src_view, DstView const& dst_view, Kernel c { aux_total += src_view(col_boundary, row_boundary)[0] * - kernel.at(flip_ker_row, flip_ker_col); + kernel.at(flip_ker_col, flip_ker_row); } } } diff --git a/test/core/image_processing/convolve_2d.cpp b/test/core/image_processing/convolve_2d.cpp index 3b37b8e37..cb6a96f66 100644 --- a/test/core/image_processing/convolve_2d.cpp +++ b/test/core/image_processing/convolve_2d.cpp @@ -100,9 +100,102 @@ gil::detail::convolve_2d(src_view, kernel, view(img_gray_out)); BOOST_TEST(gil::equal_pixels(exp_out_view, view(img_gray_out))); } +void test_convolve_2d_with_sobel_x_filter() +{ + const gil::uint8_t img[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + const gil::int16_t exp_output[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 255, 255, 0, 0, -255, -255, 0, 0, 0, + 0, 765, 765, 0, 0, -765, -765, 0, 0, 0, + 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, + 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, + 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, + 0, 765, 765, 0, 0, -765, -765, 0, 0, 0, + 0, 255, 255, 0, 0, -255, -255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + gil::gray16s_image_t img_gray_out(10, 13); + const auto src_view = + gil::interleaved_view(10, 13, reinterpret_cast(img), 10); + const auto exp_out_view = + gil::interleaved_view(10, 13, reinterpret_cast(exp_output), 20); + gil::detail::convolve_2d(src_view, gil::generate_dx_sobel(1), view(img_gray_out)); + + BOOST_TEST(gil::equal_pixels(exp_out_view, view(img_gray_out))); +} + +void test_convolve_2d_with_sobel_y_filter() +{ + const gil::uint8_t img[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + const gil::int16_t exp_output[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 255, 765, 1020, 1020, 765, 255, 0, 0, 0, + 0, 255, 765, 1020, 1020, 765, 255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -255, -765, -1020, -1020, -765, -255, 0, 0, 0, + 0, -255, -765, -1020, -1020, -765, -255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + gil::gray16s_image_t img_gray_out(10, 13); + const auto src_view = + gil::interleaved_view(10, 13, reinterpret_cast(img), 10); + const auto exp_out_view = + gil::interleaved_view(10, 13, reinterpret_cast(exp_output), 20); + gil::detail::convolve_2d(src_view, gil::generate_dy_sobel(1), view(img_gray_out)); + BOOST_TEST(gil::equal_pixels(exp_out_view, view(img_gray_out))); +} + int main() { test_convolve_2d_with_normalized_mean_filter(); test_convolve_2d_with_image_using_float32_t(); + test_convolve_2d_with_sobel_x_filter(); + test_convolve_2d_with_sobel_y_filter(); return ::boost::report_errors(); } From d6e67f38c548372e3d5c4e656c2d763c914bf918 Mon Sep 17 00:00:00 2001 From: Christoph Gringmuth Date: Tue, 7 Feb 2023 14:11:51 +0100 Subject: [PATCH 07/20] fix: Normalize Gaussian 2D kernel. (#725) --- include/boost/gil/image_processing/numeric.hpp | 15 ++++++++++----- test/core/image_processing/simple_kernels.cpp | 17 ++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/boost/gil/image_processing/numeric.hpp b/include/boost/gil/image_processing/numeric.hpp index 8507e0e29..5500c7a96 100644 --- a/include/boost/gil/image_processing/numeric.hpp +++ b/include/boost/gil/image_processing/numeric.hpp @@ -136,21 +136,26 @@ inline auto generate_gaussian_kernel(std::size_t side_length, double sigma) throw std::invalid_argument("kernel dimensions should be odd and equal"); const double denominator = 2 * boost::gil::detail::pi * sigma * sigma; - auto middle = side_length / 2; + auto const middle = side_length / 2; std::vector values(side_length * side_length); + T sum{0}; for (std::size_t y = 0; y < side_length; ++y) { for (std::size_t x = 0; x < side_length; ++x) { - const auto delta_x = middle > x ? middle - x : x - middle; - const auto delta_y = middle > y ? middle - y : y - middle; - const double power = (delta_x * delta_x + delta_y * delta_y) / (2 * sigma * sigma); + const auto delta_x = x - middle; + const auto delta_y = y - middle; + const auto power = static_cast(delta_x * delta_x + delta_y * delta_y) / (2 * sigma * sigma); const double nominator = std::exp(-power); - const float value = static_cast(nominator / denominator); + const auto value = static_cast(nominator / denominator); values[y * side_length + x] = value; + sum += value; } } + // normalize so that Gaussian kernel sums up to 1. + std::transform(values.begin(), values.end(), values.begin(), [&sum](const auto & v) { return v/sum; }); + return detail::kernel_2d(values.begin(), values.size(), middle, middle); } diff --git a/test/core/image_processing/simple_kernels.cpp b/test/core/image_processing/simple_kernels.cpp index 522dec2f1..311de88e4 100644 --- a/test/core/image_processing/simple_kernels.cpp +++ b/test/core/image_processing/simple_kernels.cpp @@ -38,15 +38,16 @@ void test_gaussian_kernel_generation() auto kernel = boost::gil::generate_gaussian_kernel(7, 0.84089642); const float expected_values[7][7] = { - {0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f}, - {0.00002292f, 0.00078633f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f}, - {0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f}, - {0.00038771f, 0.01330373f, 0.11098164f, 0.25508352f, 0.11098164f, 0.01330373f, 0.00038711f}, - {0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f}, - {0.00002292f, 0.00078633f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f}, - {0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f} + {6.67847706e-07f, 2.29160778e-05f, 1.91169232e-04f, 3.87713181e-04f, 1.91169232e-04f, 2.29160778e-05f, 6.67847706e-07f}, + {2.29160778e-05f, 7.86326905e-04f, 6.55965268e-03f, 1.33037298e-02f, 6.55965268e-03f, 7.86326905e-04f, 2.29160778e-05f}, + {1.91169232e-04f, 6.55965268e-03f, 5.47215706e-02f, 1.10981636e-01f, 5.47215706e-02f, 6.55965268e-03f, 1.91169232e-04f}, + {3.87713181e-04f, 1.33037298e-02f, 1.10981636e-01f, 2.25083518e-01f, 1.10981636e-01f, 1.33037298e-02f, 3.87713181e-04f}, + {1.91169232e-04f, 6.55965268e-03f, 5.47215706e-02f, 1.10981636e-01f, 5.47215706e-02f, 6.55965268e-03f, 1.91169232e-04f}, + {2.29160778e-05f, 7.86326905e-04f, 6.55965268e-03f, 1.33037298e-02f, 6.55965268e-03f, 7.86326905e-04f, 2.29160778e-05f}, + {6.67847706e-07f, 2.29160778e-05f, 1.91169232e-04f, 3.87713181e-04f, 1.91169232e-04f, 2.29160778e-05f, 6.67847706e-07f} }; + double sum{0}; for (gil::gray32f_view_t::coord_t y = 0; static_cast(y) < kernel.size(); ++y) { for (gil::gray32f_view_t::coord_t x = 0; static_cast(x) < kernel.size(); ++x) @@ -55,8 +56,10 @@ void test_gaussian_kernel_generation() auto expected = expected_values[y][x]; auto percent_difference = std::ceil(std::abs(expected - output) / expected); BOOST_TEST_LT(percent_difference, 5); + sum += output; } } + BOOST_TEST_LT(std::abs(sum-1), 1e-7); } int main() From 8f4cdcbcce2be1cec30fad9bcf375ca3d8eee1b7 Mon Sep 17 00:00:00 2001 From: nicolacandussi <72563215+nicolacandussi@users.noreply.github.com> Date: Tue, 21 Feb 2023 10:38:03 -0300 Subject: [PATCH 08/20] fix: Fixed custom color converter in dynamic_factory and added corresponding (#726) --- .../dynamic_image/image_view_factory.hpp | 20 ++---- .../dynamic_image/image_view_factory.cpp | 67 +++++++++++++++++++ 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/include/boost/gil/extension/dynamic_image/image_view_factory.hpp b/include/boost/gil/extension/dynamic_image/image_view_factory.hpp index 6667a828f..a41dc32c5 100644 --- a/include/boost/gil/extension/dynamic_image/image_view_factory.hpp +++ b/include/boost/gil/extension/dynamic_image/image_view_factory.hpp @@ -314,20 +314,12 @@ auto nth_channel_view(any_image_view const& src, int n) namespace detail { -template -struct get_ccv_type : color_converted_view_type {}; - template struct views_get_ccv_type { private: - // FIXME: Remove class name injection with detail:: qualification - // Required as workaround for MP11 issue that treats unqualified metafunction - // in the class definition of the same name as the specialization (Peter Dimov): - // invalid template argument for template parameter 'F', expected a class template - template - using ccvt = detail::get_ccv_type; - + template + using ccvt = typename color_converted_view_type::type; public: using type = mp11::mp_transform; }; @@ -340,7 +332,7 @@ template struct color_converted_view_type,DstP,CC> { //using type = any_image_view::type>; - using type = detail::views_get_ccv_type, DstP, CC>; + using type = typename detail::views_get_ccv_type, DstP, CC>::type; }; /// \ingroup ImageViewTransformationsColorConvert @@ -348,11 +340,11 @@ struct color_converted_view_type,DstP,CC> /// \tparam Views Models Boost.MP11-compatible list of models of ImageViewConcept template inline -auto color_converted_view(any_image_view const& src, CC) +auto color_converted_view(any_image_view const& src, CC cc) -> typename color_converted_view_type, DstP, CC>::type { using cc_view_t = typename color_converted_view_type, DstP, CC>::type; - return variant2::visit(detail::color_converted_view_fn(), src); + return variant2::visit(detail::color_converted_view_fn(cc), src); } /// \ingroup ImageViewTransformationsColorConvert @@ -360,7 +352,7 @@ auto color_converted_view(any_image_view const& src, CC) template struct color_converted_view_type,DstP> { - using type = detail::views_get_ccv_type, DstP, default_color_converter>; + using type = typename detail::views_get_ccv_type, DstP, default_color_converter>::type; }; /// \ingroup ImageViewTransformationsColorConvert diff --git a/test/extension/dynamic_image/image_view_factory.cpp b/test/extension/dynamic_image/image_view_factory.cpp index ce0ad9ee2..3837f740e 100644 --- a/test/extension/dynamic_image/image_view_factory.cpp +++ b/test/extension/dynamic_image/image_view_factory.cpp @@ -83,10 +83,77 @@ struct test_flipped_up_down_view } }; +template +bool equal_pixels_values(V1&& v1, + V2&& v2, + float threshold = 1e-6f) +{ +// convert both images to rgba32f and compare with threshold + return boost::variant2::visit([=](auto const& v1, auto const& v2) -> bool { + auto it1 = v1.begin(); + auto it2 = v2.begin(); + while(it1 != v1.end() && it2 != v2.end()) { + using pixel_t = gil::rgba32f_pixel_t; + static constexpr std::size_t num_channels = gil::num_channels::value; + pixel_t p1{}; + gil::color_convert(*it1++, p1); + pixel_t p2{}; + gil::color_convert(*it2++, p2); + for(size_t i = 0; i < num_channels; ++i) { + if(std::abs(p1[i] - p2[i]) > threshold){ + return false; + } + } + } + return true; + }, + std::forward(v1), + std::forward(v2)); +} + +struct test_color_converted_view +{ + static void run() + { + using dynamic_image_t = gil::any_image; + using src_image_t = gil::gray8_image_t; + using dst_image_t = gil::gray16_image_t; + using dst_pixel_t = typename dst_image_t::value_type; + static constexpr std::size_t num_channels = 1; + auto color_converter = [](auto const& src, auto& dst) { dst = 2 * src; }; + std::array pixel_data = + { + 0, 1, 2, + 3, 4, 5, + 6, 7, 8 + }; + std::array expected_pixel_data; + std::transform(std::begin(pixel_data), + std::end(pixel_data), + std::begin(expected_pixel_data), + [](auto v) { return 2 * v; }); + + dynamic_image_t source_image = + fixture::generate_image( + 3, 3, generator{pixel_data.data()}); + + dynamic_image_t expected_image = + fixture::generate_image( + 3, 3, generator{expected_pixel_data.data()}); + + auto result_view = gil::color_converted_view(gil::const_view(source_image), color_converter); + + BOOST_TEST(equal_pixels_values(result_view, + gil::const_view(expected_image), + 1e-6f)); + } +}; int main() { test_flipped_up_down_view::run(); + test_color_converted_view::run(); + return ::boost::report_errors(); } From ecea33a9051e607dd05db199fdbe6ccdb31a1a5a Mon Sep 17 00:00:00 2001 From: Samuel Debionne Date: Wed, 22 Feb 2023 11:59:12 +0100 Subject: [PATCH 09/20] fix: Make locator.hpp self contained (#729) --- include/boost/gil/locator.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/gil/locator.hpp b/include/boost/gil/locator.hpp index 776eedd33..f0e7c2036 100644 --- a/include/boost/gil/locator.hpp +++ b/include/boost/gil/locator.hpp @@ -8,8 +8,7 @@ #ifndef BOOST_GIL_LOCATOR_HPP #define BOOST_GIL_LOCATOR_HPP -#include -#include +#include #include #include From eabd679f632be3170d98145fcc3b49e85df7cc4b Mon Sep 17 00:00:00 2001 From: Marco Langer Date: Thu, 16 Mar 2023 21:08:04 +0100 Subject: [PATCH 10/20] fix: Documentation (#731) --- doc/design/dynamic_image.rst | 6 +++--- doc/io.rst | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/design/dynamic_image.rst b/doc/design/dynamic_image.rst index 546bfa4d9..ec9b01e3f 100644 --- a/doc/design/dynamic_image.rst +++ b/doc/design/dynamic_image.rst @@ -159,14 +159,14 @@ upside down: .. code-block:: cpp - #include + #include template // Could be rgb8_image_t or any_image<...> void save_180rot(const std::string& file_name) { Image img; - jpeg_read_image(file_name, img); - jpeg_write_view(file_name, rotated180_view(view(img))); + read_image(file_name, img, jpeg_tag()); + write_view(file_name, rotated180_view(view(img)), jpeg_tag()); } It can be instantiated with either a compile-time or a runtime image diff --git a/doc/io.rst b/doc/io.rst index 01462dbc9..6f4737167 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -172,6 +172,8 @@ provides access to the so-called backend. For instance:: + typedef bmp_tag tag_t; + typedef get_reader_backend< const std::string , tag_t >::type backend_t; @@ -245,7 +247,7 @@ The following example shows this feature:: , gray16_image_t , rgb8_image_t , rgba8_image_t - > my_img_types > runtime_image; + > runtime_image; read_image( filename , runtime_image @@ -323,7 +325,7 @@ Writing an any_image<...> is supported. See the following example:: , gray16_image_t , rgb8_image_t , rgba8_image_t - > my_img_types > runtime_image; + > runtime_image; // fill any_image From e24c87fde24a4027bc7a0a5c873ff18c39097128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Sun, 1 Oct 2023 21:47:08 +0200 Subject: [PATCH 11/20] ci: ubuntu-18.04 environment is deprecated (#738) * ci: ubuntu-18.04 environment is deprecated Switch to containers. --- .github/workflows/ci.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f8d379dc..fe72b72f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,14 @@ jobs: include: - toolset: gcc-6 cxxstd: "14,1z" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: g++-6 - toolset: gcc-7 cxxstd: "14,17" - os: ubuntu-18.04 - - toolset: gcc - compiler: g++-8 + install: g++-7 + os: ubuntu-20.04 + - toolset: gcc-8 cxxstd: "14" os: ubuntu-20.04 install: g++-8 @@ -41,17 +42,20 @@ jobs: - toolset: clang compiler: clang++-3.9 cxxstd: "14" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-3.9 - toolset: clang compiler: clang++-4.0 cxxstd: "14" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-4.0 - toolset: clang compiler: clang++-5.0 cxxstd: "14,1z" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-5.0 - toolset: clang compiler: clang++-6.0 @@ -82,13 +86,20 @@ jobs: os: macos-11 runs-on: ${{matrix.os}} + container: ${{matrix.container}} steps: - uses: actions/checkout@v3 + - name: Setup container environment + if: matrix.container + run: | + apt-get -y update + apt-get -y install sudo python3 git g++ + - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt-get -y install ${{matrix.install}} - name: Setup Boost run: | @@ -99,7 +110,7 @@ jobs: cd boost-root cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY ./bootstrap.sh ./b2 -d0 headers From 3a4d45443d90398df7b3cd627d5fa344a10fc091 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Mon, 25 Dec 2023 00:01:54 +0100 Subject: [PATCH 12/20] ci: update actions/checkout in GitHub Actions workflows to v4 (#739) --- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/docs.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe72b72f8..f8bddcd1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,7 +153,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a21a27549..f021f472b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,7 @@ jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: install packages diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 1308258f9..15eb10d23 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,7 +9,7 @@ jobs: build-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/actions/docs-prerequisites - uses: ./.github/actions/setup-boost - uses: ./.github/actions/generate-doc From 822c19ee7d1db079603f75ad544446523eec6847 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Mon, 25 Dec 2023 23:59:52 +0100 Subject: [PATCH 13/20] ci: fix Python package in coverage workflow (#740) --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f021f472b..3e9b878dd 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -21,7 +21,7 @@ jobs: - name: install packages run: | sudo apt update - sudo apt install g++ libpng-dev libjpeg-dev libtiff5-dev libraw-dev lcov python -y + sudo apt install g++ libpng-dev libjpeg-dev libtiff5-dev libraw-dev lcov python-is-python3 -y - name: Setup Boost run: | From 322c4e2e191458383db0f2873dd3301f05a7d137 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sat, 27 Jan 2024 13:09:10 +0300 Subject: [PATCH 14/20] Updated Boost.Filesystem usage. (#741) Removed usage of Boost.Filesystem APIs that were deprecated and then removed. --- test/extension/io/png/png_file_format_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/extension/io/png/png_file_format_test.cpp b/test/extension/io/png/png_file_format_test.cpp index f5713ca09..630cbc4e5 100644 --- a/test/extension/io/png/png_file_format_test.cpp +++ b/test/extension/io/png/png_file_format_test.cpp @@ -42,14 +42,14 @@ void test_file_format() fs::directory_iterator end_iter; for (fs::directory_iterator dir_itr(in_path); dir_itr != end_iter; ++dir_itr) { - if (fs::is_regular(dir_itr->status()) && (fs::extension(dir_itr->path()) == ".PNG")) + if (fs::is_regular_file(dir_itr->status()) && (dir_itr->path().extension().string() == ".PNG")) { gil::rgb8_image_t img; - std::string filename = in + dir_itr->path().leaf().string(); + std::string filename = in + dir_itr->path().filename().string(); gil::read_and_convert_image(filename, img, gil::png_tag()); #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES - gil::write_view(png_out + fs::basename(dir_itr->path()) + ".png", + gil::write_view(png_out + dir_itr->path().stem().string() + ".png", gil::view(img), gil::png_tag()); #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } From 2c3ee866b614d3c0695ae5de5931c366466b559f Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Thu, 18 Apr 2024 10:21:09 +0200 Subject: [PATCH 15/20] Portable minmax Win32-API workaround #744 (#745) Co-authored-by: Christopher Kormanyos --- include/boost/gil/extension/histogram/std.hpp | 4 ++-- include/boost/gil/extension/io/tiff/detail/read.hpp | 6 +++--- include/boost/gil/histogram.hpp | 12 ++++++------ .../gil/image_processing/histogram_equalization.hpp | 8 ++++---- .../gil/image_processing/histogram_matching.hpp | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/boost/gil/extension/histogram/std.hpp b/include/boost/gil/extension/histogram/std.hpp index a01507821..67e9a66f6 100644 --- a/include/boost/gil/extension/histogram/std.hpp +++ b/include/boost/gil/extension/histogram/std.hpp @@ -59,7 +59,7 @@ void fill_histogram(SrcView const& srcview, std::vector& histogram, bool accu if (!accumulate) histogram.clear(); - histogram.resize(std::numeric_limits::max() + 1); + histogram.resize((std::numeric_limits::max)() + 1); for_each_pixel(color_converted_view(srcview), [&](pixel_t const& p) { ++histogram[static_cast(p)]; @@ -81,7 +81,7 @@ void fill_histogram(SrcView const& srcview, std::array& histogram, bool ac using channel_t = typename channel_type::type; using pixel_t = pixel; - const size_t pixel_max = std::numeric_limits::max(); + const size_t pixel_max = (std::numeric_limits::max)(); const float scale = (histogram.size() - 1.0f) / pixel_max; if (!accumulate) diff --git a/include/boost/gil/extension/io/tiff/detail/read.hpp b/include/boost/gil/extension/io/tiff/detail/read.hpp index e0f40f412..13ce23d61 100644 --- a/include/boost/gil/extension/io/tiff/detail/read.hpp +++ b/include/boost/gil/extension/io/tiff/detail/read.hpp @@ -663,9 +663,9 @@ class reader< Device std::size_t element_size = sizeof( Pixel ); - std::size_t ret = std::max( width - , (( scanline_size_in_bytes + element_size - 1 ) / element_size ) - ); + std::size_t ret = (std::max)( width + , (( scanline_size_in_bytes + element_size - 1 ) / element_size ) + ); return ret; } diff --git a/include/boost/gil/histogram.hpp b/include/boost/gil/histogram.hpp index 9bf66ab90..901208954 100644 --- a/include/boost/gil/histogram.hpp +++ b/include/boost/gil/histogram.hpp @@ -136,11 +136,11 @@ bool tuple_compare(Tuple const& t1, Tuple const& t2) template struct tuple_limit { - static constexpr Tuple min() + static constexpr Tuple (min)() { return min_impl(boost::mp11::make_index_sequence::value>{}); } - static constexpr Tuple max() + static constexpr Tuple (max)() { return max_impl(boost::mp11::make_index_sequence::value>{}); } @@ -150,14 +150,14 @@ struct tuple_limit static constexpr Tuple min_impl(boost::mp11::index_sequence) { return std::make_tuple( - std::numeric_limits::type>::min()...); + (std::numeric_limits::type>::min)()...); } template static constexpr Tuple max_impl(boost::mp11::index_sequence) { return std::make_tuple( - std::numeric_limits::type>::max()...); + (std::numeric_limits::type>::max)()...); } }; @@ -638,9 +638,9 @@ void fill_histogram( bool applymask = false, std::vector> mask = {}, typename histogram::key_type lower = - detail::tuple_limit::key_type>::min(), + (detail::tuple_limit::key_type>::min)(), typename histogram::key_type upper = - detail::tuple_limit::key_type>::max(), + (detail::tuple_limit::key_type>::max)(), bool setlimits = false) { if (!accumulate) diff --git a/include/boost/gil/image_processing/histogram_equalization.hpp b/include/boost/gil/image_processing/histogram_equalization.hpp index 6ce3c5ef3..fba98f87c 100644 --- a/include/boost/gil/image_processing/histogram_equalization.hpp +++ b/include/boost/gil/image_processing/histogram_equalization.hpp @@ -70,8 +70,8 @@ auto histogram_equalization(histogram const& src_hist, histogram::value_type; dst_hist.clear(); double sum = src_hist.sum(); - SrcKeyType min_key = std::numeric_limits::min(); - SrcKeyType max_key = std::numeric_limits::max(); + SrcKeyType min_key = (std::numeric_limits::min)(); + SrcKeyType max_key = (std::numeric_limits::max)(); auto cumltv_srchist = cumulative_histogram(src_hist); std::map color_map; std::for_each(cumltv_srchist.begin(), cumltv_srchist.end(), [&](value_t const& v) { @@ -120,8 +120,8 @@ void histogram_equalization( std::size_t const channels = num_channels::value; coord_t const width = src_view.width(); coord_t const height = src_view.height(); - std::size_t pixel_max = std::numeric_limits::max(); - std::size_t pixel_min = std::numeric_limits::min(); + std::size_t pixel_max = (std::numeric_limits::max)(); + std::size_t pixel_min = (std::numeric_limits::min)(); for (std::size_t i = 0; i < channels; i++) { diff --git a/include/boost/gil/image_processing/histogram_matching.hpp b/include/boost/gil/image_processing/histogram_matching.hpp index 25107a7de..1b947c426 100644 --- a/include/boost/gil/image_processing/histogram_matching.hpp +++ b/include/boost/gil/image_processing/histogram_matching.hpp @@ -166,10 +166,10 @@ void histogram_matching( std::size_t const channels = num_channels::value; coord_t const width = src_view.width(); coord_t const height = src_view.height(); - source_channel_t src_pixel_min = std::numeric_limits::min(); - source_channel_t src_pixel_max = std::numeric_limits::max(); - ref_channel_t ref_pixel_min = std::numeric_limits::min(); - ref_channel_t ref_pixel_max = std::numeric_limits::max(); + source_channel_t src_pixel_min = (std::numeric_limits::min)(); + source_channel_t src_pixel_max = (std::numeric_limits::max)(); + ref_channel_t ref_pixel_min = (std::numeric_limits::min)(); + ref_channel_t ref_pixel_max = (std::numeric_limits::max)(); for (std::size_t i = 0; i < channels; i++) { From 4fec872feb14897c41c95583c595ac0836d1ba51 Mon Sep 17 00:00:00 2001 From: Olzhas Zhumabek Date: Fri, 10 May 2024 09:36:48 +0200 Subject: [PATCH 16/20] feat: Guard boost::filesystem usage (#743) CMake was unopinionated about what filesystem is used and required excessive flag setting. Now it clarifies that boost::filesystem is default and std::filesystem is used in case BOOST_GIL_USE_BOOST_FILESYSTEM is off and CMAKE_CXX_STANDARD>=17. --- CMakeLists.txt | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd94577e8..dae5c5823 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,8 +60,13 @@ option(BOOST_GIL_ENABLE_EXT_RASTERIZATION "Enable Rasterization extension and te option(BOOST_GIL_ENABLE_EXT_IMAGE_PROCESSING "Enable Image Processing extension (!) and tests" ON) option(BOOST_GIL_USE_CONAN "Use Conan to install dependencies" OFF) option(BOOST_GIL_USE_CLANG_TIDY "Set CMAKE_CXX_CLANG_TIDY property on targets to enable clang-tidy linting" OFF) +option(BOOST_GIL_USE_BOOST_FILESYSTEM "Use boost::filesystem, disabling requires CMAKE_CXX_STANDARD >= 17" ON) set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard version to use (default is 14)") +if (NOT BOOST_GIL_USE_BOOST_FILESYSTEM AND CMAKE_CXX_STANDARD LESS 17) + message(FATAL_ERROR "Using std::filesystem requires CMAKE_CXX_STANDARD >= 17") +endif() + #----------------------------------------------------------------------------- # Project #----------------------------------------------------------------------------- @@ -105,13 +110,20 @@ target_compile_options(gil_compile_options $<$,$>:-fstrict-aliasing> $<$,$>,$>>:-Wall -Wconversion -Wextra -Wfloat-equal -Wshadow -Wsign-promo -Wstrict-aliasing -Wunused-parameter -pedantic>) + +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + set(filesystem_definition "BOOST_GIL_USE_BOOST_FILESYSTEM") +else() + set(filesystem_definition "BOOST_GIL_IO_USE_STD_FILESYSTEM") +endif() target_compile_definitions(gil_compile_options INTERFACE $<$:_CRT_NONSTDC_NO_DEPRECATE> $<$:_SCL_SECURE_NO_DEPRECATE> $<$:_CRT_SECURE_NO_WARNINGS> $<$:NOMINMAX> - $<$:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE>) + $<$:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE> + ${filesystem_definition}) #----------------------------------------------------------------------------- # Dependency target @@ -140,12 +152,18 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(Boost_USE_STATIC_RUNTIME OFF) endif() -find_package(Boost 1.80.0 REQUIRED COMPONENTS filesystem) +set(Boost_required_components headers) +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + list(APPEND Boost_required_components filesystem) +endif() +find_package(Boost 1.80.0 REQUIRED COMPONENTS ${Boost_required_components}) message(STATUS "Boost.GIL: Using Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}") message(STATUS "Boost.GIL: Using Boost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}") -target_link_libraries(gil_dependencies INTERFACE Boost::filesystem) - +target_link_libraries(gil_dependencies INTERFACE Boost::headers) +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + target_link_libraries(gil_dependencies INTERFACE Boost::filesystem) +endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") target_link_libraries(gil_dependencies INTERFACE Boost::disable_autolinking) endif() From abb561a226b02e2b7cb4a18a11050a0e60aaa4d9 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Mon, 13 May 2024 09:58:59 +0200 Subject: [PATCH 17/20] fix: Wrong buffer size in path string conversion functions (#746) Fixes #733 --- include/boost/gil/io/path_spec.hpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/boost/gil/io/path_spec.hpp b/include/boost/gil/io/path_spec.hpp index 7b0c91d2f..0dd499b04 100644 --- a/include/boost/gil/io/path_spec.hpp +++ b/include/boost/gil/io/path_spec.hpp @@ -1,5 +1,6 @@ // // Copyright 2007-2008 Andreas Pokorny, Christian Henning +// Copyright 2024 Dirk Stolle // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at @@ -11,6 +12,7 @@ #include #include +#include #include #include @@ -41,11 +43,13 @@ inline std::string convert_to_string( std::string const& obj) inline std::string convert_to_string( std::wstring const& s ) { - std::size_t len = wcslen( s.c_str() ); - char* c = reinterpret_cast( alloca( len )); - wcstombs( c, s.c_str(), len ); + std::mbstate_t state = std::mbstate_t(); + const wchar_t* str = s.c_str(); + const std::size_t len = std::wcsrtombs(nullptr, &str, 0, &state); + std::string result(len, '\0'); + std::wcstombs( &result[0], s.c_str(), len ); - return std::string( c, c + len ); + return result; } inline std::string convert_to_string( char const* str ) @@ -80,18 +84,21 @@ inline char const* convert_to_native_string( const std::string& str ) inline char const* convert_to_native_string( const wchar_t* str ) { - std::size_t len = wcslen( str ) + 1; + std::mbstate_t state = std::mbstate_t(); + const std::size_t len = std::wcsrtombs(nullptr, &str, 0, &state) + 1; char* c = new char[len]; - wcstombs( c, str, len ); + std::wcstombs( c, str, len ); return c; } inline char const* convert_to_native_string( std::wstring const& str ) { - std::size_t len = wcslen( str.c_str() ) + 1; + std::mbstate_t state = std::mbstate_t(); + const wchar_t* wstr = str.c_str(); + const std::size_t len = std::wcsrtombs(nullptr, &wstr, 0, &state) + 1; char* c = new char[len]; - wcstombs( c, str.c_str(), len ); + std::wcstombs( c, str.c_str(), len ); return c; } From 481b6e7c14a289df86856fb0c755b3947eee3fa7 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Fri, 17 May 2024 11:43:44 +0200 Subject: [PATCH 18/20] feat: add tell() and error() functions to istream + ostream devices (#747) The class file_stream_device already has such functions, and now both istream_device and ostream_device have them, too, making the device classes more consistent. Closes #724 --- include/boost/gil/io/device.hpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/include/boost/gil/io/device.hpp b/include/boost/gil/io/device.hpp index 41865001f..fb531cd80 100644 --- a/include/boost/gil/io/device.hpp +++ b/include/boost/gil/io/device.hpp @@ -1,5 +1,6 @@ // // Copyright 2007-2012 Christian Henning, Andreas Pokorny +// Copyright 2024 Dirk Stolle // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at @@ -409,6 +410,17 @@ class istream_device ); } + long int tell() + { + auto pos = _in.tellg(); + + io_error_if( pos == std::istream::pos_type(-1) + , "istream_device: file position error" + ); + + return static_cast(pos); + } + void write(const byte_t*, std::size_t) { io_error( "istream_device: Bad io error." ); @@ -416,6 +428,11 @@ class istream_device void flush() {} + int error() + { + return _in.fail(); + } + private: std::istream& _in; @@ -450,6 +467,17 @@ class ostream_device ); } + long int tell() + { + auto pos = _out.tellp(); + + io_error_if( pos == std::ostream::pos_type(-1) + , "ostream_device: file position error" + ); + + return static_cast(pos); + } + void write( const byte_t* data , std::size_t count ) { @@ -509,7 +537,10 @@ class ostream_device _out << line; } - + int error() + { + return _out.fail(); + } private: From 6e49d52b11374c76ecbe1c7104a51a0096a0225a Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Thu, 4 Jul 2024 16:46:21 +0200 Subject: [PATCH 19/20] docs: Add release notes for Boost 1.86 (#749) --- RELEASES.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index da984ef64..56c517cfe 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3,6 +3,29 @@ All notable changes to [Boost.GIL](https://github.com/boostorg/gil/) project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [1.86.0] - 2024-08-14 + +### Added + +- Added `tell()` and `error()` functions to `istream_device` and `ostream_device` classes ([PR #747](https://github.com/boostorg/gil/pull/747)). + +## Changed + +- Don't ignore custom color converter in `color_converted_view` function ([PR #726](https://github.com/boostorg/gil/pull/726)). +- Added workaround for conflict with `min()` and `max()` macros on WinAPI ([PR #745](https://github.com/boostorg/gil/pull/745)). +- The use of `boost::filesystem` in GIL is now configurable in CMake via option `BOOST_GIL_USE_BOOST_FILESYSTEM` ([PR #743](https://github.com/boostorg/gil/pull/743)). + +### Fixed + +- Fixed convolution in `convolve_2d` ([PR #723](https://github.com/boostorg/gil/pull/723)) +- Normalize Gaussian 2D kernel to avoid darkening ([PR #725](https://github.com/boostorg/gil/pull/725)) +- Wrong buffer size in path string conversion functionss for `std::wstring` is fixed, avoiding buffer + overflows when using I/O-related functions with `std::wstring` paths ([PR #746](https://github.com/boostorg/gil/pull/764)). + +### Acknowledgements + +Christoph Gringmuth, Christopher Kormanyos, nicolacandussi, Dirk Stolle, Olzhas Zhumabek + ## [1.80.0] - 2022-08-10 NOTICE: We are planning BREAKING switch to C++17 as minimum required C++ language version in one or two releases after Boost 1.80 ([Discussion #676](https://github.com/boostorg/gil/discussions/676)) From 67f021ae3db9db6d0e3d3ffa47efd0b6764af82f Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Fri, 5 Jul 2024 00:56:34 +0200 Subject: [PATCH 20/20] CI improvements and workarounds (#750) * ci: add workaround for failing container jobs Node.js 20 is not supported in older containers like ubuntu:18.04, but GitHub Actions nowawadays forces the use of Node.js 20, even if the action itself still specified Node.js 16 as the version to use. The result is that e.g. `actions/checkout@v3` fails in the containers, although it should not (because v3 is still specified Node.js 16). See for more information on that forced Node.js version. Fortunately, there still is a workaround to restore the old behaviour, and that is to set a environment variable to allow older Node.js to be used in those actions, and that is what this change does. * ci: switch from macOS 11 to macOS 12 The runner image for macOS 11 has been removed on 2024-06-28. See for more information on that. So the easiest fix is probably just to move to the next newest version of macOS that is still avaiable for GHA. --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8bddcd1b..492b21d1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ on: env: LIBRARY: gil UBSAN_OPTIONS: print_stacktrace=1 + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: posix: @@ -83,7 +84,7 @@ jobs: os: ubuntu-20.04 - toolset: clang cxxstd: "14,17" - os: macos-11 + os: macos-12 runs-on: ${{matrix.os}} container: ${{matrix.container}}