title: OpenCV max possible value of a Mat type
body: <p>I want to find if there is a utility function or variable that outputs the maximum value a specific Mat type can take. For example, the maximum possible value of a CV_U8 is 255.</p>
  <h1>Example case</h1>
  <p>Matlab has a couple of built in functions which can take an image of arbitrary image type and convert it (with scaling if necessary) to another image type.</p>
  <p>For example, Matlab has the function <code>im2double</code>. Running <code>help im2double</code> shows:</p>
  <pre><code>Class Support
  -------------
  Intensity and truecolor images can be uint8, uint16, double, logical,
  single, or int16. Indexed images can be uint8, uint16, double or
  logical. Binary input images must be logical. The output image is double.
  </code></pre>
  <p>So it will run on 10 different image types, and outputs a double image with the same number of color channels, scaled by dividing the max allowable value in the original data type.</p>
  <p>Thus the OpenCV functions <code>convertTo()</code> and <code>normalize()</code> would be able to do the same thing if one was able to get the max value of the input data type and input it into those functions.</p>
  <p>In particular <code>convertTo(dst, type, scale)</code> would work identically if one could use <code>scale = 1/&lt;max_value_of_input_type&gt;</code> and <code>normalize(src, dst, alpha, beta, NORM_MINMAX)</code> would work with <code>alpha = &lt;src_min&gt;/&lt;max_value_of_input_type&gt;</code> and <code>beta = &lt;src_max&gt;/&lt;max_value_of_input_type&gt;</code>.</p>