File indexing completed on 2025-01-30 09:42:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GIL_PIXEL_NUMERIC_OPERATIONS_HPP
0010 #define BOOST_GIL_PIXEL_NUMERIC_OPERATIONS_HPP
0011
0012 #include <boost/gil/color_base_algorithm.hpp>
0013 #include <boost/gil/pixel.hpp>
0014 #include <boost/gil/channel_numeric_operations.hpp>
0015
0016 namespace boost { namespace gil {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0037 struct pixel_plus_t
0038 {
0039 auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
0040 {
0041 PixelResult result;
0042 static_transform(p1, p2, result,
0043 channel_plus_t
0044 <
0045 typename channel_type<PixelRef1>::type,
0046 typename channel_type<PixelRef2>::type,
0047 typename channel_type<PixelResult>::type
0048 >());
0049 return result;
0050 }
0051 };
0052
0053
0054
0055
0056
0057
0058 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0059 struct pixel_minus_t
0060 {
0061 auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
0062 {
0063 PixelResult result;
0064 static_transform(p1, p2, result,
0065 channel_minus_t
0066 <
0067 typename channel_type<PixelRef1>::type,
0068 typename channel_type<PixelRef2>::type,
0069 typename channel_type<PixelResult>::type
0070 >());
0071 return result;
0072 }
0073 };
0074
0075
0076
0077
0078
0079
0080 template <typename PixelRef, typename Scalar, typename PixelResult>
0081 struct pixel_multiplies_scalar_t
0082 {
0083 auto operator()(PixelRef const& p, Scalar const& s) const -> PixelResult
0084 {
0085 PixelResult result;
0086 static_transform(p, result,
0087 std::bind(
0088 channel_multiplies_scalar_t<typename channel_type<PixelRef>::type,
0089 Scalar,
0090 typename channel_type<PixelResult>::type>(),
0091 std::placeholders::_1, s));
0092 return result;
0093 }
0094 };
0095
0096
0097
0098
0099
0100
0101 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0102 struct pixel_multiplies_t
0103 {
0104 auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
0105 {
0106 PixelResult result;
0107 static_transform(p1, p2, result,
0108 channel_multiplies_t
0109 <
0110 typename channel_type<PixelRef1>::type,
0111 typename channel_type<PixelRef2>::type,
0112 typename channel_type<PixelResult>::type
0113 >());
0114 return result;
0115 }
0116 };
0117
0118 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0119 using pixel_multiply_t [[deprecated]] = pixel_multiplies_t<PixelRef1, PixelRef2, PixelResult>;
0120
0121
0122
0123
0124
0125
0126 template <typename PixelRef, typename Scalar, typename PixelResult>
0127 struct pixel_divides_scalar_t
0128 {
0129 auto operator()(PixelRef const& p, Scalar const& s) const -> PixelResult
0130 {
0131 PixelResult result;
0132 static_transform(p, result,
0133 std::bind(channel_divides_scalar_t<typename channel_type<PixelRef>::type,
0134 Scalar,
0135 typename channel_type<PixelResult>::type>(),
0136 std::placeholders::_1, s));
0137 return result;
0138 }
0139 };
0140
0141
0142
0143
0144
0145
0146 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0147 struct pixel_divides_t
0148 {
0149 auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
0150 {
0151 PixelResult result;
0152 static_transform(p1, p2, result,
0153 channel_divides_t
0154 <
0155 typename channel_type<PixelRef1>::type,
0156 typename channel_type<PixelRef2>::type,
0157 typename channel_type<PixelResult>::type
0158 >());
0159 return result;
0160 }
0161 };
0162
0163 template <typename PixelRef1, typename PixelRef2, typename PixelResult>
0164 using pixel_divide_t [[deprecated]] = pixel_divides_t<PixelRef1, PixelRef2, PixelResult>;
0165
0166
0167
0168
0169 template <typename PixelRef>
0170 struct pixel_halves_t
0171 {
0172 auto operator()(PixelRef& p) const -> PixelRef&
0173 {
0174 static_for_each(p, channel_halves_t<typename channel_type<PixelRef>::type>());
0175 return p;
0176 }
0177 };
0178
0179
0180
0181
0182 template <typename PixelRef>
0183 struct pixel_zeros_t
0184 {
0185 auto operator()(PixelRef& p) const -> PixelRef&
0186 {
0187 static_for_each(p, channel_zeros_t<typename channel_type<PixelRef>::type>());
0188 return p;
0189 }
0190 };
0191
0192
0193
0194 template <typename Pixel>
0195 void zero_channels(Pixel& p)
0196 {
0197 static_for_each(p, channel_zeros_t<typename channel_type<Pixel>::type>());
0198 }
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208 template <typename PixelRef, typename PixelResult>
0209 struct pixel_assigns_t
0210 {
0211 auto operator()(PixelRef const& src, PixelResult& dst) const -> PixelResult
0212 {
0213 static_for_each(src, dst,
0214 channel_assigns_t
0215 <
0216 typename channel_type<PixelRef>::type,
0217 typename channel_type<PixelResult>::type
0218 >());
0219 return dst;
0220 }
0221 };
0222
0223 }}
0224
0225 #endif