]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/example/histogram.cpp
2 Copyright 2005-2007 Adobe Systems Incorporated
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
8 See http://opensource.adobe.com/gil for most recent version including documentation.
11 /*************************************************************************************************/
14 /// \brief Example file to demonstrate a way to compute histogram
15 /// \author Lubomir Bourdev and Hailin Jin
16 /// \date February 27, 2007
20 #include <boost/gil/image.hpp>
21 #include <boost/gil/typedefs.hpp>
22 #include <boost/gil/color_convert.hpp>
23 #include <boost/gil/extension/io/jpeg_io.hpp>
25 using namespace boost::gil
;
27 template <typename GrayView
, typename R
>
28 void gray_image_hist(const GrayView
& img_view
, R
& hist
) {
29 // for_each_pixel(img_view,++lambda::var(hist)[lambda::_1]);
30 for (typename
GrayView::iterator it
=img_view
.begin(); it
!=img_view
.end(); ++it
)
34 template <typename V
, typename R
>
35 void get_hist(const V
& img_view
, R
& hist
) {
36 gray_image_hist(color_converted_view
<gray8_pixel_t
>(img_view
), hist
);
41 jpeg_read_image("test.jpg",img
);
44 std::fill(histogram
,histogram
+256,0);
45 get_hist(const_view(img
),histogram
);
47 std::fstream
histo_file("out-histogram.txt",std::ios::out
);
48 for(std::size_t ii
=0;ii
<256;++ii
)
49 histo_file
<< histogram
[ii
] << std::endl
;