Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unified naming for pixel and channel operations #655

Merged
merged 1 commit into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions include/boost/gil/pixel_numeric_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace boost { namespace gil {
// List of currently defined functors:
// pixel_plus_t (+)
// pixel_minus_t (-)
// pixel_multiplies_scalar_t (*)
// pixel_divides_scalar_t (/)
// pixel_multiplies_scalar_t (*s)
// pixel_multiplies_t (*)
// pixel_divides_scalar_t (/s)
// pixel_divides_t (/)
// pixel_halves_t (/=2),
// pixel_zeros_t (=0)
// pixel_assigns_t (=)
Expand Down Expand Up @@ -97,7 +99,7 @@ struct pixel_multiplies_scalar_t
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
template <typename PixelRef1, typename PixelRef2, typename PixelResult>
struct pixel_multiply_t
struct pixel_multiplies_t
{
auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
{
Expand All @@ -113,6 +115,9 @@ struct pixel_multiply_t
}
};

template <typename PixelRef1, typename PixelRef2, typename PixelResult>
using pixel_multiply_t [[deprecated]] = pixel_multiplies_t<PixelRef1, PixelRef2, PixelResult>;

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise division of pixel elements by scalar.
/// \tparam PixelRef - models PixelConcept
Expand All @@ -139,7 +144,7 @@ struct pixel_divides_scalar_t
/// \tparam PixelRef2 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
template <typename PixelRef1, typename PixelRef2, typename PixelResult>
struct pixel_divide_t
struct pixel_divides_t
{
auto operator()(PixelRef1 const& p1, PixelRef2 const& p2) const -> PixelResult
{
Expand All @@ -155,6 +160,9 @@ struct pixel_divide_t
}
};

template <typename PixelRef1, typename PixelRef2, typename PixelResult>
using pixel_divide_t [[deprecated]] = pixel_divides_t<PixelRef1, PixelRef2, PixelResult>;

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise division by 2
/// \tparam PixelRef - models PixelConcept
Expand Down
4 changes: 2 additions & 2 deletions test/core/pixel/pixel_numeric_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct test_pixel_multiply_integer_same_types
{
using pixel_t = Pixel;
using channel_t = typename gil::channel_type<pixel_t>::type;
gil::pixel_multiply_t<pixel_t, pixel_t, pixel_t> f;
gil::pixel_multiplies_t<pixel_t, pixel_t, pixel_t> f;

pixel_t p0;
gil::static_fill(p0, static_cast<channel_t>(0));
Expand Down Expand Up @@ -190,7 +190,7 @@ struct test_pixel_divide_integer_same_types
{
using pixel_t = Pixel;
using channel_t = typename gil::channel_type<pixel_t>::type;
gil::pixel_divide_t<pixel_t, pixel_t, pixel_t> f;
gil::pixel_divides_t<pixel_t, pixel_t, pixel_t> f;

pixel_t p0;
gil::static_fill(p0, static_cast<channel_t>(0));
Expand Down
6 changes: 3 additions & 3 deletions test/core/pixel/pixel_numeric_operations_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void test_multiply()
gil::rgb32f_pixel_t a(1.f, 2.f, 3.f);
gil::bgr32f_pixel_t b(2.f, 2.f, 2.f);

gil::pixel_multiply_t<
gil::pixel_multiplies_t<
gil::rgb32f_pixel_t, gil::bgr32f_pixel_t, gil::rgb32f_pixel_t>
op;
gil::rgb32f_pixel_t c = op(a, b);
Expand All @@ -67,7 +67,7 @@ void test_divide()
gil::rgb8_pixel_t a(10, 20, 30);
gil::bgr8_pixel_t b(2, 2, 2);

gil::pixel_divide_t<gil::rgb8_pixel_t, gil::bgr8_pixel_t, gil::rgb32f_pixel_t> op;
gil::pixel_divides_t<gil::rgb8_pixel_t, gil::bgr8_pixel_t, gil::rgb32f_pixel_t> op;
gil::rgb32f_pixel_t c = op(a, b);

BOOST_TEST_EQ(get_color(c, gil::red_t()), 5);
Expand All @@ -80,7 +80,7 @@ void test_divide()
gil::rgb32f_pixel_t a(1.f, 2.f, 3.f);
gil::bgr32f_pixel_t b(2.f, 2.f, 2.f);

gil::pixel_divide_t<gil::rgb32f_pixel_t, gil::bgr32f_pixel_t, gil::rgb32f_pixel_t> op;
gil::pixel_divides_t<gil::rgb32f_pixel_t, gil::bgr32f_pixel_t, gil::rgb32f_pixel_t> op;
gil::rgb32f_pixel_t c = op(a, b);

float epsilon = 1e-6f;
Expand Down