Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / doc / html / reference / group___channel_convert_algorithm.html
1 <!-- HTML header for doxygen 1.8.13-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4   <head>
5     <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6     <meta http-equiv="X-UA-Compatible" content="IE=9"/>
7     <meta name="generator" content="Doxygen 1.8.15"/>
8     <meta name="viewport" content="width=device-width, initial-scale=1"/>
9     <title>Generic Image Library: channel_convert</title>
10     <link href="tabs.css" rel="stylesheet" type="text/css"/>
11     <script type="text/javascript" src="jquery.js"></script>
12     <script type="text/javascript" src="dynsections.js"></script>
13     <link href="doxygen.css" rel="stylesheet" type="text/css" />
14     <link href="doxygen-boost.css" rel="stylesheet" type="text/css"/>
15   </head>
16   <body>
17     <div class="boost-header">
18       <table border="0" cellpadding="7" cellspacing="0" width="100%" summary="header">
19         <tr>
20           <td valign="top" width="300">
21             <h3><a href="../index.html"><img alt="Boost GIL" src="../_static/gil.png" border="0"></a></h3>
22           </td>
23           <td ><h1 align="center"><a href="../index.html"></a></h1></td>
24           <td></td>
25         </tr>
26       </table>
27     </div>
28     <hr/>
29     <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
30 <!-- Generated by Doxygen 1.8.15 -->
31 <script type="text/javascript" src="menudata.js"></script>
32 <script type="text/javascript" src="menu.js"></script>
33 <script type="text/javascript">
34 /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
35 $(function() {
36   initMenu('',false,false,'search.php','Search');
37 });
38 /* @license-end */</script>
39 <div id="main-nav"></div>
40 </div><!-- top -->
41 <div class="header">
42   <div class="summary">
43 <a href="#groups">Modules</a> &#124;
44 <a href="#nested-classes">Classes</a> &#124;
45 <a href="#func-members">Functions</a>  </div>
46   <div class="headertitle">
47 <div class="title">channel_convert<div class="ingroups"><a class="el" href="group___channel.html">Channel</a> &raquo; <a class="el" href="group___channel_algorithm.html">Algorithms and Utility Functions</a></div></div>  </div>
48 </div><!--header-->
49 <div class="contents">
50
51 <p>Converting from one channel type to anotherConversion is done as a simple linear mapping of one channel range to the other, such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination. One implication of this is that the value 0 of signed channels may not be preserved!  
52 <a href="#details">More...</a></p>
53 <table class="memberdecls">
54 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
55 Modules</h2></td></tr>
56 <tr class="memitem:group___channel_convert_unsigned_algorithm"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___channel_convert_unsigned_algorithm.html">channel_converter_unsigned</a></td></tr>
57 <tr class="memdesc:group___channel_convert_unsigned_algorithm"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert one unsigned/floating point channel to another. Converts both the channel type and range. <br /></td></tr>
58 <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
59 </table><table class="memberdecls">
60 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
61 Classes</h2></td></tr>
62 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1gil_1_1channel__converter.html">channel_converter&lt; SrcChannelV, DstChannelV &gt;</a></td></tr>
63 <tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">A unary function object converting between channel types.  <a href="structboost_1_1gil_1_1channel__converter.html#details">More...</a><br /></td></tr>
64 <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
65 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1gil_1_1default__channel__converter.html">default_channel_converter</a></td></tr>
66 <tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Same as <a class="el" href="structboost_1_1gil_1_1channel__converter.html" title="A unary function object converting between channel types.">channel_converter</a>, except it takes the destination channel by reference, which allows us to move the templates from the class level to the method level. This is important when invoking it on heterogeneous pixels.  <a href="structboost_1_1gil_1_1default__channel__converter.html#details">More...</a><br /></td></tr>
67 <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
68 </table><table class="memberdecls">
69 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
70 Functions</h2></td></tr>
71 <tr class="memitem:ga1ca10b1d27bc2f2ce4906b8890e613a5"><td class="memTemplParams" colspan="2"><a id="ga1ca10b1d27bc2f2ce4906b8890e613a5"></a>
72 template&lt;typename DstChannel , typename SrcChannel &gt; </td></tr>
73 <tr class="memitem:ga1ca10b1d27bc2f2ce4906b8890e613a5"><td class="memTemplItemLeft" align="right" valign="top">channel_traits&lt; DstChannel &gt;::value_type&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group___channel_convert_algorithm.html#ga1ca10b1d27bc2f2ce4906b8890e613a5">channel_convert</a> (const SrcChannel &amp;src)</td></tr>
74 <tr class="memdesc:ga1ca10b1d27bc2f2ce4906b8890e613a5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Converting from one channel type to another. <br /></td></tr>
75 <tr class="separator:ga1ca10b1d27bc2f2ce4906b8890e613a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
76 </table>
77 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
78 <p>Converting from one channel type to another</p>
79 <p>Conversion is done as a simple linear mapping of one channel range to the other, such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination. One implication of this is that the value 0 of signed channels may not be preserved! </p>
80 <p>When creating new channel models, it is often a good idea to provide specializations for the channel conversion algorithms, for example, for performance optimizations. If the new model is an integral type that can be signed, it is easier to define the conversion only for the unsigned type (<code>channel_converter_unsigned</code>) and provide specializations of <code>detail::channel_convert_to_unsigned</code> and <code>detail::channel_convert_from_unsigned</code> to convert between the signed and unsigned type.</p>
81 <p>Example: </p><div class="fragment"><div class="line"><span class="comment">// float32_t is a floating point channel with range [0.0f ... 1.0f]</span></div><div class="line"><a class="code" href="group___channel_model.html#gaa70e2f51d4342cd54a28684f20c6135b">float32_t</a> src_channel = channel_traits&lt;float32_t&gt;::max_value();</div><div class="line">assert(src_channel == 1);</div><div class="line"></div><div class="line"><span class="comment">// uint8_t is 8-bit unsigned integral channel (aliased from unsigned char)</span></div><div class="line">uint8_t dst_channel = channel_convert&lt;uint8_t&gt;(src_channel);</div><div class="line">assert(dst_channel == 255);     <span class="comment">// max value goes to max value</span></div></div><!-- fragment --> </div><!-- contents -->
82      <!-- HTML footer for doxygen 1.8.13-->
83      <!-- start footer part -->
84      <hr class="footer"/>
85      <address class="footer">
86       <small>
87         Generated by &#160;<a href="http://www.doxygen.org/index.html">doxygen</a> 1.8.15
88       </small>
89     </address>
90   </body>
91 </html>