Boost.GIL - Generic Image Library | Requires C++11 since Boost 1.68

Overview

Boost Generic Image Library (GIL)

Language License Documentation Wiki Mailing List Gitter Try it online Conan Vcpkg

Documentation GitHub Actions AppVeyor Azure Pipelines CircleCI Regression Codecov
develop GitHub Actions AppVeyor Azure CircleCI gil codecov
master GitHub Actions AppVeyor Azure CircleCI gil codecov

Boost.GIL

Introduction

Boost.GIL is a part of the Boost C++ Libraries.

The Boost Generic Image Library (GIL) is a C++11 header-only library that abstracts image representations from algorithms and allows writing code that can work on a variety of images with performance similar to hand-writing for a specific image type.

Documentation

See RELEASES.md for release notes.

See CONTRIBUTING.md for instructions about how to build and run tests and examples using Boost.Build or CMake.

See example/README.md for GIL usage examples.

See example/b2/README.md for Boost.Build configuration examples.

See example/cmake/README.md for CMake configuration examples.

Requirements

NOTE: The library source code is currently being modernized for C++11.

The Boost Generic Image Library (GIL) requires:

  • C++11 compiler (GCC 4.9, clang 3.3, MSVC++ 14.0 (1900) or any later version)
  • Boost header-only libraries

Optionally, in order to build and run tests and examples:

  • Boost.Filesystem
  • Boost.Test
  • Headers and libraries of libjpeg, libpng, libtiff, libraw for the I/O extension and some of examples.

Branches

The official repository contains the following branches:

  • master This holds the most recent snapshot with code that is known to be stable.

  • develop This holds the most recent snapshot. It may contain unstable code.

Community

There is number of communication channels to ask questions and discuss Boost.GIL issues:

Contributing (We Need Your Help!)

If you would like to contribute to Boost.GIL, help us improve the library and maintain high quality, there is number of ways to do it.

If you would like to test the library, contribute new feature or a bug fix, see the CONTRIBUTING.md where the whole development infrastructure and the contributing workflow is explained in details.

You may consider performing code reviews on active pull requests or help with solving reported issues, especially those labelled with:

Any feedback from users and developers, even simple questions about how things work or why they were done a certain way, carries value and can be used to improve the library.

License

Distributed under the Boost Software License, Version 1.0.

Issues
  • Fix any_image_view::const_t

    Fix any_image_view::const_t

    Description

    Fix any_image_view<>::const_t that currently returns an invalid type, see the provided test case that fails on develop.

    Tasklist

    • [x] Add test case(s)
    • [x] Ensure all CI builds pass
    • [x] Review and approve
    cat/bug ext/dynamic_image 
    opened by sdebionne 36
  • Implement Sobel and Scharr operators

    Implement Sobel and Scharr operators

    Description

    This commit adds Sobel and Scharr operators with support for 0th and 1st degrees with other degrees planned for later

    References

    https://www.researchgate.net/publication/239398674_An_Isotropic_3_3_Image_Gradient_Operator

    https://www.researchgate.net/profile/Hanno_Scharr/publication/220955743_Optimal_Filters_for_Extended_Optical_Flow/links/004635151972eda98f000000/Optimal-Filters-for-Extended-Optical-Flow.pdf

    Tasklist

    • [X] Implement the operators
    • [X] Add test case(s)
    • [ ] Ensure all CI builds pass
    • [ ] Review and approve
    cat/feature 
    opened by simmplecoder 35
  • Add variant=release to Travis CI builds of tests

    Add variant=release to Travis CI builds of tests

    This aims to confirm there are no issues depending on build configuration (related to #46 and #49).

    References

    #51


    BTW, variant=debug,release is intentional, it first builds tests with variant=debug, then variant=release.

    opened by mloskot 26
  • Compilation of extension/dynamic_image/apply_operation_base.hpp takes ages with GCC 7 or 8

    Compilation of extension/dynamic_image/apply_operation_base.hpp takes ages with GCC 7 or 8

    The compilation of the io jpeg extension takes ages with g++ (boost 1.68.0):

    Minimal Working Example (in C++)

    #include <boost/gil/extension/io/jpeg.hpp>
    int main() {
      return 0;
    }
    

    Actual behavior

    compiles on my x86_64 linux system:

    • in 2 min 37 s with g++ 8.2.0 in release mode: -O2 -DNDEBUG -Wall -Wextra -Wnon-virtual-dtor -Werror=delete-non-virtual-dtor -pipe -march=native -std=c++14 -DBOOST_DISABLE_ASSERTS
    • in 2 min 37 s with g++ 8.2.0 in debug mode: -g3 -Wall -Wextra -Wnon-virtual-dtor -Werror=delete-non-virtual-dtor -pipe -march=native -std=c++14

    But it is very fast with clang 5.0.2

    • in 5 s with clang 5.0.2 in release mode: -O2 -DNDEBUG -Wall -Wextra -Wnon-virtual-dtor -Werror=delete-non-virtual-dtor -pipe -march=native -std=c++14 -DBOOST_DISABLE_ASSERTS
    • in 5 s with clang 5.0.2 in debug mode: -g3 -Wall -Wextra -Wnon-virtual-dtor -Werror=delete-non-virtual-dtor -pipe -march=native -std=c++14

    -ftime-report gives the following time breakdown:

    Time variable                                   usr           sys          wall               GGC
     phase setup                        :   0.01 (  0%)   0.00 (  0%)   0.01 (  0%)    1646 kB (  0%)
     phase parsing                      : 154.97 (100%)   2.28 ( 99%) 157.74 (100%)  412923 kB ( 98%)
     phase lang. deferred               :   0.06 (  0%)   0.01 (  0%)   0.07 (  0%)    6184 kB (  1%)
     phase opt and generate             :   0.01 (  0%)   0.01 (  0%)   0.01 (  0%)     561 kB (  0%)
     |name lookup                       :   0.47 (  0%)   0.13 (  6%)   0.69 (  0%)   13160 kB (  3%)
     |overload resolution               :   0.06 (  0%)   0.01 (  0%)   0.11 (  0%)    7204 kB (  2%)
     garbage collection                 :   0.08 (  0%)   0.00 (  0%)   0.08 (  0%)       0 kB (  0%)
     callgraph construction             :   0.01 (  0%)   0.01 (  0%)   0.00 (  0%)     484 kB (  0%)
     preprocessing                      :   1.07 (  1%)   0.65 ( 28%)   1.89 (  1%)  190652 kB ( 45%)
     parser (global)                    :   0.55 (  0%)   0.50 ( 22%)   0.90 (  1%)   91965 kB ( 22%)
     parser struct body                 :   0.34 (  0%)   0.05 (  2%)   0.40 (  0%)   36645 kB (  9%)
     parser function body               :   0.08 (  0%)   0.03 (  1%)   0.12 (  0%)    3138 kB (  1%)
     parser inl. func. body             :   0.05 (  0%)   0.02 (  1%)   0.05 (  0%)    3248 kB (  1%)
     parser inl. meth. body             :   1.39 (  1%)   0.10 (  4%)   1.49 (  1%)   55566 kB ( 13%)
     template instantiation             : 151.46 ( 98%)   0.93 ( 40%) 152.87 ( 97%)   37564 kB (  9%)
     constant expression evaluation     :   0.01 (  0%)   0.01 (  0%)   0.01 (  0%)     134 kB (  0%)
     tree PTA                           :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)       0 kB (  0%)
     TOTAL                              : 155.05          2.30        157.83         421325 kB
    

    So it is mostly template instantiation although nothing is instantiated.

    Expected behavior

    I would hope that such file compile within a few seconds.

    Environment

    Fedora 27 x86_64 linux

    All relevant information like:

    • Boost version (see <boost/version.hpp>): 1.68.0

    Is there anything that can be done to improve the compile time with g++?

    ext/dynamic_image 
    opened by kivadiu 22
  • Added all standard morphological transformations

    Added all standard morphological transformations

    Description

    This pull request adds all standard morphological transformations in Boost Gil library.

    Summary of applied morphological concepts:

    1. Dilation: Gives the maximum overlapped value with respect to the structuring element to the pixel overlapping with the center element of structuring element.We can vary the number of times dilation happens by varying the argument 'iterations' in the dilate function.
    2. Erosion: Give the minimum overlapped value with respect to the structuring element to the pixel overlapping with the center element of structuring element.We can vary the number of times erosion happens by varying the argument 'iterations' in the erode function.
    3. Opening: Opening is just another name of erosion followed by dilation. It is useful in removing noise.
    4. Closing: Closing is reverse of Opening, Dilation followed by Erosion. It is useful in closing small holes inside the foreground objects, or small black points on the object.
    5. Morphological Gradient: It is the difference between dilation and erosion of an image. The result will look like the outline of the object.
    6. Top Hat: It is the difference between input image and Opening of the image.
    7. Black Hat: It is the difference between the closing of the input image and input image. Functions have been made for applying above morphological transformations.

    References

    https://homepages.inf.ed.ac.uk/rbf/HIPR2/dilate.htm https://homepages.inf.ed.ac.uk/rbf/HIPR2/erode.htm https://docs.opencv.org/master/d9/d61/tutorial_py_morphological_ops.html

    Tasklist

    • [x] Add test case(s)
    • [x] Ensure all CI builds pass - RIP Travis CI, ignored and replaced with GitHub Actions
    • [x] Review and approve
    cat/feature core 
    opened by meshtag 19
  • Switch docs deployment from Travis CI to GitHub Actions

    Switch docs deployment from Travis CI to GitHub Actions

    Migration of Documentation Deployment From Travis CI to GitHub Actions

    This pull request is in reference to the issue #549 .

    Changes Made

    • A new workflow has been added named docs.yaml under the .github/workflow directory
    • Three new actions have been introduced
    • docs-prerequisites : Gets all the necessary packages for generating the documentation
    • setup-boost : Sets up boost
    • generate-publish-doc : Generates the documentation and uploads the necessary files ( as per the branch ) to gh-pages branch

    References

    #549

    Tasklist

    • [ ] Add test case(s)
    • [ ] Ensure all CI builds pass
    • [ ] Review and approve
    cat/documentation 
    opened by gopi487krishna 15
  • Replace Boost.Variant with Boost.Variant2

    Replace Boost.Variant with Boost.Variant2

    Description

    Implements dynamic extension with Boost.Variant2 instead of Boost.Variant.

    References

    Fixes #232

    Tasklist

    • [x] Update/Add test case(s)
    • [x] Update doc(s)
    • [x] Update extension usage in I/O
    • [x] Ensure all CI builds pass
    • [x] Review and approve
    cat/enhancement 
    opened by sdebionne 15
  • Adding Morphological Dilation and Erosion Algorithms

    Adding Morphological Dilation and Erosion Algorithms

    Description

    Morphological Dilation and Erosion algorithms implemented (for grayscale images). This PR is also meant to be my solution for the competency test for GSoC 2020.

    Dilation/Erosion process is performed by laying the structuring element H on the image I and sliding it across the image in a manner similar to convolution.

    1. Morphological Dilation - The grayscale morphological dilation formula is written as follows : [𝐼⊕𝐻](𝑢,𝑣)=max(𝑖,𝑗)∈𝐻{𝐼(𝑢−𝑖,𝑣−𝑗)+𝐻(𝑖,𝑗)}
    2. Morphological Erosion - The grayscale morphological erosion formula is written as follows : [𝐼⊕𝐻](𝑢,𝑣)=min(𝑖,𝑗)∈𝐻{𝐼(𝑢−𝑖,𝑣−𝑗)+𝐻(𝑖,𝑗)}

    References

    • https://lists.boost.org/Archives/boost/2020/01/248134.php thread with initial discussion
    • https://en.wikipedia.org/wiki/Dilation_(morphology)#Grayscale_dilation
    • https://en.wikipedia.org/wiki/Erosion_(morphology)

    Further development during GSoC 2020

    Tasklist

    • [x] Add basic test case(s)
    • [x] Add more advanced test case(s)
    • [x] Ensure all CI builds pass
    • [ ] Review and approve
    cat/feature core google-summer-of-code 
    opened by ayushbansal07 15
  • Custom PNG error handler

    Custom PNG error handler

    Description

    This pull request sets custom error handler function to avoid all of the problems stated in the referenced pages, and also hopefully deals with the resource leak that happens when objects with non-trivial destructors are declared after setjmp part.

    References

    http://www.libpng.org/pub/png/book/chapter13.html

    http://www.libpng.org/pub/png/book/chapter14.html

    Tasklist

    • [ ] Find some way to bypass C ABI
    • Add test case(s) not applicable
    • [ ] Ensure all CI builds pass
    • [ ] Review and approve
    cat/bug core/io 
    opened by simmplecoder 15
  • JPEG I/O calls jpeg_ functions without proper setjmp

    JPEG I/O calls jpeg_ functions without proper setjmp

    This is sister issue of #401 for JPEG I/O.

    One example is writer_backend destructor: https://github.com/boostorg/gil/blob/79ad37f75a07c8d0931afbfd32e6cbfed9af7271/include/boost/gil/extension/io/jpeg/detail/writer_backend.hpp#L114-L118

    When called from write_view there is no valid setjmp where longjmp from jpeg_ functions can jump. If it happens it will jump into some function with already destroyed frame like writer_backend constructor or write_rows. I think we should not assume that jpeg_finish_compress or any jpeg_ function cannot call error handler.

    There can be more such places. Possible solution would be to setup setjmp at top of each function which calls jpeg_ functions.

    cat/bug ext/io 
    opened by misos1 15
  • Segmentation fault when reading purposely corrupted png image (related to jpeg)

    Segmentation fault when reading purposely corrupted png image (related to jpeg)

    Actual behavior

    Segmentation fault - signal SIGSEGV.

    In png read.hpp in functions which use png library like apply and read_rows is missing setjmp setup as is done in jpeg read.hpp. Latest setjmp is used in png reader_backend.hpp in function read_header so for example any png error during decompression in read_rows in png_read_rows will cause longjmp to jump to this place which is inside function which frame at this point is already destroyed and so subsequent call to png_destroy_read_struct causes crash.

    libpng error: Not enough image data
    Process 20104 stopped
    * thread #1, name = 'a.out', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
        frame #0: 0x00007ffff7bb3cbd libpng16.so.16`png_destroy_read_struct + 13
    libpng16.so.16`png_destroy_read_struct:
    

    Expected behavior

    Gracefully thrown exception.

    C++ Minimal Working Example

    #include <boost/gil.hpp>
    #include <boost/gil/extension/io/png.hpp>
    
    int main()
    {
    	std::initializer_list<unsigned char> corrupt_png = {
    		0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A,
    		0x00, 0x00, 0x00, 0x0D,
    		'I', 'H', 'D', 'R',
    		0x00, 0x00, 0x04, 0x00,
    		0x00, 0x00, 0x05, 0xA9,
    		0x08, 0x02, 0x00, 0x00, 0x00,
    		0x68, 0x1B, 0xF7, 0x46,
    		0x00, 0x00, 0x00, 0x00,
    		'I', 'D', 'A', 'T',
    		0x35, 0xAF, 0x06, 0x1E,
    		0x00, 0x00, 0x00, 0x00,
    		'I', 'E', 'N', 'D',
    		0xAE, 0x42, 0x60, 0x82
    	};
    	std::stringstream ss(std::string(corrupt_png.begin(), corrupt_png.end()), std::ios_base::in | std::ios_base::binary);
    	boost::gil::rgb8_image_t img;
    	boost::gil::read_image(ss, img, boost::gil::png_tag{});
    	return 0;
    }
    

    Environment

    • Compiler version: -
    • Build settings: -
    • Version (Git ref or <boost/version.hpp>): latest master 1_71
    cat/bug ext/io 
    opened by misos1 15
  • fix: Wrong return type of copy_fn and missing typedef in destruct_range

    fix: Wrong return type of copy_fn and missing typedef in destruct_range

    Description

    This PR fixes some minor issues in algorithm.hpp:

    • removed unnecessary non-const std::copy overload
    • fixed wrong return type of copy_fn
    • added missing typedef to destruct_range

    Tasklist

    • [x] Ensure all CI builds pass
    • [x] Review and approve
    cat/bug 
    opened by marco-langer 3
  • Consider moving channel_convert_to_unsigned out of detail namespace

    Consider moving channel_convert_to_unsigned out of detail namespace

    From @marco-langer https://github.com/boostorg/gil/pull/703#issuecomment-1172915455

    Regarding this channel_convert_to_unsigned, which is now in the detail namespace, but also still referenced in this tutorial:

    Maybe one should think to pull it out of the detail namespace again, if it is that useful for client code? I don't know the rational why it was moved into the detail namespace at all (this was done 15 years ago!).

    I think, it is worth to keep this discussion open and come back to it in future.


    For the records, it moved into detail in https://github.com/boostorg/gil/commit/2ad6747dd0472cef7c67b3438b847f347ce45212 which refers to the "GIL 2.0 to GIL 2.1 Changes" PDF. Since I have got this gil2.1_changes.pdf, I've attached it for the reference. It does not explain the move rationale though.

    I attached also earlier gil2.0_changes.pdf which lists lots of changes related to Boost'ification of the Adobe GIL library. This makes me guess that moving of the types into the detail namespace may be related to the unification of GIL according to Boost conventions.

    (both legacy documents available at https://github.com/boostorg/gil/wiki/History)

    cat/refactoring 
    opened by mloskot 0
  • feat: Generalized threshold algorithm for all kind of pixel types

    feat: Generalized threshold algorithm for all kind of pixel types

    Description

    This PR implements the channel traits min and max values for binary, truncate and adaptive thresholds and thereby extends the possible pixel types for these algorithms.

    The current test cases are all green, but I will also add new test cases for floating point types and signed integer types soon.

    References

    Closes #697

    Tasklist

    • [ ] Add test case(s)
    • [ ] Ensure all CI builds pass
    • [ ] Review and approve
    opened by marco-langer 1
  • Fix wrong pixel channel truncation in binary threshold and truncate threshold

    Fix wrong pixel channel truncation in binary threshold and truncate threshold

    Actual behavior

    gil::threshold_truncate() and gil::threshold_binary() from gil/image_processing/truncate.hpp employ a hard-coded value of 0 for the channel minimum value and a value of std::numeric_limits<channel_t>::max() for the maximum value. This works only for unsigned integer channel types such as gil::rgb8_pixel_t and gil::gray8_pixel_t, but does not work for signed channel types and also not for floating point types whose value range is limited from 0.0 to 1.0.

    Edit: Otsu thresholding also employs std::numeric_limits, which is invalid for scoped channels.

    Expected behavior

    Correct channel value truncation according to the channel min/max values.

    ext/image_processing 
    opened by marco-langer 2
  • Refactor any_image tests after deprecating apply_operation in #656

    Refactor any_image tests after deprecating apply_operation in #656

    Saving @marco-langer 's https://github.com/boostorg/gil/pull/656#issuecomment-1166430775 as task for future

    the core library refactoring is done. I think we can add/refactor the tests also after the Boost 1.80 deadline.

    test 
    opened by mloskot 0
Owner
Boost.org
Boost provides free peer-reviewed portable C++ source libraries.
Boost.org
requests-like networking library using boost for C++

cq == C++ Requests cq == C++ Requests is a "Python Requests"-like C++ header-only library for sending HTTP requests. The library is inspired a lot by

null 11 Dec 15, 2021
Ole Christian Eidheim 737 Aug 6, 2022
Lightweight, header-only, Boost-based socket pool library

Stream-client This is a lightweight, header-only, Boost-based library providing client-side network primitives to easily organize and implement data t

Tinkoff.ru 12 Aug 5, 2022
Packio - An asynchronous msgpack-RPC and JSON-RPC library built on top of Boost.Asio.

Header-only | JSON-RPC | msgpack-RPC | asio | coroutines This library requires C++17 and is designed as an extension to boost.asio. It will let you bu

Quentin Chateau 49 Aug 8, 2022
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio.

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Ole Christian Eidheim 2.3k Aug 2, 2022
Minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file

cz-spas czspas (Small Portable Asynchronous Sockets) is minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file.

Rui Figueira 25 Jun 12, 2022
This API uses both composition and inheritance to provide a generic way to set up a custom server with a custom communication protocol and custom middlewares

Ziapi Summary Introduction Installation Introduction This API uses both composition and inheritance to provide a generic way to set up a custom server

Aurélien Boch 8 Apr 22, 2022
HTTP and WebSocket built on Boost.Asio in C++11

HTTP and WebSocket built on Boost.Asio in C++11 Branch Linux/OSX Windows Coverage Documentation Matrix master develop Contents Introduction Appearance

Boost.org 3.5k Aug 10, 2022
Asynchronous gRPC with Boost.Asio executors

asio-grpc This library provides an implementation of boost::asio::execution_context that dispatches work to a grpc::CompletionQueue. Making it possibl

Dennis 138 Aug 8, 2022
Boost headers

About This repository contains a set of header files from Boost. Can be useful when using header only libraries. How to use You can easily include the

null 2 Oct 16, 2021
Boost.org signals2 module

Signals2, part of collection of the Boost C++ Libraries, is an implementation of a managed signals and slots system. License Distributed under the Boo

Boost.org 50 Aug 2, 2022
Boost.org property_tree module

Maintainer This library is currently maintained by Richard Hodges with generous support from the C++ Alliance. Build Status Branch Status develop mast

Boost.org 35 Jan 24, 2022
Boost::ASIO low-level redis client (connector)

bredis Boost::ASIO low-level redis client (connector), github gitee Features header only zero-copy (currently only for received replies from Redis) lo

Ivan Baidakou 142 Jul 21, 2022
Super-project for modularized Boost

Boost C++ Libraries The Boost project provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work well with the C++ St

Boost.org 5k Aug 3, 2022
Level up your Beat Saber experience on Quest! AnyTweaks provides various tweaks to help boost your experience on Quest, such as Bloom, FPS Counter and more.

Need help/support? Ask in one of BSMG's support channels for Quest, or join my Discord server! AnyTweaks Level up your Beat Saber experience on Quest!

kaitlyn~ 14 Jul 28, 2022
Accelerated Container Image

OverlayBD Accelerated Container Image Accelerated Container Image is an open-source implementation of paper "DADI: Block-Level Image Service for Agile

Alibaba 122 Jul 27, 2022
docker-nginx-with-image-filter

docker-nginx-with-image-filter 因为官方镜像默认没有启用该模块,故自己做了一个Dockerfile,并编译,docker镜像地址: docker pull smally84/nginx-with-image-filter:1.20.1 附上Dockerfile ###

null 2 Dec 11, 2021
Un petit client/serveur TCP pour transférer d'image en C

MIMAGE Project Guide de démarage Prérequis Être sur un environement Linux et avoir le compilateur GCC et makefile d'installé. Installation Pour build

MrSolarius 4 Dec 21, 2021
A Linux reference software for building the Demo Core-Image on Renesas RZ/V2M Evaluation Kit

Introduction This repository is a Linux reference software for building the Demo Core-Image on Renesas RZ/V2M Evaluation Kit . You have to get the pro

Lexra Chang 3 Jan 20, 2022