The value_type of a view is a pixel, not a channel. A pixel may contain more than one channel. Furthermore, in the case of heterogeneous views, the channels are of different types, and thus they may have different max values. So to be fully generic you need to specify the channel index.
What you need to do is get the channel type and use channel_traits<Channel>::max_value(). For homogeneous views:
x = channel_traits<typename channel_type<View>::type>::max_value();
Lubomir
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I got a small question. I got a view of type gray8_view_t. I want to get the maximum value that a pixel can have.
I tried std::numeric_limits<typename gray8_view_t::value_type>::max() butit returns 0. What is the right way of doing that ?
Thank you.
Hi,
The value_type of a view is a pixel, not a channel. A pixel may contain more than one channel. Furthermore, in the case of heterogeneous views, the channels are of different types, and thus they may have different max values. So to be fully generic you need to specify the channel index.
What you need to do is get the channel type and use channel_traits<Channel>::max_value(). For homogeneous views:
x = channel_traits<typename channel_type<View>::type>::max_value();
Lubomir
Thank you for your help.