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

Add arithmetic operators for float and double grayscale pixels #615

Open
sdebionne opened this issue Jun 10, 2021 · 0 comments
Open

Add arithmetic operators for float and double grayscale pixels #615

sdebionne opened this issue Jun 10, 2021 · 0 comments

Comments

@sdebionne
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I was surprised to see that arithmetic operations on pixel compiles but without explicit support from the library. pixels are actually implicitly converted to their underlying type.

Describe the solution you'd like

Provide a set of arithmetic operators, at least for pixel_gray32f_t and pixel_gray64f_t.

C++ Example

#include <type_traits>
#include <boost/gil/pixel.hpp>
using pixel_t = boost::gil::pixel<float, boost::gil::layout<boost::mp11::mp_list<boost::gil::gray_color_t> > >;
int main()
{
    pixel_t a(1.0f), b(2.0f);
    auto c = a + b;
    static_assert(std::is_same_v<std::decay_t<decltype(c)>, float>);   //OK , but is implicit conversion right?
    static_assert(std::is_same_v<std::decay_t<decltype(c)>, pixel_t>); //Fails, but should be OK?
    return 0;
}

Additional context

Discussed first on Slack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant