mirror of
https://github.com/boostorg/gil.git
synced 2026-01-22 05:12:30 +00:00
A typical user is supposed to include the main header and to not know the library enough to include headers selectively.
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
//
|
|
// 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>
|
|
|
|
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());
|
|
|
|
// 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_adaptive(const_view(img), view(img_out), 11);
|
|
write_view("out-threshold-adaptive.png", view(img_out), png_tag{});
|
|
|
|
// if the pixel value is more than 150 than it will be set to 150 else no change
|
|
boost::gil::threshold_adaptive(const_view(img), view(img_out), 11, threshold_adaptive_method::mean, threshold_direction::inverse);
|
|
write_view("out-threshold-adaptive-inv.png", view(img_out), png_tag{});
|
|
|
|
return 0;
|
|
}
|