forked from boostorg/gil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
173 additions
and
7 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
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
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
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,37 @@ | ||
// | ||
// 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/image_processing/threshold.hpp> | ||
#include <boost/gil/image_view.hpp> | ||
#include <boost/gil/algorithm.hpp> | ||
#include <boost/gil/gray.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
|
||
|
||
namespace gil = boost::gil; | ||
|
||
int main() | ||
{ | ||
int height = 2; | ||
int width = 2; | ||
gil::rgb8_image_t original(width, height), otsu(width, height), expected(width, height); | ||
|
||
gil::view(original)(0, 0) = gil::rgb8_pixel_t(15, 158, 150); | ||
gil::view(original)(1, 0) = gil::rgb8_pixel_t(200, 175, 150); | ||
gil::view(original)(0, 1) = gil::rgb8_pixel_t(230, 170, 150); | ||
gil::view(original)(1, 1) = gil::rgb8_pixel_t(25, 248, 150); | ||
|
||
gil::view(expected)(0, 0) = gil::rgb8_pixel_t(0, 0, 255); | ||
gil::view(expected)(1, 0) = gil::rgb8_pixel_t(255, 255, 255); | ||
gil::view(expected)(0, 1) = gil::rgb8_pixel_t(255, 0, 255); | ||
gil::view(expected)(1, 1) = gil::rgb8_pixel_t(255, 255, 255); | ||
|
||
gil::threshold_optimal(gil::view(original), gil::view(otsu), gil::threshold_optimal_value::otsu); | ||
|
||
BOOST_TEST(gil::equal_pixels(gil::view(otsu), gil::view(expected))); | ||
return boost::report_errors(); | ||
} |