2
0
mirror of https://github.com/boostorg/gil.git synced 2026-01-24 18:02:17 +00:00
Files
gil/test/core/histogram/cumulative.cpp
Debabrata Mandal 3e729e5dae Add histogram class and related functionality (#499)
A new histogram class proposed with close suport for gil
image constructs.

Shift the stl support implmentation to extension to
serve as example for overloading fill_histogram.

Add cumulative histogram and histogram normalization.

Co-authored-by: debabrata1 <debabrata@goodhealthapp.com>
2021-01-24 00:02:51 +01:00

55 lines
1.1 KiB
C++

//
// Copyright 2020 Debabrata Mandal <mandaldebabrata123@gmail.com>
//
// Distributed under 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/histogram.hpp>
#include <boost/core/lightweight_test.hpp>
namespace gil = boost::gil;
void check_cumulative()
{
gil::histogram<int> h1;
for (int i = 0; i < 8; i++)
{
h1(i) = 1;
}
auto h2 = cumulative_histogram(h1);
bool check1 = true;
for (int i = 0; i < 8; i++)
{
if(h2(i) != i+1)
check1 = false;
}
BOOST_TEST(check1);
gil::histogram<int , int> h3;
h3(1, 3) = 1;
h3(1, 4) = 2;
h3(2, 1) = 3;
h3(2, 2) = 1;
h3(2, 5) = 2;
h3(3, 2) = 3;
h3(3, 9) = 1;
auto h4 = cumulative_histogram(h3);
BOOST_TEST(h4(1, 3) == 1);
BOOST_TEST(h4(1, 4) == 3);
BOOST_TEST(h4(2, 1) == 3);
BOOST_TEST(h4(2, 2) == 4);
BOOST_TEST(h4(2, 5) == 9);
BOOST_TEST(h4(3, 2) == 7);
BOOST_TEST(h4(3, 9) == 13);
}
int main() {
check_cumulative();
return boost::report_errors();
}