123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- #ifndef BOOST_GIL_PIXEL_NUMERIC_OPERATIONS_HPP
- #define BOOST_GIL_PIXEL_NUMERIC_OPERATIONS_HPP
- #include <boost/gil/color_base_algorithm.hpp>
- #include <boost/gil/pixel.hpp>
- #include <boost/gil/channel_numeric_operations.hpp>
- namespace boost { namespace gil {
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- struct pixel_plus_t
- {
- auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
- {
- PixelResult result;
- static_transform(p1, p2, result,
- channel_plus_t
- <
- typename channel_type<PixelRef1>::type,
- typename channel_type<PixelRef2>::type,
- typename channel_type<PixelResult>::type
- >());
- return result;
- }
- };
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- struct pixel_minus_t
- {
- auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
- {
- PixelResult result;
- static_transform(p1, p2, result,
- channel_minus_t
- <
- typename channel_type<PixelRef1>::type,
- typename channel_type<PixelRef2>::type,
- typename channel_type<PixelResult>::type
- >());
- return result;
- }
- };
- template <typename PixelRef, typename Scalar, typename PixelResult>
- struct pixel_multiplies_scalar_t
- {
- auto operator()(PixelRef const& p, Scalar const& s) const -> PixelResult
- {
- PixelResult result;
- static_transform(p, result,
- std::bind(
- channel_multiplies_scalar_t<typename channel_type<PixelRef>::type,
- Scalar,
- typename channel_type<PixelResult>::type>(),
- std::placeholders::_1, s));
- return result;
- }
- };
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- struct pixel_multiplies_t
- {
- auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
- {
- PixelResult result;
- static_transform(p1, p2, result,
- channel_multiplies_t
- <
- typename channel_type<PixelRef1>::type,
- typename channel_type<PixelRef2>::type,
- typename channel_type<PixelResult>::type
- >());
- return result;
- }
- };
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- using pixel_multiply_t [[deprecated]] = pixel_multiplies_t<PixelRef1, PixelRef2, PixelResult>;
- template <typename PixelRef, typename Scalar, typename PixelResult>
- struct pixel_divides_scalar_t
- {
- auto operator()(PixelRef const& p, Scalar const& s) const -> PixelResult
- {
- PixelResult result;
- static_transform(p, result,
- std::bind(channel_divides_scalar_t<typename channel_type<PixelRef>::type,
- Scalar,
- typename channel_type<PixelResult>::type>(),
- std::placeholders::_1, s));
- return result;
- }
- };
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- struct pixel_divides_t
- {
- auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
- {
- PixelResult result;
- static_transform(p1, p2, result,
- channel_divides_t
- <
- typename channel_type<PixelRef1>::type,
- typename channel_type<PixelRef2>::type,
- typename channel_type<PixelResult>::type
- >());
- return result;
- }
- };
- template <typename PixelRef1, typename PixelRef2, typename PixelResult>
- using pixel_divide_t [[deprecated]] = pixel_divides_t<PixelRef1, PixelRef2, PixelResult>;
- template <typename PixelRef>
- struct pixel_halves_t
- {
- auto operator()(PixelRef& p) const -> PixelRef&
- {
- static_for_each(p, channel_halves_t<typename channel_type<PixelRef>::type>());
- return p;
- }
- };
- template <typename PixelRef>
- struct pixel_zeros_t
- {
- auto operator()(PixelRef& p) const -> PixelRef&
- {
- static_for_each(p, channel_zeros_t<typename channel_type<PixelRef>::type>());
- return p;
- }
- };
- template <typename Pixel>
- void zero_channels(Pixel& p)
- {
- static_for_each(p, channel_zeros_t<typename channel_type<Pixel>::type>());
- }
- template <typename PixelRef, typename PixelResult>
- struct pixel_assigns_t
- {
- auto operator()(PixelRef const& src, PixelResult& dst) const -> PixelResult
- {
- static_for_each(src, dst,
- channel_assigns_t
- <
- typename channel_type<PixelRef>::type,
- typename channel_type<PixelResult>::type
- >());
- return dst;
- }
- };
- }}
- #endif
|