Skip to content

Commit

Permalink
refactor: Unified operation names for pixel and channel operations (#655
Browse files Browse the repository at this point in the history
)

Renamed
- gil::pixel_multiply_t to gil::pixel_multiplies_t
- gil::pixel_divide_t to gil::pixel_divides_t

Closes #368
  • Loading branch information
marco-langer committed Apr 30, 2022
1 parent 9d526ed commit 3289fe0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
16 changes: 12 additions & 4 deletions include/boost/gil/pixel_numeric_operations.hpp
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
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
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

0 comments on commit 3289fe0

Please sign in to comment.