Skip to content

Commit

Permalink
numeric extension move into core part 4
Browse files Browse the repository at this point in the history
moved numeric/pixel_numeric_operations.hpp into core
  • Loading branch information
lpranam committed Feb 18, 2022
1 parent 483915c commit 87a3157
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 215 deletions.
3 changes: 1 addition & 2 deletions include/boost/gil/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#ifndef BOOST_GIL_ALGORITHM_HPP
#define BOOST_GIL_ALGORITHM_HPP

#include <boost/gil/extension/numeric/pixel_numeric_operations.hpp>

#include <boost/gil/metafunctions.hpp>
#include <boost/gil/pixel_iterator.hpp>
#include <boost/gil/pixel_numeric_operations.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/bit_aligned_pixel_iterator.hpp>
#include <boost/gil/color_base_algorithm.hpp>
Expand Down
206 changes: 2 additions & 204 deletions include/boost/gil/extension/numeric/pixel_numeric_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,210 +9,8 @@
#ifndef BOOST_GIL_EXTENSION_NUMERIC_PIXEL_NUMERIC_OPERATIONS_HPP
#define BOOST_GIL_EXTENSION_NUMERIC_PIXEL_NUMERIC_OPERATIONS_HPP

#include <boost/gil/channel_numeric_operations.hpp>
#include <boost/config/header_deprecated.hpp>

#include <boost/gil/color_base_algorithm.hpp>
#include <boost/gil/pixel.hpp>

namespace boost { namespace gil {

// Function objects and utilities for pixel-wise numeric operations.
//
// List of currently defined functors:
// pixel_plus_t (+)
// pixel_minus_t (-)
// pixel_multiplies_scalar_t (*)
// pixel_divides_scalar_t (/)
// pixel_halves_t (/=2),
// pixel_zeros_t (=0)
// pixel_assigns_t (=)

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise addition of two pixels.
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelRef2 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise subtraction of two pixels.
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelRef2 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise multiplication of pixel elements by scalar.
/// \tparam PixelRef - models PixelConcept
/// \tparam Scalar - models a scalar type
/// \tparam PixelResult - models PixelValueConcept
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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise multiplication of two pixels.
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
template <typename PixelRef1, typename PixelRef2, typename PixelResult>
struct pixel_multiply_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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise division of pixel elements by scalar.
/// \tparam PixelRef - models PixelConcept
/// \tparam Scalar - models a scalar type
/// \tparam PixelResult - models PixelValueConcept
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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise division of two pixels.
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelRef1 - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
template <typename PixelRef1, typename PixelRef2, typename PixelResult>
struct pixel_divide_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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Performs channel-wise division by 2
/// \tparam PixelRef - models PixelConcept
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;
}
};

/// \ingroup PixelNumericOperations
/// \brief Sets pixel elements to zero (for whatever zero means)
/// \tparam PixelRef - models PixelConcept
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;
}
};

/// \brief Sets pixel elements to zero (for whatever zero means)
/// \tparam Pixel - models PixelConcept
template <typename Pixel>
void zero_channels(Pixel& p)
{
static_for_each(p, channel_zeros_t<typename channel_type<Pixel>::type>());
}

/// \ingroup PixelNumericOperations
/// \brief Casts and assigns a pixel to another
///
/// A generic implementation for casting and assigning a pixel to another.
/// User should specialize it for better performance.
///
/// \tparam PixelRef - models PixelConcept
/// \tparam PixelResult - models PixelValueConcept
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;
}
};

}} // namespace boost::gil
BOOST_HEADER_DEPRECATED("<boost/gil/pixel_numeric_operations.hpp>")

#endif
3 changes: 2 additions & 1 deletion include/boost/gil/extension/numeric/sampler.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright 2005-2007 Adobe Systems Incorporated
// Copyright 2021 Pranam Lashkari <plashkari628@gmail.com>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
Expand All @@ -8,8 +9,8 @@
#ifndef BOOST_GIL_EXTENSION_NUMERIC_SAMPLER_HPP
#define BOOST_GIL_EXTENSION_NUMERIC_SAMPLER_HPP

#include <boost/gil/extension/numeric/pixel_numeric_operations.hpp>
#include <boost/gil/extension/dynamic_image/dynamic_image_all.hpp>
#include <boost/gil/pixel_numeric_operations.hpp>

namespace boost { namespace gil {

Expand Down
2 changes: 1 addition & 1 deletion include/boost/gil/image_processing/convolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#define BOOST_GIL_IMAGE_PROCESSING_CONVOLVE_HPP

#include <boost/gil/extension/numeric/kernel.hpp>
#include <boost/gil/extension/numeric/pixel_numeric_operations.hpp>

#include <boost/gil/algorithm.hpp>
#include <boost/gil/image_view_factory.hpp>
#include <boost/gil/metafunctions.hpp>
#include <boost/gil/pixel_numeric_operations.hpp>

#include <boost/assert.hpp>

Expand Down
Loading

0 comments on commit 87a3157

Please sign in to comment.