Skip to content

Commit

Permalink
Add delayed evaluation for image conversions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmhofmann committed Mar 7, 2019
1 parent 6377d49 commit f08a326
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 147 deletions.
1 change: 1 addition & 0 deletions selene/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ target_sources(selene_img_ops PRIVATE
${CMAKE_CURRENT_LIST_DIR}/img_ops/View.hpp
${CMAKE_CURRENT_LIST_DIR}/img_ops/_impl/FlipExpr.hpp
${CMAKE_CURRENT_LIST_DIR}/img_ops/_impl/IdentityExpr.hpp
${CMAKE_CURRENT_LIST_DIR}/img_ops/_impl/ImageConversionExpr.hpp
${CMAKE_CURRENT_LIST_DIR}/img_ops/_impl/TransposeExpr.hpp
)

Expand Down
18 changes: 18 additions & 0 deletions selene/img/pixel/Pixel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,24 @@ round(const Pixel<T, nr_channels_, pixel_format_>& px)

// -----

/** \brief Converts a pixel value into a character stream representation, e.g. for printing.
*
* @param os An output stream.
* @param px The pixel to be converted.
* @return A reference to the provided output stream.
*/
template <typename T, std::size_t nr_channels_, PixelFormat pixel_format_>
std::ostream& operator<<(std::ostream& os, const Pixel<T, nr_channels_, pixel_format_>& px)
{
os << '(';
for (auto c = std::size_t{0}; c < nr_channels_ - 1; ++c)
{
os << static_cast<promote_t<T>>(px[c]) << ", ";
}
os << static_cast<promote_t<T>>(px[nr_channels_ - 1]) << ')';
return os;
}

/** \brief Converts a pixel value into a character stream representation, e.g. for printing.
*
* @param os An output stream.
Expand Down
Loading

0 comments on commit f08a326

Please sign in to comment.