add boost on mac
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/color_converters/gray_to_rgba.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_converters/rgb_to_luminance.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_GRAY_TO_RGBA_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_GRAY_TO_RGBA_HPP
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// This one is missing in gil ( color_convert.hpp ).
|
||||
template <>
|
||||
struct default_color_converter_impl<gray_t,rgba_t>
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const
|
||||
{
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type<P2, red_t >::type>(get_color(src,gray_color_t()));
|
||||
get_color(dst,green_t())=
|
||||
channel_convert<typename color_element_type<P2, green_t>::type>(get_color(src,gray_color_t()));
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type<P2, blue_t >::type>(get_color(src,gray_color_t()));
|
||||
|
||||
using channel_t = typename channel_type<P2>::type;
|
||||
get_color(dst,alpha_t()) = channel_traits< channel_t >::max_value();
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_RGB_TO_LUMINANCE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_RGB_TO_LUMINANCE_HPP
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
|
||||
namespace boost{ namespace gil { namespace detail {
|
||||
|
||||
/// - performance specialization double
|
||||
/// - to eliminate compiler warning 4244
|
||||
template <typename GrayChannelValue>
|
||||
struct rgb_to_luminance_fn< double, double, double, GrayChannelValue >
|
||||
{
|
||||
GrayChannelValue operator()( const double& red
|
||||
, const double& green
|
||||
, const double& blue ) const
|
||||
{
|
||||
return channel_convert<GrayChannelValue>( red * 0.30 + green * 0.59 + blue * 0.11 );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
18
macx64/include/boost/gil/extension/toolbox/color_spaces.hpp
Normal file
18
macx64/include/boost/gil/extension/toolbox/color_spaces.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/color_spaces/cmyka.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/gray_alpha.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/hsl.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/hsv.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/lab.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/xyz.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
|
||||
|
||||
#include <boost/gil/cmyk.hpp>
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil/rgba.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using cmyka_t = mpl::vector5<cyan_t, magenta_t, yellow_t, black_t, alpha_t>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using cmyka_layout_t = layout<cmyka_t>;
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyka)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyka)
|
||||
|
||||
///// \ingroup ColorConvert
|
||||
///// \brief Converting CMYKA to any pixel type. Note: Supports homogeneous pixels only.
|
||||
//template <typename C2>
|
||||
//struct default_color_converter_impl<cmyka_t,C2> {
|
||||
// template <typename P1, typename P2>
|
||||
// void operator()(const P1& src, P2& dst) const {
|
||||
// using T1 = typename channel_type<P1>::type;
|
||||
// default_color_converter_impl<cmyk_t,C2>()(
|
||||
// pixel<T1,cmyk_layout_t>(channel_multiply(get_color(src,cyan_t()), get_color(src,alpha_t())),
|
||||
// channel_multiply(get_color(src,magenta_t()),get_color(src,alpha_t())),
|
||||
// channel_multiply(get_color(src,yellow_t()), get_color(src,alpha_t())),
|
||||
// channel_multiply(get_color(src,black_t()), get_color(src,alpha_t())))
|
||||
// ,dst);
|
||||
// }
|
||||
//};
|
||||
template <>
|
||||
struct default_color_converter_impl<cmyka_t,rgba_t> {
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const {
|
||||
using T1 = typename channel_type<P1>::type;
|
||||
default_color_converter_impl<cmyk_t,rgba_t>()(
|
||||
pixel<T1,cmyk_layout_t>(get_color(src,cyan_t()),
|
||||
get_color(src,magenta_t()),
|
||||
get_color(src,yellow_t()),
|
||||
get_color(src,black_t()))
|
||||
,dst);
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief Unfortunately CMYKA to CMYKA must be explicitly provided - otherwise we get ambiguous specialization error.
|
||||
template <>
|
||||
struct default_color_converter_impl<cmyka_t,cmyka_t> {
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const {
|
||||
static_for_each(src,dst,default_channel_converter());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// Copyright 2012 Andreas Pokorny
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_GRAY_ALPHA_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_GRAY_ALPHA_HPP
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil/gray.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
|
||||
#include <boost/mpl/contains.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
using gray_alpha_t = mpl::vector2<gray_color_t,alpha_t>;
|
||||
|
||||
using gray_alpha_layout_t = layout<gray_alpha_t>;
|
||||
using alpha_gray_layout_t = layout<gray_alpha_layout_t, mpl::vector2_c<int,1,0>>;
|
||||
|
||||
GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, alpha_gray)
|
||||
GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, alpha_gray)
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, gray_alpha)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, gray_alpha)
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief Gray Alpha to RGBA
|
||||
template <>
|
||||
struct default_color_converter_impl<gray_alpha_t,rgba_t> {
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const {
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type<P2, red_t>::type>(get_color(src,gray_color_t()));
|
||||
get_color(dst,green_t())=
|
||||
channel_convert<typename color_element_type<P2, green_t>::type>(get_color(src,gray_color_t()));
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type<P2, blue_t>::type>(get_color(src,gray_color_t()));
|
||||
get_color(dst,alpha_t()) =
|
||||
channel_convert<typename color_element_type<P2, alpha_t>::type>(get_color(src,alpha_t()));
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Gray Alpha to RGB
|
||||
template <>
|
||||
struct default_color_converter_impl<gray_alpha_t,rgb_t> {
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const {
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type<P2, red_t>::type>(
|
||||
channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
|
||||
);
|
||||
get_color(dst,green_t()) =
|
||||
channel_convert<typename color_element_type<P2, green_t>::type>(
|
||||
channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
|
||||
);
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type<P2, blue_t>::type>(
|
||||
channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Gray Alpha to Gray
|
||||
template <>
|
||||
struct default_color_converter_impl<gray_alpha_t,gray_t> {
|
||||
template <typename P1, typename P2>
|
||||
void operator()(const P1& src, P2& dst) const {
|
||||
get_color(dst,gray_color_t()) =
|
||||
channel_convert<typename color_element_type<P2, gray_color_t>::type>(
|
||||
channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
260
macx64/include/boost/gil/extension/toolbox/color_spaces/hsl.hpp
Normal file
260
macx64/include/boost/gil/extension/toolbox/color_spaces/hsl.hpp
Normal file
@@ -0,0 +1,260 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HSL_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HSL_HPP
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \addtogroup ColorNameModel
|
||||
/// \{
|
||||
namespace hsl_color_space
|
||||
{
|
||||
/// \brief Hue
|
||||
struct hue_t {};
|
||||
/// \brief Saturation
|
||||
struct saturation_t {};
|
||||
/// \brief Lightness
|
||||
struct lightness_t {};
|
||||
}
|
||||
/// \}
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using hsl_t = mpl::vector3
|
||||
<
|
||||
hsl_color_space::hue_t,
|
||||
hsl_color_space::saturation_t,
|
||||
hsl_color_space::lightness_t
|
||||
>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using hsl_layout_t = layout<hsl_t>;
|
||||
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, hsl)
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief RGB to HSL
|
||||
template <>
|
||||
struct default_color_converter_impl< rgb_t, hsl_t >
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace hsl_color_space;
|
||||
|
||||
// only float32_t for hsl is supported
|
||||
float32_t temp_red = channel_convert<float32_t>( get_color( src, red_t() ));
|
||||
float32_t temp_green = channel_convert<float32_t>( get_color( src, green_t() ));
|
||||
float32_t temp_blue = channel_convert<float32_t>( get_color( src, blue_t() ));
|
||||
|
||||
float32_t hue, saturation, lightness;
|
||||
|
||||
float32_t min_color = (std::min)( temp_red, (std::min)( temp_green, temp_blue ));
|
||||
float32_t max_color = (std::max)( temp_red, (std::max)( temp_green, temp_blue ));
|
||||
|
||||
if( std::abs( min_color - max_color ) < 0.001 )
|
||||
{
|
||||
// rgb color is gray
|
||||
|
||||
hue = 0.f;
|
||||
saturation = 0.f;
|
||||
|
||||
// doesn't matter which rgb channel we use.
|
||||
lightness = temp_red;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
float32_t diff = max_color - min_color;
|
||||
|
||||
// lightness calculation
|
||||
|
||||
lightness = ( min_color + max_color ) / 2.f;
|
||||
|
||||
// saturation calculation
|
||||
|
||||
if( lightness < 0.5f )
|
||||
{
|
||||
saturation = diff
|
||||
/ ( min_color + max_color );
|
||||
}
|
||||
else
|
||||
{
|
||||
saturation = ( max_color - min_color )
|
||||
/ ( 2.f - diff );
|
||||
|
||||
}
|
||||
|
||||
// hue calculation
|
||||
if( std::abs( max_color - temp_red ) < 0.0001f )
|
||||
{
|
||||
// max_color is red
|
||||
hue = ( temp_green - temp_blue )
|
||||
/ diff;
|
||||
|
||||
}
|
||||
else if( std::abs( max_color - temp_green) < 0.0001f )
|
||||
{
|
||||
// max_color is green
|
||||
// 2.0 + (b - r) / (maxColor - minColor);
|
||||
hue = 2.f
|
||||
+ ( temp_blue - temp_red )
|
||||
/ diff;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// max_color is blue
|
||||
hue = 4.f
|
||||
+ ( temp_red - temp_blue )
|
||||
/ diff;
|
||||
}
|
||||
|
||||
hue /= 6.f;
|
||||
|
||||
if( hue < 0.f )
|
||||
{
|
||||
hue += 1.f;
|
||||
}
|
||||
}
|
||||
|
||||
get_color( dst,hue_t() ) = hue;
|
||||
get_color( dst,saturation_t() ) = saturation;
|
||||
get_color( dst,lightness_t() ) = lightness;
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief HSL to RGB
|
||||
template <>
|
||||
struct default_color_converter_impl<hsl_t,rgb_t>
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst) const
|
||||
{
|
||||
using namespace hsl_color_space;
|
||||
|
||||
float32_t red, green, blue;
|
||||
|
||||
if( std::abs( get_color( src, saturation_t() )) < 0.0001 )
|
||||
{
|
||||
// If saturation is 0, the color is a shade of gray
|
||||
red = get_color( src, lightness_t() );
|
||||
green = get_color( src, lightness_t() );
|
||||
blue = get_color( src, lightness_t() );
|
||||
}
|
||||
else
|
||||
{
|
||||
float temp1, temp2;
|
||||
float tempr, tempg, tempb;
|
||||
|
||||
//Set the temporary values
|
||||
if( get_color( src, lightness_t() ) < 0.5 )
|
||||
{
|
||||
temp2 = get_color( src, lightness_t() )
|
||||
* ( 1.f + get_color( src, saturation_t() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
temp2 = ( get_color( src, lightness_t() ) + get_color( src, saturation_t() ))
|
||||
- ( get_color( src, lightness_t() ) * get_color( src, saturation_t() ));
|
||||
}
|
||||
|
||||
temp1 = 2.f
|
||||
* get_color( src, lightness_t() )
|
||||
- temp2;
|
||||
|
||||
tempr = get_color( src, hue_t() ) + 1.f / 3.f;
|
||||
|
||||
if( tempr > 1.f )
|
||||
{
|
||||
tempr--;
|
||||
}
|
||||
|
||||
tempg = get_color( src, hue_t() );
|
||||
tempb = get_color( src, hue_t() ) - 1.f / 3.f;
|
||||
|
||||
if( tempb < 0.f )
|
||||
{
|
||||
tempb++;
|
||||
}
|
||||
|
||||
//Red
|
||||
if( tempr < 1.f / 6.f )
|
||||
{
|
||||
red = temp1 + ( temp2 - temp1 ) * 6.f * tempr;
|
||||
}
|
||||
else if( tempr < 0.5f )
|
||||
{
|
||||
red = temp2;
|
||||
}
|
||||
else if( tempr < 2.f / 3.f )
|
||||
{
|
||||
red = temp1 + (temp2 - temp1)
|
||||
* (( 2.f / 3.f ) - tempr) * 6.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
red = temp1;
|
||||
}
|
||||
|
||||
//Green
|
||||
if( tempg < 1.f / 6.f )
|
||||
{
|
||||
green = temp1 + ( temp2 - temp1 ) * 6.f * tempg;
|
||||
}
|
||||
else if( tempg < 0.5f )
|
||||
{
|
||||
green = temp2;
|
||||
}
|
||||
else if( tempg < 2.f / 3.f )
|
||||
{
|
||||
green = temp1 + ( temp2 - temp1 )
|
||||
* (( 2.f / 3.f ) - tempg) * 6.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
green = temp1;
|
||||
}
|
||||
|
||||
//Blue
|
||||
if( tempb < 1.f / 6.f )
|
||||
{
|
||||
blue = temp1 + (temp2 - temp1) * 6.f * tempb;
|
||||
}
|
||||
else if( tempb < 0.5f )
|
||||
{
|
||||
blue = temp2;
|
||||
}
|
||||
else if( tempb < 2.f / 3.f )
|
||||
{
|
||||
blue = temp1 + (temp2 - temp1)
|
||||
* (( 2.f / 3.f ) - tempb) * 6.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
blue = temp1;
|
||||
}
|
||||
}
|
||||
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type< P2, red_t >::type>( red );
|
||||
get_color(dst,green_t())=
|
||||
channel_convert<typename color_element_type< P2, green_t >::type>( green );
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type< P2, blue_t >::type>( blue );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
234
macx64/include/boost/gil/extension/toolbox/color_spaces/hsv.hpp
Normal file
234
macx64/include/boost/gil/extension/toolbox/color_spaces/hsv.hpp
Normal file
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HSV_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_HSV_HPP
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \addtogroup ColorNameModel
|
||||
/// \{
|
||||
namespace hsv_color_space
|
||||
{
|
||||
/// \brief Hue
|
||||
struct hue_t {};
|
||||
/// \brief Saturation
|
||||
struct saturation_t{};
|
||||
/// \brief Value
|
||||
struct value_t {};
|
||||
}
|
||||
/// \}
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using hsv_t = mpl::vector3
|
||||
<
|
||||
hsv_color_space::hue_t,
|
||||
hsv_color_space::saturation_t,
|
||||
hsv_color_space::value_t
|
||||
>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using hsv_layout_t = layout<hsv_t>;
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, hsv)
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief RGB to HSV
|
||||
template <>
|
||||
struct default_color_converter_impl< rgb_t, hsv_t >
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace hsv_color_space;
|
||||
|
||||
// only float32_t for hsv is supported
|
||||
float32_t temp_red = channel_convert<float32_t>( get_color( src, red_t() ));
|
||||
float32_t temp_green = channel_convert<float32_t>( get_color( src, green_t() ));
|
||||
float32_t temp_blue = channel_convert<float32_t>( get_color( src, blue_t() ));
|
||||
|
||||
float32_t hue, saturation, value;
|
||||
|
||||
float32_t min_color = (std::min)( temp_red, (std::min)( temp_green, temp_blue ));
|
||||
float32_t max_color = (std::max)( temp_red, (std::max)( temp_green, temp_blue ));
|
||||
|
||||
value = max_color;
|
||||
|
||||
float32_t diff = max_color - min_color;
|
||||
|
||||
if( max_color < 0.0001f )
|
||||
{
|
||||
saturation = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
saturation = diff / max_color;
|
||||
}
|
||||
|
||||
|
||||
if( saturation < 0.0001f )
|
||||
{
|
||||
//it doesn't matter what value it has
|
||||
hue = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( (std::abs)( boost::numeric_cast<float32_t>(temp_red - max_color) ) < 0.0001f )
|
||||
{
|
||||
hue = ( temp_green - temp_blue )
|
||||
/ diff;
|
||||
}
|
||||
else if( temp_green >= max_color ) // means == but >= avoids compiler warning; color is never greater than max
|
||||
{
|
||||
hue = 2.f + ( temp_blue - temp_red )
|
||||
/ diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
hue = 4.f + ( temp_red - temp_green )
|
||||
/ diff;
|
||||
}
|
||||
|
||||
//to bring it to a number between 0 and 1
|
||||
hue /= 6.f;
|
||||
|
||||
if( hue < 0.f )
|
||||
{
|
||||
hue++;
|
||||
}
|
||||
}
|
||||
|
||||
get_color( dst, hue_t() ) = hue;
|
||||
get_color( dst, saturation_t() ) = saturation;
|
||||
get_color( dst, value_t() ) = value;
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief HSV to RGB
|
||||
template <>
|
||||
struct default_color_converter_impl<hsv_t,rgb_t>
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst) const
|
||||
{
|
||||
using namespace hsv_color_space;
|
||||
|
||||
float32_t red, green, blue;
|
||||
|
||||
//If saturation is 0, the color is a shade of gray
|
||||
if( abs( get_color( src, saturation_t() )) < 0.0001f )
|
||||
{
|
||||
// If saturation is 0, the color is a shade of gray
|
||||
red = get_color( src, value_t() );
|
||||
green = get_color( src, value_t() );
|
||||
blue = get_color( src, value_t() );
|
||||
}
|
||||
else
|
||||
{
|
||||
float32_t frac, p, q, t, h;
|
||||
uint32_t i;
|
||||
|
||||
//to bring hue to a number between 0 and 6, better for the calculations
|
||||
h = get_color( src, hue_t() );
|
||||
h *= 6.f;
|
||||
|
||||
i = static_cast<uint32_t>(floor(h));
|
||||
|
||||
frac = h - i;
|
||||
|
||||
p = get_color( src, value_t() )
|
||||
* ( 1.f - get_color( src, saturation_t() ));
|
||||
|
||||
q = get_color( src, value_t() )
|
||||
* ( 1.f - ( get_color( src, saturation_t() ) * frac ));
|
||||
|
||||
t = get_color( src, value_t() )
|
||||
* ( 1.f - ( get_color( src, saturation_t() ) * ( 1.f - frac )));
|
||||
|
||||
switch( i )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
red = get_color( src, value_t() );
|
||||
green = t;
|
||||
blue = p;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
red = q;
|
||||
green = get_color( src, value_t() );
|
||||
blue = p;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
red = p;
|
||||
green = get_color( src, value_t() );
|
||||
blue = t;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
red = p;
|
||||
green = q;
|
||||
blue = get_color( src, value_t() );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
red = t;
|
||||
green = p;
|
||||
blue = get_color( src, value_t() );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 5:
|
||||
{
|
||||
red = get_color( src, value_t() );
|
||||
green = p;
|
||||
blue = q;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type< P2, red_t >::type>( red );
|
||||
get_color(dst,green_t())=
|
||||
channel_convert<typename color_element_type< P2, green_t >::type>( green );
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type< P2, blue_t >::type>( blue );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
173
macx64/include/boost/gil/extension/toolbox/color_spaces/lab.hpp
Normal file
173
macx64/include/boost/gil/extension/toolbox/color_spaces/lab.hpp
Normal file
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// Copyright 2012 Chung-Lin Wen
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_LAB_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_LAB_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/color_spaces/xyz.hpp>
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil.hpp> // FIXME: Include what you use, not everything, even in extensions!
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \addtogroup ColorNameModel
|
||||
/// \{
|
||||
namespace lab_color_space
|
||||
{
|
||||
/// \brief Luminance
|
||||
struct luminance_t {};
|
||||
/// \brief a Color Component
|
||||
struct a_color_opponent_t {};
|
||||
/// \brief b Color Component
|
||||
struct b_color_opponent_t {};
|
||||
}
|
||||
/// \}
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using lab_t = mpl::vector3
|
||||
<
|
||||
lab_color_space::luminance_t,
|
||||
lab_color_space::a_color_opponent_t,
|
||||
lab_color_space::b_color_opponent_t
|
||||
>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using lab_layout_t = layout<lab_t>;
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, lab)
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief LAB to XYZ
|
||||
template <>
|
||||
struct default_color_converter_impl< lab_t, xyz_t >
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace lab_color_space;
|
||||
using namespace xyz_color_space;
|
||||
|
||||
float32_t p = ((get_color(src, luminance_t()) + 16.f)/116.f);
|
||||
|
||||
get_color(dst, y_t()) =
|
||||
1.f * powf(p, 3.f);
|
||||
|
||||
get_color(dst, x_t()) =
|
||||
0.95047f * powf((p +
|
||||
(get_color(src, a_color_opponent_t())/500.f)
|
||||
), 3.f);
|
||||
get_color(dst, z_t()) =
|
||||
1.08883f * powf((p -
|
||||
(get_color(src, b_color_opponent_t())/200.f)
|
||||
), 3.f);
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief XYZ to LAB
|
||||
/// \note I assume \c xyz_t
|
||||
template <>
|
||||
struct default_color_converter_impl< xyz_t, lab_t >
|
||||
{
|
||||
private:
|
||||
/// \ref http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_Lab.html
|
||||
BOOST_FORCEINLINE
|
||||
float32_t forward_companding(float32_t value) const
|
||||
{
|
||||
if (value > 216.f/24389.f)
|
||||
{
|
||||
return powf(value, 1.f/3.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((24389.f/27.f * value + 16.f)/116.f);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace lab_color_space;
|
||||
|
||||
float32_t f_y =
|
||||
forward_companding(
|
||||
channel_convert<float32_t>(
|
||||
get_color(src, xyz_color_space::y_t())
|
||||
)
|
||||
// / 1.f
|
||||
);
|
||||
|
||||
float32_t f_x =
|
||||
forward_companding(
|
||||
channel_convert<float32_t>(
|
||||
get_color(src, xyz_color_space::x_t())
|
||||
)
|
||||
* (1.f / 0.95047f) // if the compiler is smart, it should
|
||||
// precalculate this, no?
|
||||
);
|
||||
|
||||
float32_t f_z =
|
||||
forward_companding(
|
||||
channel_convert<float32_t>(
|
||||
get_color(src, xyz_color_space::z_t())
|
||||
)
|
||||
* (1.f / 1.08883f) // if the compiler is smart, it should
|
||||
// precalculate this, no?
|
||||
);
|
||||
|
||||
get_color(dst, luminance_t()) =
|
||||
116.f * f_y - 16.f;
|
||||
|
||||
get_color(dst, a_color_opponent_t()) =
|
||||
500.f * (f_x - f_y);
|
||||
|
||||
get_color(dst, b_color_opponent_t()) =
|
||||
200.f * (f_y - f_z);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief RGB to LAB
|
||||
template <>
|
||||
struct default_color_converter_impl< rgb_t, lab_t >
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace lab_color_space;
|
||||
|
||||
xyz32f_pixel_t xyz32f_temp_pixel;
|
||||
default_color_converter_impl<rgb_t, xyz_t>()(src, xyz32f_temp_pixel);
|
||||
default_color_converter_impl<xyz_t, lab_t>()(xyz32f_temp_pixel, dst);
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief LAB to RGB
|
||||
template <>
|
||||
struct default_color_converter_impl<lab_t,rgb_t>
|
||||
{
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst) const
|
||||
{
|
||||
using namespace lab_color_space;
|
||||
|
||||
xyz32f_pixel_t xyz32f_temp_pixel;
|
||||
default_color_converter_impl<lab_t, xyz_t>()(src, xyz32f_temp_pixel);
|
||||
default_color_converter_impl<xyz_t, rgb_t>()(xyz32f_temp_pixel, dst);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
151
macx64/include/boost/gil/extension/toolbox/color_spaces/xyz.hpp
Normal file
151
macx64/include/boost/gil/extension/toolbox/color_spaces/xyz.hpp
Normal file
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// Copyright 2012 Chung-Lin Wen, Davide Anastasia
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_XYZ_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_XYZ_HPP
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil/typedefs.hpp>
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \addtogroup ColorNameModel
|
||||
/// \{
|
||||
namespace xyz_color_space
|
||||
{
|
||||
/// \brief x Color Component
|
||||
struct x_t {};
|
||||
/// \brief y Color Component
|
||||
struct y_t {};
|
||||
/// \brief z Color Component
|
||||
struct z_t {};
|
||||
}
|
||||
/// \}
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using xyz_t = mpl::vector3
|
||||
<
|
||||
xyz_color_space::x_t,
|
||||
xyz_color_space::y_t,
|
||||
xyz_color_space::z_t
|
||||
>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using xyz_layout_t = layout<xyz_t>;
|
||||
|
||||
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, xyz)
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief RGB to XYZ
|
||||
/// <a href="http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html">Link</a>
|
||||
/// \note rgb_t is assumed to be sRGB D65
|
||||
template <>
|
||||
struct default_color_converter_impl< rgb_t, xyz_t >
|
||||
{
|
||||
private:
|
||||
BOOST_FORCEINLINE
|
||||
float32_t inverse_companding(float32_t sample) const
|
||||
{
|
||||
if ( sample > 0.04045f )
|
||||
{
|
||||
return powf((( sample + 0.055f ) / 1.055f ), 2.4f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( sample / 12.92f );
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst ) const
|
||||
{
|
||||
using namespace xyz_color_space;
|
||||
|
||||
float32_t red(
|
||||
inverse_companding(
|
||||
channel_convert<float32_t>(get_color(src, red_t()))));
|
||||
float32_t green(
|
||||
inverse_companding(
|
||||
channel_convert<float32_t>(get_color(src, green_t()))));
|
||||
float32_t blue(
|
||||
inverse_companding(
|
||||
channel_convert<float32_t>(get_color(src, blue_t()))));
|
||||
|
||||
get_color( dst, x_t() ) =
|
||||
red * 0.4124564f +
|
||||
green * 0.3575761f +
|
||||
blue * 0.1804375f;
|
||||
get_color( dst, y_t() ) =
|
||||
red * 0.2126729f +
|
||||
green * 0.7151522f +
|
||||
blue * 0.0721750f;
|
||||
get_color( dst, z_t() ) =
|
||||
red * 0.0193339f +
|
||||
green * 0.1191920f +
|
||||
blue * 0.9503041f;
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ColorConvert
|
||||
/// \brief XYZ to RGB
|
||||
template <>
|
||||
struct default_color_converter_impl<xyz_t,rgb_t>
|
||||
{
|
||||
private:
|
||||
BOOST_FORCEINLINE
|
||||
float32_t companding(float32_t sample) const
|
||||
{
|
||||
if ( sample > 0.0031308f )
|
||||
{
|
||||
return ( 1.055f * powf( sample, 1.f/2.4f ) - 0.055f );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( 12.92f * sample );
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename P1, typename P2>
|
||||
void operator()( const P1& src, P2& dst) const
|
||||
{
|
||||
using namespace xyz_color_space;
|
||||
|
||||
// Note: ideally channel_convert should be compiled out, because xyz_t
|
||||
// is float32_t natively only
|
||||
float32_t x( channel_convert<float32_t>( get_color( src, x_t() ) ) );
|
||||
float32_t y( channel_convert<float32_t>( get_color( src, y_t() ) ) );
|
||||
float32_t z( channel_convert<float32_t>( get_color( src, z_t() ) ) );
|
||||
|
||||
get_color(dst,red_t()) =
|
||||
channel_convert<typename color_element_type<P2, red_t>::type>(
|
||||
companding( x * 3.2404542f +
|
||||
y * -1.5371385f +
|
||||
z * -0.4985314f )
|
||||
);
|
||||
get_color(dst,green_t()) =
|
||||
channel_convert<typename color_element_type<P2, green_t>::type>(
|
||||
companding( x * -0.9692660f +
|
||||
y * 1.8760108f +
|
||||
z * 0.0415560f )
|
||||
);
|
||||
get_color(dst,blue_t()) =
|
||||
channel_convert<typename color_element_type<P2, blue_t>::type>(
|
||||
companding( x * 0.0556434f +
|
||||
y * -0.2040259f +
|
||||
z * 1.0572252f )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_XYZ_HPP
|
||||
@@ -0,0 +1,266 @@
|
||||
//
|
||||
// Copyright 2013 Juan V. Puertos G-Cluster, Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_YCBCR_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_YCBCR_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
|
||||
|
||||
#include <boost/gil/color_convert.hpp>
|
||||
#include <boost/gil.hpp> // FIXME: Include what you use!
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// \addtogroup ColorNameModel
|
||||
/// \{
|
||||
namespace ycbcr_601_color_space
|
||||
{
|
||||
/// \brief Luminance
|
||||
struct y_t {};
|
||||
/// \brief Blue chrominance component
|
||||
struct cb_t {};
|
||||
/// \brief Red chrominance component
|
||||
struct cr_t {};
|
||||
}
|
||||
|
||||
namespace ycbcr_709_color_space
|
||||
{
|
||||
/// \brief Luminance
|
||||
struct y_t {};
|
||||
/// \brief Blue chrominance component
|
||||
struct cb_t {};
|
||||
/// \brief Red chrominance component
|
||||
struct cr_t {};
|
||||
}
|
||||
/// \}
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using ycbcr_601__t = boost::mpl::vector3
|
||||
<
|
||||
ycbcr_601_color_space::y_t,
|
||||
ycbcr_601_color_space::cb_t,
|
||||
ycbcr_601_color_space::cr_t>
|
||||
;
|
||||
|
||||
/// \ingroup ColorSpaceModel
|
||||
using ycbcr_709__t = boost::mpl::vector3
|
||||
<
|
||||
ycbcr_709_color_space::y_t,
|
||||
ycbcr_709_color_space::cb_t,
|
||||
ycbcr_709_color_space::cr_t
|
||||
>;
|
||||
|
||||
/// \ingroup LayoutModel
|
||||
using ycbcr_601__layout_t = boost::gil::layout<ycbcr_601__t>;
|
||||
using ycbcr_709__layout_t = boost::gil::layout<ycbcr_709__t>;
|
||||
|
||||
//The channel depth is ALWAYS 8bits ofr YCbCr!
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, ycbcr_601_)
|
||||
GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, ycbcr_709_)
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Source:boost/algorithm/clamp.hpp
|
||||
template<typename T>
|
||||
BOOST_CXX14_CONSTEXPR T const& clamp(T const& val,
|
||||
typename boost::mpl::identity<T>::type const & lo,
|
||||
typename boost::mpl::identity<T>::type const & hi)
|
||||
{
|
||||
// assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal
|
||||
auto const p = std::less<T>();
|
||||
return p(val, lo) ? lo : p(hi, val) ? hi : val;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/*
|
||||
* 601 Source: http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion
|
||||
* 709 Source: http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.709_conversion
|
||||
* (using values coming directly from ITU-R BT.601 recommendation)
|
||||
* (using values coming directly from ITU-R BT.709 recommendation)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Convert YCbCr ITU.BT-601 to RGB.
|
||||
*/
|
||||
template<>
|
||||
struct default_color_converter_impl<ycbcr_601__t, rgb_t>
|
||||
{
|
||||
// Note: the RGB_t channels range can be set later on by the users. We dont want to cast to uint8_t or anything here.
|
||||
template < typename SRCP, typename DSTP >
|
||||
void operator()( const SRCP& src, DSTP& dst ) const
|
||||
{
|
||||
using dst_channel_t = typename channel_type<DSTP>::type;
|
||||
convert(src, dst, typename std::is_same
|
||||
<
|
||||
typename mpl::int_<sizeof(dst_channel_t)>::type,
|
||||
typename mpl::int_<1>::type
|
||||
>::type());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// optimization for bit8 channels
|
||||
template< typename Src_Pixel
|
||||
, typename Dst_Pixel
|
||||
>
|
||||
void convert( const Src_Pixel& src
|
||||
, Dst_Pixel& dst
|
||||
, mpl::true_ // is 8 bit channel
|
||||
) const
|
||||
{
|
||||
using namespace ycbcr_601_color_space;
|
||||
|
||||
using src_channel_t = typename channel_type<Src_Pixel>::type;
|
||||
using dst_channel_t = typename channel_type<Dst_Pixel>::type;
|
||||
|
||||
src_channel_t y = channel_convert<src_channel_t>( get_color(src, y_t()));
|
||||
src_channel_t cb = channel_convert<src_channel_t>( get_color(src, cb_t()));
|
||||
src_channel_t cr = channel_convert<src_channel_t>( get_color(src, cr_t()));
|
||||
|
||||
// The intermediate results of the formulas require at least 16bits of precission.
|
||||
std::int_fast16_t c = y - 16;
|
||||
std::int_fast16_t d = cb - 128;
|
||||
std::int_fast16_t e = cr - 128;
|
||||
std::int_fast16_t red = detail::clamp((( 298 * c + 409 * e + 128) >> 8), 0, 255);
|
||||
std::int_fast16_t green = detail::clamp((( 298 * c - 100 * d - 208 * e + 128) >> 8), 0, 255);
|
||||
std::int_fast16_t blue = detail::clamp((( 298 * c + 516 * d + 128) >> 8), 0, 255);
|
||||
|
||||
get_color( dst, red_t() ) = (dst_channel_t) red;
|
||||
get_color( dst, green_t() ) = (dst_channel_t) green;
|
||||
get_color( dst, blue_t() ) = (dst_channel_t) blue;
|
||||
}
|
||||
|
||||
|
||||
template< typename Src_Pixel
|
||||
, typename Dst_Pixel
|
||||
>
|
||||
void convert( const Src_Pixel& src
|
||||
, Dst_Pixel& dst
|
||||
, mpl::false_ // is 8 bit channel
|
||||
) const
|
||||
{
|
||||
using namespace ycbcr_601_color_space;
|
||||
|
||||
using dst_channel_t = typename channel_type<Dst_Pixel>::type;
|
||||
|
||||
double y = get_color( src, y_t() );
|
||||
double cb = get_color( src, cb_t() );
|
||||
double cr = get_color( src, cr_t() );
|
||||
|
||||
get_color(dst, red_t()) = static_cast<dst_channel_t>(
|
||||
detail::clamp(1.6438 * (y - 16.0) + 1.5960 * (cr -128.0), 0.0, 255.0));
|
||||
|
||||
get_color(dst, green_t()) = static_cast<dst_channel_t>(
|
||||
detail::clamp(1.6438 * (y - 16.0) - 0.3917 * (cb - 128.0) + 0.8129 * (cr -128.0), 0.0, 255.0));
|
||||
|
||||
get_color(dst, blue_t()) = static_cast<dst_channel_t>(
|
||||
detail::clamp(1.6438 * ( y - 16.0 ) - 2.0172 * ( cb -128.0 ), 0.0, 255.0));
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Source: http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion
|
||||
* digital Y'CbCr derived from digital R'dG'dB'd 8 bits per sample, each using the full range.
|
||||
* with NO footroom wither headroom.
|
||||
*/
|
||||
/**
|
||||
* @brief Convert RGB to YCbCr ITU.BT-601.
|
||||
*/
|
||||
template<>
|
||||
struct default_color_converter_impl<rgb_t, ycbcr_601__t>
|
||||
{
|
||||
template < typename SRCP, typename DSTP >
|
||||
void operator()( const SRCP& src, DSTP& dst ) const
|
||||
{
|
||||
using namespace ycbcr_601_color_space;
|
||||
|
||||
using src_channel_t = typename channel_type<SRCP>::type;
|
||||
using dst_channel_t = typename channel_type<DSTP>::type;
|
||||
|
||||
src_channel_t red = channel_convert<src_channel_t>( get_color(src, red_t()));
|
||||
src_channel_t green = channel_convert<src_channel_t>( get_color(src, green_t()));
|
||||
src_channel_t blue = channel_convert<src_channel_t>( get_color(src, blue_t()));
|
||||
|
||||
double y = 16.0 + 0.2567 * red + 0.5041 * green + 0.0979 * blue;
|
||||
double cb = 128.0 - 0.1482 * red - 0.2909 * green + 0.4392 * blue;
|
||||
double cr = 128.0 + 0.4392 * red - 0.3677 * green - 0.0714 * blue;
|
||||
|
||||
get_color( dst, y_t() ) = (dst_channel_t) y;
|
||||
get_color( dst, cb_t() ) = (dst_channel_t) cb;
|
||||
get_color( dst, cr_t() ) = (dst_channel_t) cr;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Convert RGB to YCbCr ITU.BT-709.
|
||||
*/
|
||||
template<>
|
||||
struct default_color_converter_impl<rgb_t, ycbcr_709__t>
|
||||
{
|
||||
template < typename SRCP, typename DSTP >
|
||||
void operator()( const SRCP& src, DSTP& dst ) const
|
||||
{
|
||||
using namespace ycbcr_709_color_space;
|
||||
|
||||
using src_channel_t = typename channel_type<SRCP>::type;
|
||||
using dst_channel_t = typename channel_type<DSTP>::type;
|
||||
|
||||
src_channel_t red = channel_convert<src_channel_t>( get_color(src, red_t()));
|
||||
src_channel_t green = channel_convert<src_channel_t>( get_color(src, green_t()));
|
||||
src_channel_t blue = channel_convert<src_channel_t>( get_color(src, blue_t()));
|
||||
|
||||
double y = 0.299 * red + 0.587 * green + 0.114 * blue;
|
||||
double cb = 128.0 - 0.168736 * red - 0.331264 * green + 0.5 * blue;
|
||||
double cr = 128.0 + 0.5 * red - 0.418688 * green - 0.081312 * blue;
|
||||
|
||||
get_color( dst, y_t() ) = (dst_channel_t) y;
|
||||
get_color( dst, cb_t() ) = (dst_channel_t) cb;
|
||||
get_color( dst, cr_t() ) = (dst_channel_t) cr;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Convert RGB to YCbCr ITU.BT-709.
|
||||
*/
|
||||
template<>
|
||||
struct default_color_converter_impl<ycbcr_709__t, rgb_t>
|
||||
{
|
||||
template < typename SRCP, typename DSTP >
|
||||
void operator()( const SRCP& src, DSTP& dst ) const
|
||||
{
|
||||
using namespace ycbcr_709_color_space;
|
||||
|
||||
using src_channel_t = typename channel_type<SRCP>::type;
|
||||
using dst_channel_t = typename channel_type<DSTP>::type;
|
||||
|
||||
src_channel_t y = channel_convert<src_channel_t>( get_color(src, y_t()) );
|
||||
src_channel_t cb_clipped = channel_convert<src_channel_t>( get_color(src, cb_t()) - 128 );
|
||||
src_channel_t cr_clipped = channel_convert<src_channel_t>( get_color(src, cr_t()) - 128 );
|
||||
|
||||
double red = y + 1.042 * cr_clipped;
|
||||
double green = y - 0.34414 * cb_clipped - 0.71414 * cr_clipped;
|
||||
double blue = y + 1.772 * cb_clipped;
|
||||
|
||||
get_color( dst, red_t() ) = (dst_channel_t) red;
|
||||
get_color( dst, green_t() ) = (dst_channel_t) green;
|
||||
get_color( dst, blue_t() ) = (dst_channel_t) blue;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2005-2007 Adobe Systems Incorporated
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_DYNAMIC_IMAGES_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_DYNAMIC_IMAGES_HPP
|
||||
|
||||
#include <boost/gil/extension/dynamic_image/dynamic_image_all.hpp>
|
||||
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
|
||||
namespace boost { namespace gil {
|
||||
|
||||
// need this for various meta functions.
|
||||
struct any_image_pixel_t {};
|
||||
struct any_image_channel_t {};
|
||||
struct any_image_color_space_t {};
|
||||
|
||||
template<>
|
||||
struct color_space_type< any_image_pixel_t >
|
||||
{
|
||||
using type = any_image_color_space_t;
|
||||
};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
13
macx64/include/boost/gil/extension/toolbox/image_types.hpp
Normal file
13
macx64/include/boost/gil/extension/toolbox/image_types.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IMAGE_TYPES_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IMAGE_TYPES_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/image_types/indexed_image.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,388 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_IMAGE_TYPES_INDEXED_IMAGE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_IMAGE_TYPES_INDEXED_IMAGE_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
|
||||
|
||||
#include <boost/gil/image.hpp>
|
||||
#include <boost/gil/point.hpp>
|
||||
#include <boost/gil/virtual_locator.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
template< typename Locator >
|
||||
struct get_pixel_type_locator : mpl::if_< typename is_bit_aligned< typename Locator::value_type >::type
|
||||
, typename Locator::reference
|
||||
, typename Locator::value_type
|
||||
> {};
|
||||
|
||||
// used for virtual locator
|
||||
template< typename IndicesLoc
|
||||
, typename PaletteLoc
|
||||
>
|
||||
struct indexed_image_deref_fn_base
|
||||
{
|
||||
using indices_locator_t = IndicesLoc;
|
||||
using palette_locator_t = PaletteLoc;
|
||||
//using index_t = typename get_pixel_type_locator<indices_locator_t>::type;
|
||||
|
||||
using const_t = indexed_image_deref_fn_base<IndicesLoc, PaletteLoc>;
|
||||
using value_type = typename PaletteLoc::value_type;
|
||||
using reference = value_type;
|
||||
using const_reference = value_type;
|
||||
using argument_type = point_t;
|
||||
using result_type = reference;
|
||||
|
||||
static const bool is_mutable = false;
|
||||
|
||||
indexed_image_deref_fn_base() {}
|
||||
|
||||
indexed_image_deref_fn_base( const indices_locator_t& indices_loc
|
||||
, const palette_locator_t& palette_loc
|
||||
)
|
||||
: _indices_loc( indices_loc )
|
||||
, _palette_loc( palette_loc )
|
||||
{}
|
||||
|
||||
void set_indices( const indices_locator_t& indices_loc ) { _indices_loc = indices_loc; }
|
||||
void set_palette( const palette_locator_t& palette_loc ) { _palette_loc = palette_loc; }
|
||||
|
||||
const indices_locator_t& indices() const { return _indices_loc; }
|
||||
const palette_locator_t& palette() const { return _palette_loc; }
|
||||
|
||||
protected:
|
||||
|
||||
indices_locator_t _indices_loc;
|
||||
palette_locator_t _palette_loc;
|
||||
};
|
||||
|
||||
|
||||
// used for virtual locator
|
||||
template< typename IndicesLoc
|
||||
, typename PaletteLoc
|
||||
, typename Enable = void // there is specialization for integral indices
|
||||
>
|
||||
struct indexed_image_deref_fn : indexed_image_deref_fn_base< IndicesLoc
|
||||
, PaletteLoc
|
||||
>
|
||||
{
|
||||
using base_t = indexed_image_deref_fn_base
|
||||
<
|
||||
IndicesLoc,
|
||||
PaletteLoc
|
||||
>;
|
||||
|
||||
indexed_image_deref_fn()
|
||||
: base_t()
|
||||
{}
|
||||
|
||||
indexed_image_deref_fn( const typename base_t::indices_locator_t& indices_loc
|
||||
, const typename base_t::palette_locator_t& palette_loc
|
||||
)
|
||||
: base_t( indices_loc
|
||||
, palette_loc
|
||||
)
|
||||
{}
|
||||
|
||||
typename base_t::result_type operator()( const point_t& p ) const
|
||||
{
|
||||
return * this->_palette_loc.xy_at( at_c<0>( *this->_indices_loc.xy_at( p )), 0 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename IndicesLoc, typename PaletteLoc>
|
||||
struct indexed_image_deref_fn
|
||||
<
|
||||
IndicesLoc,
|
||||
PaletteLoc,
|
||||
typename std::enable_if
|
||||
<
|
||||
std::is_integral<typename IndicesLoc::value_type>::value
|
||||
>::type
|
||||
> : indexed_image_deref_fn_base<IndicesLoc, PaletteLoc>
|
||||
{
|
||||
using base_t = indexed_image_deref_fn_base<IndicesLoc, PaletteLoc>;
|
||||
|
||||
indexed_image_deref_fn() : base_t() {}
|
||||
|
||||
indexed_image_deref_fn(
|
||||
typename base_t::indices_locator_t const& indices_loc,
|
||||
typename base_t::palette_locator_t const& palette_loc)
|
||||
: base_t(indices_loc, palette_loc)
|
||||
{
|
||||
}
|
||||
|
||||
typename base_t::result_type operator()(point_t const& p) const
|
||||
{
|
||||
return *this->_palette_loc.xy_at(*this->_indices_loc.xy_at(p), 0);
|
||||
}
|
||||
};
|
||||
|
||||
template< typename IndicesLoc
|
||||
, typename PaletteLoc
|
||||
>
|
||||
struct indexed_image_locator_type
|
||||
{
|
||||
using type = virtual_2d_locator
|
||||
<
|
||||
indexed_image_deref_fn<IndicesLoc, PaletteLoc>,
|
||||
false
|
||||
>;
|
||||
};
|
||||
|
||||
template< typename Locator > // indexed_image_locator_type< ... >::type
|
||||
class indexed_image_view : public image_view< Locator >
|
||||
{
|
||||
public:
|
||||
|
||||
using deref_fn_t = typename Locator::deref_fn_t;
|
||||
using indices_locator_t = typename deref_fn_t::indices_locator_t;
|
||||
using palette_locator_t = typename deref_fn_t::palette_locator_t;
|
||||
|
||||
using const_t = indexed_image_view<Locator>;
|
||||
|
||||
using indices_view_t = image_view<indices_locator_t>;
|
||||
using palette_view_t = image_view<palette_locator_t>;
|
||||
|
||||
indexed_image_view()
|
||||
: image_view< Locator >()
|
||||
, _num_colors( 0 )
|
||||
{}
|
||||
|
||||
indexed_image_view( const point_t& dimensions
|
||||
, std::size_t num_colors
|
||||
, const Locator& locator
|
||||
)
|
||||
: image_view< Locator >( dimensions, locator )
|
||||
, _num_colors( num_colors )
|
||||
{}
|
||||
|
||||
template< typename IndexedView >
|
||||
indexed_image_view( const IndexedView& iv )
|
||||
: image_view< Locator >( iv )
|
||||
, _num_colors( iv._num_colors )
|
||||
{}
|
||||
|
||||
std::size_t num_colors() const { return _num_colors; }
|
||||
|
||||
|
||||
const indices_locator_t& indices() const { return get_deref_fn().indices(); }
|
||||
const palette_locator_t& palette() const { return get_deref_fn().palette(); }
|
||||
|
||||
indices_view_t get_indices_view() const { return indices_view_t(this->dimensions(), indices() );}
|
||||
palette_view_t get_palette_view() const { return palette_view_t(point_t(num_colors(), 1), palette());}
|
||||
|
||||
private:
|
||||
|
||||
const deref_fn_t& get_deref_fn() const { return this->pixels().deref_fn(); }
|
||||
|
||||
private:
|
||||
|
||||
template< typename Locator2 > friend class indexed_image_view;
|
||||
|
||||
std::size_t _num_colors;
|
||||
};
|
||||
|
||||
// build an indexed_image_view from two views
|
||||
template<typename Index_View, typename Palette_View>
|
||||
indexed_image_view
|
||||
<
|
||||
typename indexed_image_locator_type
|
||||
<
|
||||
typename Index_View::locator
|
||||
, typename Palette_View::locator
|
||||
>::type
|
||||
>
|
||||
view(Index_View iv, Palette_View pv)
|
||||
{
|
||||
using view_t = indexed_image_view
|
||||
<
|
||||
typename indexed_image_locator_type
|
||||
<
|
||||
typename Index_View::locator,
|
||||
typename Palette_View::locator
|
||||
>::type
|
||||
>;
|
||||
|
||||
using defer_fn_t = indexed_image_deref_fn
|
||||
<
|
||||
typename Index_View::locator,
|
||||
typename Palette_View::locator
|
||||
>;
|
||||
|
||||
return view_t(
|
||||
iv.dimensions()
|
||||
, pv.dimensions().x
|
||||
, typename view_t::locator(point_t(0, 0), point_t(1, 1), defer_fn_t(iv.xy_at(0, 0), pv.xy_at(0, 0)))
|
||||
);
|
||||
}
|
||||
|
||||
template< typename Index
|
||||
, typename Pixel
|
||||
, typename IndicesAllocator = std::allocator< unsigned char >
|
||||
, typename PalleteAllocator = std::allocator< unsigned char >
|
||||
>
|
||||
class indexed_image
|
||||
{
|
||||
public:
|
||||
|
||||
using indices_t = image<Index, false, IndicesAllocator>;
|
||||
using palette_t = image<Pixel, false, PalleteAllocator>;
|
||||
|
||||
using indices_view_t = typename indices_t::view_t;
|
||||
using palette_view_t = typename palette_t::view_t;
|
||||
|
||||
using indices_const_view_t = typename indices_t::const_view_t;
|
||||
using palette_const_view_t = typename palette_t::const_view_t;
|
||||
|
||||
using indices_locator_t = typename indices_view_t::locator;
|
||||
using palette_locator_t = typename palette_view_t::locator;
|
||||
|
||||
using locator_t = typename indexed_image_locator_type
|
||||
<
|
||||
indices_locator_t,
|
||||
palette_locator_t
|
||||
>::type;
|
||||
|
||||
using x_coord_t = typename indices_t::coord_t;
|
||||
using y_coord_t = typename indices_t::coord_t;
|
||||
|
||||
|
||||
using view_t = indexed_image_view<locator_t>;
|
||||
using const_view_t = typename view_t::const_t;
|
||||
|
||||
indexed_image( const x_coord_t width = 0
|
||||
, const y_coord_t height = 0
|
||||
, const std::size_t num_colors = 1
|
||||
, const std::size_t indices_alignment = 0
|
||||
, const std::size_t palette_alignment = 0
|
||||
)
|
||||
: _indices( width , height, indices_alignment, IndicesAllocator() )
|
||||
, _palette( num_colors, 1, palette_alignment, PalleteAllocator() )
|
||||
{
|
||||
init( point_t( width, height ), num_colors );
|
||||
}
|
||||
|
||||
indexed_image( const point_t& dimensions
|
||||
, const std::size_t num_colors = 1
|
||||
, const std::size_t indices_alignment = 0
|
||||
, const std::size_t palette_alignment = 0
|
||||
)
|
||||
: _indices( dimensions, indices_alignment, IndicesAllocator() )
|
||||
, _palette( num_colors, 1, palette_alignment, PalleteAllocator() )
|
||||
{
|
||||
init( dimensions, num_colors );
|
||||
}
|
||||
|
||||
indexed_image( const indexed_image& img )
|
||||
: _indices( img._indices )
|
||||
, _palette( img._palette )
|
||||
{}
|
||||
|
||||
template <typename Pixel2, typename Index2>
|
||||
indexed_image( const indexed_image< Pixel2, Index2 >& img )
|
||||
{
|
||||
_indices = img._indices;
|
||||
_palette = img._palette;
|
||||
}
|
||||
|
||||
indexed_image& operator= ( const indexed_image& img )
|
||||
{
|
||||
_indices = img._indices;
|
||||
_palette = img._palette;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
indices_const_view_t get_indices_const_view() const { return static_cast< indices_const_view_t >( _view.get_indices_view()); }
|
||||
palette_const_view_t get_palette_const_view() const { return static_cast< palette_const_view_t >( _view.get_palette_view()); }
|
||||
|
||||
indices_view_t get_indices_view() { return _view.get_indices_view(); }
|
||||
palette_view_t get_palette_view() { return _view.get_palette_view(); }
|
||||
|
||||
public:
|
||||
|
||||
view_t _view;
|
||||
|
||||
private:
|
||||
|
||||
void init( const point_t& dimensions
|
||||
, const std::size_t num_colors
|
||||
)
|
||||
{
|
||||
using defer_fn_t = indexed_image_deref_fn
|
||||
<
|
||||
indices_locator_t,
|
||||
palette_locator_t
|
||||
>;
|
||||
|
||||
defer_fn_t deref_fn( view( _indices ).xy_at( 0, 0 )
|
||||
, view( _palette ).xy_at( 0, 0 )
|
||||
);
|
||||
|
||||
locator_t locator( point_t( 0, 0 ) // p
|
||||
, point_t( 1, 1 ) // step
|
||||
, deref_fn
|
||||
);
|
||||
|
||||
_view = view_t( dimensions
|
||||
, num_colors
|
||||
, locator
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
indices_t _indices;
|
||||
palette_t _palette;
|
||||
};
|
||||
|
||||
template< typename Index
|
||||
, typename Pixel
|
||||
>
|
||||
inline
|
||||
const typename indexed_image< Index, Pixel >::view_t& view( indexed_image< Index, Pixel >& img )
|
||||
{
|
||||
return img._view;
|
||||
}
|
||||
|
||||
template< typename Index
|
||||
, typename Pixel
|
||||
>
|
||||
inline
|
||||
const typename indexed_image< Index, Pixel >::const_view_t const_view( indexed_image< Index, Pixel >& img )
|
||||
{
|
||||
return static_cast< const typename indexed_image< Index, Pixel >::const_view_t>( img._view );
|
||||
}
|
||||
|
||||
// Whole image has one color and all indices are set to 0.
|
||||
template< typename Locator
|
||||
, typename Value
|
||||
>
|
||||
void fill_pixels( const indexed_image_view< Locator >& view
|
||||
, const Value& value
|
||||
)
|
||||
{
|
||||
using view_t = indexed_image_view<Locator>;
|
||||
|
||||
fill_pixels( view.get_indices_view(), typename view_t::indices_view_t::value_type( 0 ));
|
||||
*view.get_palette_view().begin() = value;
|
||||
}
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,580 @@
|
||||
//
|
||||
// Copyright 2013 Christian Henning and Juan V. Puertos
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_IMAGE_TYPES_SUBCHROMA_IMAGE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_IMAGE_TYPES_SUBCHROMA_IMAGE_HPP
|
||||
|
||||
#include <boost/gil/dynamic_step.hpp>
|
||||
#include <boost/gil/image.hpp>
|
||||
#include <boost/gil/image_view.hpp>
|
||||
#include <boost/gil/point.hpp>
|
||||
#include <boost/gil/virtual_locator.hpp>
|
||||
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/divides.hpp>
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace boost { namespace gil {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template< int J, int A, int B>
|
||||
struct scaling_factors
|
||||
{
|
||||
static_assert(mpl::equal_to< mpl::int_< J >, mpl::int_< 4 > >::value, "");
|
||||
|
||||
static_assert(mpl::or_<mpl::equal_to< mpl::int_<A>, mpl::int_< 4 > >
|
||||
, mpl::or_< mpl::equal_to< mpl::int_<A>, mpl::int_< 2 > >
|
||||
, mpl::equal_to< mpl::int_<A>, mpl::int_< 1 > >
|
||||
>
|
||||
>::value, "");
|
||||
|
||||
static_assert(mpl::or_< mpl::equal_to< mpl::int_<B>, mpl::int_< 4 > >
|
||||
, mpl::or_< mpl::equal_to< mpl::int_<B>, mpl::int_< 2 > >
|
||||
, mpl::or_< mpl::equal_to< mpl::int_<B>, mpl::int_< 1 > >
|
||||
, mpl::equal_to< mpl::int_<B>, mpl::int_< 0 > >
|
||||
>
|
||||
>
|
||||
>::value, "");
|
||||
|
||||
static constexpr int ss_X =
|
||||
mpl::divides
|
||||
<
|
||||
mpl::int_<J>,
|
||||
mpl::int_<A>
|
||||
>::value;
|
||||
|
||||
static constexpr int ss_Y =
|
||||
mpl::if_
|
||||
<
|
||||
mpl::equal_to<mpl::int_<B>, mpl::int_<0>>,
|
||||
mpl::int_<2>,
|
||||
typename mpl::if_
|
||||
<
|
||||
mpl::equal_to<mpl::int_<A>, mpl::int_<B>>,
|
||||
mpl::int_<1>,
|
||||
mpl::int_<4>
|
||||
>::type
|
||||
>::type::value;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class subchroma_image_deref_fn
|
||||
/// \ingroup PixelLocatorModel PixelBasedModel
|
||||
/// \brief Used for virtual_2D_locator
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Locator
|
||||
, typename Factors
|
||||
>
|
||||
struct subchroma_image_deref_fn
|
||||
{
|
||||
using plane_locator_t = gray8_view_t::locator;
|
||||
|
||||
using const_t = subchroma_image_deref_fn<Locator, Factors>;
|
||||
using value_type = typename Locator::value_type;
|
||||
using reference = value_type;
|
||||
using const_reference = value_type;
|
||||
using argument_type = point_t;
|
||||
using result_type = reference;
|
||||
|
||||
static const bool is_mutable = false;
|
||||
|
||||
/// default constructor
|
||||
subchroma_image_deref_fn() {}
|
||||
|
||||
/// constructor
|
||||
subchroma_image_deref_fn( const plane_locator_t& y_locator
|
||||
, const plane_locator_t& v_locator
|
||||
, const plane_locator_t& u_locator
|
||||
)
|
||||
: _y_locator( y_locator )
|
||||
, _v_locator( v_locator )
|
||||
, _u_locator( u_locator )
|
||||
{}
|
||||
|
||||
/// operator()
|
||||
result_type operator()( const point_t& p ) const
|
||||
{
|
||||
using scaling_factors_t = detail::scaling_factors
|
||||
<
|
||||
mpl::at_c<Factors, 0>::type::value,
|
||||
mpl::at_c<Factors, 1>::type::value,
|
||||
mpl::at_c<Factors, 2>::type::value
|
||||
>;
|
||||
|
||||
plane_locator_t y = _y_locator.xy_at( p );
|
||||
plane_locator_t v = _v_locator.xy_at( p.x / scaling_factors_t::ss_X, p.y / scaling_factors_t::ss_X );
|
||||
plane_locator_t u = _u_locator.xy_at( p.x / scaling_factors_t::ss_X, p.y / scaling_factors_t::ss_X );
|
||||
|
||||
return value_type( at_c< 0 >( *y )
|
||||
, at_c< 0 >( *v )
|
||||
, at_c< 0 >( *u )
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
const plane_locator_t& y_locator() const { return _y_locator; }
|
||||
const plane_locator_t& v_locator() const { return _v_locator; }
|
||||
const plane_locator_t& u_locator() const { return _u_locator; }
|
||||
|
||||
private:
|
||||
|
||||
plane_locator_t _y_locator;
|
||||
plane_locator_t _v_locator;
|
||||
plane_locator_t _u_locator;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class subchroma_image_locator_type
|
||||
/// \ingroup PixelLocatorModel PixelBasedModel
|
||||
/// \brief
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Locator
|
||||
, typename Factors
|
||||
>
|
||||
struct subchroma_image_locator
|
||||
{
|
||||
using type = virtual_2d_locator
|
||||
<
|
||||
subchroma_image_deref_fn<Locator, Factors>, // Deref
|
||||
false // IsTransposed
|
||||
>;
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
// PixelBasedConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct channel_type< subchroma_image_locator< Locator, Factors > >
|
||||
: public channel_type< typename subchroma_image_locator< Locator, Factors >::type > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct color_space_type< subchroma_image_locator< Locator, Factors > >
|
||||
: public color_space_type< typename subchroma_image_locator< Locator, Factors >::type > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct channel_mapping_type< subchroma_image_locator< Locator, Factors > >
|
||||
: public channel_mapping_type< typename subchroma_image_locator< Locator, Factors >::type > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct is_planar< subchroma_image_locator< Locator, Factors > >
|
||||
: public is_planar< typename subchroma_image_locator< Locator, Factors >::type > {};
|
||||
|
||||
/////////////////////////////
|
||||
// HasDynamicXStepTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct dynamic_x_step_type< subchroma_image_locator< Locator, Factors > >
|
||||
{
|
||||
using type = typename subchroma_image_locator<Locator, Factors>::type;
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
// HasDynamicYStepTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct dynamic_y_step_type< subchroma_image_locator< Locator, Factors > >
|
||||
{
|
||||
using type = typename subchroma_image_locator<Locator, Factors>::type;
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
// HasTransposedTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct transposed_type< subchroma_image_locator< Locator, Factors > >
|
||||
{
|
||||
using type = typename subchroma_image_locator<Locator, Factors>::type;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class subchroma_image_view
|
||||
/// \ingroup ImageViewModel PixelBasedModel
|
||||
/// \brief A lightweight object that interprets a subchroma image.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Locator
|
||||
, typename Factors = mpl::vector_c< int, 4, 4, 4 >
|
||||
>
|
||||
class subchroma_image_view : public image_view< Locator >
|
||||
{
|
||||
public:
|
||||
|
||||
using locator = Locator;
|
||||
using deref_fn_t = typename locator::deref_fn_t;
|
||||
using plane_locator_t = typename deref_fn_t::plane_locator_t;
|
||||
|
||||
|
||||
using const_t = subchroma_image_view<Locator, Factors>;
|
||||
|
||||
using plane_view_t = image_view<plane_locator_t>;
|
||||
|
||||
/// default constructor
|
||||
subchroma_image_view()
|
||||
: image_view< Locator >()
|
||||
{}
|
||||
|
||||
/// constructor
|
||||
subchroma_image_view( const point_t& y_dimensions
|
||||
, const point_t& v_dimensions
|
||||
, const point_t& u_dimensions
|
||||
, const Locator& locator
|
||||
)
|
||||
: image_view< Locator >( y_dimensions, locator )
|
||||
, _y_dimensions( y_dimensions )
|
||||
, _v_dimensions( v_dimensions )
|
||||
, _u_dimensions( u_dimensions )
|
||||
{}
|
||||
|
||||
/// copy constructor
|
||||
template< typename Subchroma_View >
|
||||
subchroma_image_view( const Subchroma_View& v )
|
||||
: image_view< locator >( v )
|
||||
{}
|
||||
|
||||
const point_t& v_ssfactors() const { return point_t( get_deref_fn().vx_ssfactor(), get_deref_fn().vx_ssfactor() ); }
|
||||
const point_t& u_ssfactors() const { return point_t( get_deref_fn().ux_ssfactor(), get_deref_fn().ux_ssfactor() ); }
|
||||
|
||||
const point_t& y_dimension() const { return _y_dimensions; }
|
||||
const point_t& v_dimension() const { return _v_dimensions; }
|
||||
const point_t& u_dimension() const { return _u_dimensions; }
|
||||
|
||||
const plane_locator_t& y_plane() const { return get_deref_fn().y_locator(); }
|
||||
const plane_locator_t& v_plane() const { return get_deref_fn().v_locator(); }
|
||||
const plane_locator_t& u_plane() const { return get_deref_fn().u_locator(); }
|
||||
|
||||
const plane_view_t y_plane_view() const { return plane_view_t( _y_dimensions, y_plane() ); }
|
||||
const plane_view_t v_plane_view() const { return plane_view_t( _v_dimensions, v_plane() ); }
|
||||
const plane_view_t u_plane_view() const { return plane_view_t( _u_dimensions, u_plane() ); }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
const deref_fn_t& get_deref_fn() const { return this->pixels().deref_fn(); }
|
||||
|
||||
private:
|
||||
|
||||
point_t _y_dimensions;
|
||||
point_t _v_dimensions;
|
||||
point_t _u_dimensions;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// PixelBasedConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct channel_type< subchroma_image_view< Locator, Factors > >
|
||||
: public channel_type< Locator > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct color_space_type< subchroma_image_view< Locator, Factors > >
|
||||
: public color_space_type< Locator > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct channel_mapping_type< subchroma_image_view< Locator, Factors > >
|
||||
: public channel_mapping_type< Locator > {};
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct is_planar< subchroma_image_view< Locator, Factors > >
|
||||
: public is_planar< Locator > {};
|
||||
|
||||
/////////////////////////////
|
||||
// HasDynamicXStepTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct dynamic_x_step_type< subchroma_image_view< Locator, Factors > >
|
||||
{
|
||||
using type = image_view<typename dynamic_x_step_type<Locator>::type>;
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
// HasDynamicYStepTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct dynamic_y_step_type< subchroma_image_view< Locator, Factors > >
|
||||
{
|
||||
using type = image_view<typename dynamic_y_step_type<Locator>::type>;
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
// HasTransposedTypeConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Locator, typename Factors >
|
||||
struct transposed_type< subchroma_image_view< Locator, Factors > >
|
||||
{
|
||||
using type = image_view<typename transposed_type<Locator>::type>;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \ingroup ImageModel PixelBasedModel
|
||||
/// \brief container interface over image view. Models ImageConcept, PixelBasedConcept
|
||||
///
|
||||
/// A subchroma image holds a bunch of planes which don't need to have the same resolution.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Pixel
|
||||
, typename Factors = mpl::vector_c< int, 4, 4, 4 >
|
||||
, typename Allocator = std::allocator< unsigned char >
|
||||
>
|
||||
class subchroma_image : public detail::scaling_factors< mpl::at_c< Factors, 0 >::type::value
|
||||
, mpl::at_c< Factors, 1 >::type::value
|
||||
, mpl::at_c< Factors, 2 >::type::value
|
||||
>
|
||||
{
|
||||
|
||||
private:
|
||||
using parent_t = detail::scaling_factors< mpl::at_c< Factors, 0 >::type::value
|
||||
, mpl::at_c< Factors, 1 >::type::value
|
||||
, mpl::at_c< Factors, 2 >::type::value
|
||||
>;
|
||||
|
||||
public:
|
||||
|
||||
using channel_t = typename channel_type<Pixel>::type;
|
||||
using pixel_t = pixel<channel_t, gray_layout_t>;
|
||||
|
||||
using plane_image_t = image<pixel_t, false, Allocator>;
|
||||
|
||||
using plane_view_t = typename plane_image_t::view_t;
|
||||
using plane_const_view_t = typename plane_image_t::const_view_t;
|
||||
using plane_locator_t = typename plane_view_t::locator;
|
||||
|
||||
using pixel_view_t = typename view_type_from_pixel<Pixel>::type;
|
||||
using pixel_locator_t = typename pixel_view_t::locator;
|
||||
|
||||
using locator_t = typename subchroma_image_locator
|
||||
<
|
||||
pixel_locator_t,
|
||||
Factors
|
||||
>::type;
|
||||
|
||||
using x_coord_t = typename plane_image_t::coord_t;
|
||||
using y_coord_t = typename plane_image_t::coord_t;
|
||||
|
||||
using view_t = subchroma_image_view<locator_t, Factors>;
|
||||
using const_view_t = typename view_t::const_t;
|
||||
|
||||
|
||||
/// constructor
|
||||
subchroma_image( const x_coord_t y_width
|
||||
, const y_coord_t y_height
|
||||
)
|
||||
: _y_plane( y_width, y_height, 0, Allocator() )
|
||||
, _v_plane( y_width / parent_t::ss_X, y_height / parent_t::ss_Y, 0, Allocator() )
|
||||
, _u_plane( y_width / parent_t::ss_X, y_height / parent_t::ss_Y, 0, Allocator() )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
view_t _view;
|
||||
|
||||
private:
|
||||
|
||||
void init()
|
||||
{
|
||||
using defer_fn_t = subchroma_image_deref_fn<pixel_locator_t, Factors>;
|
||||
|
||||
defer_fn_t deref_fn( view( _y_plane ).xy_at( 0, 0 )
|
||||
, view( _v_plane ).xy_at( 0, 0 )
|
||||
, view( _u_plane ).xy_at( 0, 0 )
|
||||
);
|
||||
|
||||
// init a virtual_2d_locator
|
||||
locator_t locator( point_t( 0, 0 ) // p
|
||||
, point_t( 1, 1 ) // step
|
||||
, deref_fn
|
||||
);
|
||||
|
||||
_view = view_t( _y_plane.dimensions()
|
||||
, _v_plane.dimensions()
|
||||
, _u_plane.dimensions()
|
||||
, locator
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
plane_image_t _y_plane;
|
||||
plane_image_t _v_plane;
|
||||
plane_image_t _u_plane;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// PixelBasedConcept
|
||||
/////////////////////////////
|
||||
|
||||
template < typename Pixel, typename Factors, typename Alloc >
|
||||
struct channel_type< subchroma_image< Pixel, Factors, Alloc > >
|
||||
: public channel_type< Pixel > {};
|
||||
|
||||
template < typename Pixel, typename Factors, typename Alloc >
|
||||
struct color_space_type< subchroma_image< Pixel, Factors, Alloc > >
|
||||
: public color_space_type< Pixel > {};
|
||||
|
||||
template < typename Pixel, typename Factors, typename Alloc >
|
||||
struct channel_mapping_type< subchroma_image< Pixel, Factors, Alloc > >
|
||||
: public channel_mapping_type< Pixel > {};
|
||||
|
||||
template < typename Pixel, typename Factors, typename Alloc >
|
||||
struct is_planar< subchroma_image< Pixel, Factors, Alloc > >
|
||||
: public mpl::bool_< false > {};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \name view, const_view
|
||||
/// \brief Get an image view from an subchroma_image
|
||||
/// \ingroup ImageModel
|
||||
/// \brief Returns the non-constant-pixel view of an image
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Pixel
|
||||
, typename Factors
|
||||
>
|
||||
inline
|
||||
const typename subchroma_image< Pixel, Factors >::view_t& view( subchroma_image< Pixel, Factors >& img )
|
||||
{
|
||||
return img._view;
|
||||
}
|
||||
|
||||
template< typename Pixel
|
||||
, typename Factors
|
||||
>
|
||||
inline
|
||||
const typename subchroma_image< Pixel, Factors >::const_view_t const_view( subchroma_image< Pixel, Factors >& img )
|
||||
{
|
||||
return static_cast< const typename subchroma_image< Pixel, Factors >::const_view_t>( img._view );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \ingroup ImageViewSTLAlgorithmsFillPixels
|
||||
/// \brief std::fill for subchroma_image views
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Locator
|
||||
, typename Factors
|
||||
, typename Pixel
|
||||
>
|
||||
void fill_pixels( const subchroma_image_view< Locator, Factors >& view
|
||||
, const Pixel& value
|
||||
)
|
||||
{
|
||||
using channel_t = typename subchroma_image
|
||||
<
|
||||
Pixel,
|
||||
Factors
|
||||
>::plane_view_t::value_type;
|
||||
|
||||
fill_pixels( view.y_plane_view(), channel_t( at_c< 0 >( value )));
|
||||
fill_pixels( view.v_plane_view(), channel_t( at_c< 1 >( value )));
|
||||
fill_pixels( view.u_plane_view(), channel_t( at_c< 2 >( value )));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \ingroup ImageViewConstructors
|
||||
/// \brief Creates a subchroma view from a raw memory
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< typename Pixel
|
||||
, typename Factors
|
||||
>
|
||||
typename subchroma_image< Pixel
|
||||
, Factors
|
||||
>::view_t subchroma_view( std::size_t y_width
|
||||
, std::size_t y_height
|
||||
, unsigned char* y_base
|
||||
)
|
||||
{
|
||||
using scaling_factors_t = detail::scaling_factors
|
||||
<
|
||||
mpl::at_c<Factors, 0>::type::value,
|
||||
mpl::at_c<Factors, 1>::type::value,
|
||||
mpl::at_c<Factors, 2>::type::value
|
||||
>;
|
||||
|
||||
std::size_t y_channel_size = 1;
|
||||
std::size_t u_channel_size = 1;
|
||||
|
||||
unsigned char* u_base = y_base + ( y_width * y_height * y_channel_size );
|
||||
unsigned char* v_base = u_base + ( y_width / scaling_factors_t::ss_X )
|
||||
* u_channel_size;
|
||||
|
||||
using plane_view_t = typename subchroma_image<Pixel, Factors>::plane_view_t;
|
||||
|
||||
plane_view_t y_plane = interleaved_view( y_width
|
||||
, y_height
|
||||
, (typename plane_view_t::value_type*) y_base // pixels
|
||||
, y_width // rowsize_in_bytes
|
||||
);
|
||||
|
||||
plane_view_t v_plane = interleaved_view( y_width / scaling_factors_t::ss_X
|
||||
, y_height / scaling_factors_t::ss_Y
|
||||
, (typename plane_view_t::value_type*) v_base // pixels
|
||||
, y_width // rowsize_in_bytes
|
||||
);
|
||||
|
||||
plane_view_t u_plane = interleaved_view( y_width / scaling_factors_t::ss_X
|
||||
, y_height / scaling_factors_t::ss_Y
|
||||
, (typename plane_view_t::value_type*) u_base // pixels
|
||||
, y_width // rowsize_in_bytes
|
||||
);
|
||||
|
||||
using defer_fn_t = subchroma_image_deref_fn
|
||||
<
|
||||
typename subchroma_image<Pixel, Factors>::pixel_locator_t,
|
||||
Factors
|
||||
>;
|
||||
|
||||
defer_fn_t deref_fn( y_plane.xy_at( 0, 0 )
|
||||
, v_plane.xy_at( 0, 0 )
|
||||
, u_plane.xy_at( 0, 0 )
|
||||
);
|
||||
|
||||
|
||||
using locator_t = typename subchroma_image<Pixel, Factors>::locator_t;
|
||||
|
||||
locator_t locator( point_t( 0, 0 ) // p
|
||||
, point_t( 1, 1 ) // step
|
||||
, deref_fn
|
||||
);
|
||||
|
||||
using view_t = typename subchroma_image<Pixel, Factors>::view_t;
|
||||
|
||||
return view_t( point_t( y_width, y_height )
|
||||
, point_t( y_width / scaling_factors_t::ss_X, y_height / scaling_factors_t::ss_Y )
|
||||
, point_t( y_width / scaling_factors_t::ss_X, y_height / scaling_factors_t::ss_Y )
|
||||
, locator
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
20
macx64/include/boost/gil/extension/toolbox/metafunctions.hpp
Normal file
20
macx64/include/boost/gil/extension/toolbox/metafunctions.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/metafunctions/channel_type.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/channel_view.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/get_pixel_type.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_homogeneous.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_similar.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/pixel_bit_size.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/dynamic_images.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_homogeneous.hpp>
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
#include <boost/gil/channel.hpp>
|
||||
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/utility/enable_if.hpp> // boost::lazy_enable_if
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// channel_type metafunction
|
||||
/// \brief Generates the channel type for
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct gen_chan_ref
|
||||
{
|
||||
using type = packed_dynamic_channel_reference
|
||||
<
|
||||
B,
|
||||
mpl::at_c<C, 0>::type::value,
|
||||
M
|
||||
>;
|
||||
};
|
||||
|
||||
//! This implementation works for bit_algined_pixel_reference
|
||||
//! with a homogeneous channel layout.
|
||||
//! The result type will be a packed_dynamic_channel_reference, since the
|
||||
//! offset info will be missing.
|
||||
|
||||
// bit_aligned_pixel_reference
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct channel_type< bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
|
||||
, gen_chan_ref< B, C, L, M >
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct channel_type<const bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
|
||||
, gen_chan_ref< B, C, L, M >
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct gen_chan_ref_p
|
||||
{
|
||||
using type = packed_dynamic_channel_reference
|
||||
<
|
||||
B,
|
||||
get_num_bits<typename mpl::at_c<C, 0>::type>::value,
|
||||
true
|
||||
>;
|
||||
};
|
||||
|
||||
// packed_pixel
|
||||
template < typename BitField
|
||||
, typename ChannelRefVec
|
||||
, typename Layout
|
||||
>
|
||||
struct channel_type< packed_pixel< BitField
|
||||
, ChannelRefVec
|
||||
, Layout
|
||||
>
|
||||
> : lazy_enable_if< is_homogeneous< packed_pixel< BitField
|
||||
, ChannelRefVec
|
||||
, Layout
|
||||
>
|
||||
>
|
||||
, gen_chan_ref_p< BitField
|
||||
, ChannelRefVec
|
||||
, Layout
|
||||
>
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct channel_type< const packed_pixel< B, C, L > >
|
||||
: lazy_enable_if< is_homogeneous<packed_pixel< B, C, L > >
|
||||
, gen_chan_ref_p< B, C, L >
|
||||
>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct channel_type< any_image_pixel_t >
|
||||
{
|
||||
using type = any_image_channel_t;
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// Copyright 2010 Fabien Castan, Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
|
||||
|
||||
#include <boost/gil/image_view_factory.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace gil {
|
||||
|
||||
template < typename Channel
|
||||
, typename View
|
||||
>
|
||||
struct channel_type_to_index
|
||||
{
|
||||
static const int value = detail::type_to_index< typename color_space_type< View >::type // color (mpl::vector)
|
||||
, Channel // channel type
|
||||
>::value; //< index of the channel in the color (mpl::vector)
|
||||
};
|
||||
|
||||
template< typename Channel
|
||||
, typename View
|
||||
>
|
||||
struct channel_view_type : public kth_channel_view_type< channel_type_to_index< Channel
|
||||
, View
|
||||
>::value
|
||||
, View
|
||||
>
|
||||
{
|
||||
static const int index = channel_type_to_index< Channel
|
||||
, View
|
||||
>::value;
|
||||
|
||||
using parent_t = kth_channel_view_type<index, View>;
|
||||
using type = typename parent_t::type;
|
||||
|
||||
static type make( const View& src )
|
||||
{
|
||||
return parent_t::make( src );
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ImageViewTransformationsKthChannel
|
||||
template< typename Channel
|
||||
, typename View
|
||||
>
|
||||
typename channel_view_type< Channel
|
||||
, View
|
||||
>::type channel_view( const View& src )
|
||||
{
|
||||
return channel_view_type< Channel
|
||||
, View
|
||||
>::make( src );
|
||||
}
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
|
||||
|
||||
#include <boost/gil/channel.hpp>
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// get_num_bits metafunctions
|
||||
/// \brief Determines the numbers of bits for the given channel type.
|
||||
|
||||
template <typename T, class = void >
|
||||
struct get_num_bits;
|
||||
|
||||
template< typename B, int I, int S, bool M >
|
||||
struct get_num_bits< packed_channel_reference< B, I, S, M > > : mpl::int_< S >
|
||||
{};
|
||||
|
||||
template< typename B, int I, int S, bool M >
|
||||
struct get_num_bits< const packed_channel_reference< B, I, S, M > > : mpl::int_< S >
|
||||
{};
|
||||
|
||||
template<typename B, int I, bool M>
|
||||
struct get_num_bits< packed_dynamic_channel_reference< B, I, M > > : mpl::int_< I >
|
||||
{};
|
||||
|
||||
template<typename B, int I, bool M>
|
||||
struct get_num_bits< const packed_dynamic_channel_reference< B, I, M > > : mpl::int_< I >
|
||||
{};
|
||||
|
||||
template< int N >
|
||||
struct get_num_bits< packed_channel_value< N > > : mpl::int_< N >
|
||||
{};
|
||||
|
||||
template< int N >
|
||||
struct get_num_bits< const packed_channel_value< N > > : mpl::int_< N >
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct get_num_bits
|
||||
<
|
||||
T,
|
||||
typename std::enable_if
|
||||
<
|
||||
mpl::and_
|
||||
<
|
||||
is_integral<T>,
|
||||
mpl::not_<is_class<T>>
|
||||
>::value
|
||||
>::type
|
||||
> : mpl::size_t<sizeof(T) * 8>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/dynamic_images.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// get_pixel_type metafunction
|
||||
/// \brief Depending on Image this function generates either
|
||||
/// the pixel type or the reference type in case
|
||||
/// the image is bit_aligned.
|
||||
template< typename View >
|
||||
struct get_pixel_type : mpl::if_< typename is_bit_aligned< typename View::value_type >::type
|
||||
, typename View::reference
|
||||
, typename View::value_type
|
||||
> {};
|
||||
|
||||
template< typename ImageViewTypes >
|
||||
struct get_pixel_type< any_image_view< ImageViewTypes > >
|
||||
{
|
||||
using type = any_image_pixel_t;
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_BIT_ALIGNED_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_BIT_ALIGNED_TYPE_HPP
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_bit_aligned metafunctions
|
||||
/// \brief Determines whether the given type is bit_aligned.
|
||||
|
||||
template< typename PixelRef >
|
||||
struct is_bit_aligned : mpl::false_{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_bit_aligned<bit_aligned_pixel_reference<B,C,L,M> > : mpl::true_{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_bit_aligned<const bit_aligned_pixel_reference<B,C,L,M> > : mpl::true_{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct is_bit_aligned<packed_pixel<B,C,L> > : mpl::true_{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct is_bit_aligned<const packed_pixel<B,C,L> > : mpl::true_{};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_HOMOGENEOUS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_HOMOGENEOUS_HPP
|
||||
|
||||
#include <boost/gil/pixel.hpp>
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_homogeneous metafunctions
|
||||
/// \brief Determines if a pixel types are homogeneous.
|
||||
|
||||
template<typename C,typename CMP, int Next, int Last> struct is_homogeneous_impl;
|
||||
|
||||
template<typename C,typename CMP, int Last>
|
||||
struct is_homogeneous_impl<C,CMP,Last,Last> : mpl::true_{};
|
||||
|
||||
template<typename C,typename CMP, int Next, int Last>
|
||||
struct is_homogeneous_impl : mpl::and_< is_homogeneous_impl< C, CMP,Next + 1, Last >
|
||||
, is_same< CMP, typename mpl::at_c<C,Next>::type
|
||||
> > {};
|
||||
|
||||
template < typename P > struct is_homogeneous : mpl::false_ {};
|
||||
|
||||
// pixel
|
||||
template < typename C, typename L > struct is_homogeneous< pixel<C,L> > : mpl::true_ {};
|
||||
template < typename C, typename L > struct is_homogeneous<const pixel<C,L> > : mpl::true_ {};
|
||||
template < typename C, typename L > struct is_homogeneous< pixel<C,L>& > : mpl::true_ {};
|
||||
template < typename C, typename L > struct is_homogeneous<const pixel<C,L>& > : mpl::true_ {};
|
||||
|
||||
// planar pixel reference
|
||||
template <typename Channel, typename ColorSpace>
|
||||
struct is_homogeneous< planar_pixel_reference< Channel, ColorSpace > > : mpl::true_ {};
|
||||
template <typename Channel, typename ColorSpace>
|
||||
struct is_homogeneous< const planar_pixel_reference< Channel, ColorSpace > > : mpl::true_ {};
|
||||
|
||||
template<typename C,typename CMP, int I,int Last>
|
||||
struct is_homogeneous_impl_p {};
|
||||
|
||||
// for packed_pixel
|
||||
template <typename B, typename C, typename L >
|
||||
struct is_homogeneous<packed_pixel< B, C, L > >
|
||||
: is_homogeneous_impl_p< C
|
||||
, typename mpl::at_c< C, 0 >::type
|
||||
, 1
|
||||
, mpl::size< C >::value
|
||||
> {};
|
||||
|
||||
template< typename B
|
||||
, typename C
|
||||
, typename L
|
||||
>
|
||||
struct is_homogeneous< const packed_pixel< B, C, L > >
|
||||
: is_homogeneous_impl_p< C
|
||||
, typename mpl::at_c<C,0>::type
|
||||
, 1
|
||||
, mpl::size< C >::value
|
||||
> {};
|
||||
|
||||
// for bit_aligned_pixel_reference
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_homogeneous<bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: is_homogeneous_impl<C,typename mpl::at_c<C,0>::type,1,mpl::size<C>::value>
|
||||
{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_homogeneous<const bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: is_homogeneous_impl<C,typename mpl::at_c<C,0>::type,1,mpl::size<C>::value>
|
||||
{};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_SIMILAR_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_SIMILAR_HPP
|
||||
|
||||
#include <boost/gil/channel.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_similar metafunctions
|
||||
/// \brief Determines if two pixel types are similar.
|
||||
|
||||
template< typename A, typename B >
|
||||
struct is_similar : mpl::false_ {};
|
||||
|
||||
template<typename A>
|
||||
struct is_similar< A, A > : mpl::true_ {};
|
||||
|
||||
template<typename B,int I, int S, bool M, int I2>
|
||||
struct is_similar< packed_channel_reference< B, I, S, M >
|
||||
, packed_channel_reference< B, I2, S, M >
|
||||
> : mpl::true_ {};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
#include <boost/gil/packed_pixel.hpp>
|
||||
|
||||
#include <boost/mpl/accumulate.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// pixel_bit_size metafunctions
|
||||
/// \brief Accumulates the all channel size.
|
||||
///
|
||||
/// \code
|
||||
/// using image_t = bit_aligned_image5_type<16, 16, 16, 8, 8, devicen_layout_t<5>>::type;
|
||||
/// const int size = pixel_bit_size<image_t::view_t::reference>::value;
|
||||
/// \endcode
|
||||
template< typename PixelRef >
|
||||
struct pixel_bit_size : mpl::int_<0> {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct pixel_bit_size<bit_aligned_pixel_reference<B,C,L,M> > : mpl::int_< mpl::accumulate< C, mpl::int_<0>, mpl::plus<mpl::_1, mpl::_2> >::type::value >{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct pixel_bit_size<const bit_aligned_pixel_reference<B,C,L,M> > : mpl::int_< mpl::accumulate< C, mpl::int_<0>, mpl::plus<mpl::_1, mpl::_2> >::type::value >{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct pixel_bit_size<packed_pixel<B,C,L> > : mpl::int_< mpl::accumulate< C, mpl::int_<0>, mpl::plus<mpl::_1, mpl::_2> >::type::value >{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct pixel_bit_size<const packed_pixel<B,C,L> > : mpl::int_< mpl::accumulate< C, mpl::int_<0>, mpl::plus<mpl::_1, mpl::_2> >::type::value >{};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
17
macx64/include/boost/gil/extension/toolbox/toolbox.hpp
Normal file
17
macx64/include/boost/gil/extension/toolbox/toolbox.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_TOOLBOX_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_TOOLBOX_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/color_converters.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces.hpp>
|
||||
#include <boost/gil/extension/toolbox/dynamic_images.hpp>
|
||||
#include <boost/gil/extension/toolbox/image_types.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions.hpp>
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user