Menu

How to get pixel type

2007-10-24
2013-04-29
  • Simon Rodrigue

    Simon Rodrigue - 2007-10-24

    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.

     
    • Lubomir Bourdev

      Lubomir Bourdev - 2007-10-25

      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

       
      • Simon Rodrigue

        Simon Rodrigue - 2007-10-25

        Thank you for your help.

         

Log in to post a comment.

MongoDB Logo MongoDB