-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mean adaptive threshold implemeted with example
closes #315
- Loading branch information
1 parent
d86e4a4
commit 7c0f386
Showing
3 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/png.hpp> | ||
#include <boost/gil/image_processing/threshold.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; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters