PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/gil/doc/html/g_i_l_0226.html

http://hadesmem.googlecode.com/
HTML | 478 lines | 459 code | 3 blank | 16 comment | 0 complexity | 419f4a4ac8b3f32df45b944c9f346b12 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.0, Apache-2.0, LGPL-3.0
  1. <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. -->
  6. <!--
  7. Copyright 2005-2007 Adobe Systems Incorporated
  8. Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
  9. or a copy at http://stlab.adobe.com/licenses.html)
  10. Some files are held under additional license.
  11. Please see "http://stlab.adobe.com/licenses.html" for more information.
  12. -->
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  14. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  15. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  16. <head>
  17. <TITLE>Generic Image Library: image_view_factory.hpp Source File</TITLE>
  18. <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/>
  19. <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/>
  20. </head>
  21. <body>
  22. <table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr>
  23. <td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'>
  24. <div class="qindex"><a class="qindex" href="index.html">Modules</a>
  25. | <a class="qindex" href="classes.html">Alphabetical List</a>
  26. | <a class="qindex" href="annotated.html">Class List</a>
  27. | <a class="qindex" href="dirs.html">Directories</a>
  28. | <a class="qindex" href="files.html">File List</a>
  29. | <a class="qindex" href="../index.html">GIL Home Page</a>
  30. </div>
  31. <!-- End Header -->
  32. <!-- Generated by Doxygen 1.5.6 -->
  33. <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0079.html">gil</a>
  34. </div>
  35. <div class="contents">
  36. <h1>image_view_factory.hpp</h1><a href="g_i_l_0227.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
  37. <a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span>
  38. <a name="l00003"></a>00003 <span class="comment"> </span>
  39. <a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span>
  40. <a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
  41. <a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span>
  42. <a name="l00007"></a>00007 <span class="comment"></span>
  43. <a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span>
  44. <a name="l00009"></a>00009 <span class="comment">*/</span>
  45. <a name="l00010"></a>00010
  46. <a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span>
  47. <a name="l00012"></a>00012
  48. <a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_IMAGE_VIEW_FACTORY_HPP</span>
  49. <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_IMAGE_VIEW_FACTORY_HPP</span>
  50. <a name="l00015"></a>00015 <span class="preprocessor"></span>
  51. <a name="l00025"></a>00025
  52. <a name="l00027"></a>00027 <span class="preprocessor">#include &lt;cassert&gt;</span>
  53. <a name="l00028"></a>00028 <span class="preprocessor">#include &lt;cstddef&gt;</span>
  54. <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="g_i_l_0094.html" title="GIL configuration file.">gil_config.hpp</a>"</span>
  55. <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="g_i_l_0238.html" title="metafunctions that construct types or return type properties">metafunctions.hpp</a>"</span>
  56. <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="gray_8hpp.html" title="Support for grayscale color space and variants.">gray.hpp</a>"</span>
  57. <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="g_i_l_0071.html" title="GIL default color space conversions.">color_convert.hpp</a>"</span>
  58. <a name="l00033"></a>00033
  59. <a name="l00037"></a>00037
  60. <a name="l00041"></a>00041
  61. <a name="l00042"></a>00042 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
  62. <a name="l00043"></a>00043 <span class="keyword">struct </span>default_color_converter;
  63. <a name="l00044"></a>00044
  64. <a name="l00045"></a>00045 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">struct </span>dynamic_x_step_type;
  65. <a name="l00046"></a>00046 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">struct </span>dynamic_y_step_type;
  66. <a name="l00047"></a>00047 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">struct </span>transposed_type;
  67. <a name="l00048"></a>00048
  68. <a name="l00051"></a>00051 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  69. <a name="l00052"></a><a class="code" href="g_i_l_0532.html">00052</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0532.html" title="Returns the type of a view that has a dynamic step along both X and Y.">dynamic_xy_step_type</a> : <span class="keyword">public</span> dynamic_y_step_type&lt;typename dynamic_x_step_type&lt;View&gt;::type&gt; {};
  70. <a name="l00053"></a>00053
  71. <a name="l00056"></a>00056 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  72. <a name="l00057"></a><a class="code" href="g_i_l_0531.html">00057</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0531.html" title="Returns the type of a transposed view that has a dynamic step along both X and Y...">dynamic_xy_step_transposed_type</a> : <span class="keyword">public</span> <a class="code" href="g_i_l_0532.html" title="Returns the type of a view that has a dynamic step along both X and Y.">dynamic_xy_step_type</a>&lt;typename transposed_type&lt;View&gt;::type&gt; {};
  73. <a name="l00058"></a>00058
  74. <a name="l00059"></a>00059
  75. <a name="l00062"></a>00062 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Iterator&gt;
  76. <a name="l00063"></a>00063 <span class="keyword">typename</span> <a class="code" href="g_i_l_0627.html" title="Given a pixel iterator defining access to pixels along a row, returns the types of...">type_from_x_iterator&lt;Iterator&gt;::view_t</a>
  77. <a name="l00064"></a><a class="code" href="g_i_l_0140.html#g258d615c33c66b17c85b018297164df1">00064</a> <a class="code" href="g_i_l_0140.html#g558c29855a5b73404d4d21f22832a624" title="Constructing image views from raw interleaved pixel data.">interleaved_view</a>(std::size_t width, std::size_t height,
  78. <a name="l00065"></a>00065 Iterator pixels, std::ptrdiff_t rowsize_in_bytes) {
  79. <a name="l00066"></a>00066 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0627.html" title="Given a pixel iterator defining access to pixels along a row, returns the types of...">type_from_x_iterator&lt;Iterator&gt;::view_t</a> RView;
  80. <a name="l00067"></a>00067 <span class="keywordflow">return</span> RView(width, height, <span class="keyword">typename</span> RView::locator(pixels, rowsize_in_bytes));
  81. <a name="l00068"></a>00068 }
  82. <a name="l00069"></a>00069
  83. <a name="l00072"></a>00072 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Iterator&gt;
  84. <a name="l00073"></a>00073 <span class="keyword">typename</span> type_from_x_iterator&lt;Iterator&gt;::view_t
  85. <a name="l00074"></a><a class="code" href="g_i_l_0140.html#g558c29855a5b73404d4d21f22832a624">00074</a> <a class="code" href="g_i_l_0140.html#g558c29855a5b73404d4d21f22832a624" title="Constructing image views from raw interleaved pixel data.">interleaved_view</a>(<a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;std::size_t&gt;</a> dim,
  86. <a name="l00075"></a>00075 Iterator pixels, std::ptrdiff_t rowsize_in_bytes) {
  87. <a name="l00076"></a>00076 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0627.html" title="Given a pixel iterator defining access to pixels along a row, returns the types of...">type_from_x_iterator&lt;Iterator&gt;::view_t</a> RView;
  88. <a name="l00077"></a>00077 <span class="keywordflow">return</span> RView(dim, <span class="keyword">typename</span> RView::locator(pixels, rowsize_in_bytes));
  89. <a name="l00078"></a>00078 }
  90. <a name="l00079"></a>00079
  91. <a name="l00081"></a>00081 <span class="comment">// interleaved_view_get_raw_data, planar_view_get_raw_data - return pointers to the raw data (the channels) of a basic homogeneous view.</span>
  92. <a name="l00083"></a>00083 <span class="comment"></span>
  93. <a name="l00084"></a>00084 <span class="keyword">namespace </span>detail {
  94. <a name="l00085"></a>00085 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keywordtype">bool</span> IsMutable&gt; <span class="keyword">struct </span>channel_pointer_type_impl;
  95. <a name="l00086"></a>00086
  96. <a name="l00087"></a>00087 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>channel_pointer_type_impl&lt;View, true&gt; {
  97. <a name="l00088"></a>00088 <span class="keyword">typedef</span> <span class="keyword">typename</span> channel_type&lt;View&gt;::type* type;
  98. <a name="l00089"></a>00089 };
  99. <a name="l00090"></a>00090 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>channel_pointer_type_impl&lt;View, false&gt; {
  100. <a name="l00091"></a>00091 <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="keyword">typename</span> channel_type&lt;View&gt;::type* type;
  101. <a name="l00092"></a>00092 };
  102. <a name="l00093"></a>00093
  103. <a name="l00094"></a>00094 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>channel_pointer_type
  104. <a name="l00095"></a>00095 : <span class="keyword">public</span> channel_pointer_type_impl&lt;View, view_is_mutable&lt;View&gt;::value&gt; {};
  105. <a name="l00096"></a>00096 } <span class="comment">// namespace detail</span>
  106. <a name="l00097"></a>00097
  107. <a name="l00100"></a>00100 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> HomogeneousView&gt;
  108. <a name="l00101"></a><a class="code" href="g_i_l_0140.html#g01d2b0e1eb77cd5cafb18f4140278918">00101</a> <span class="keyword">typename</span> detail::channel_pointer_type&lt;HomogeneousView&gt;::type <a class="code" href="g_i_l_0140.html#g01d2b0e1eb77cd5cafb18f4140278918" title="Returns C pointer to the the channels of an interleaved homogeneous view.">interleaved_view_get_raw_data</a>(<span class="keyword">const</span> HomogeneousView&amp; <a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>) {
  109. <a name="l00102"></a>00102 BOOST_STATIC_ASSERT((!is_planar&lt;HomogeneousView&gt;::value &amp;&amp; <a class="code" href="g_i_l_0628.html" title="Basic views must be over basic locators.">view_is_basic&lt;HomogeneousView&gt;::value</a>));
  110. <a name="l00103"></a>00103 BOOST_STATIC_ASSERT((boost::is_pointer&lt;typename HomogeneousView::x_iterator&gt;::value));
  111. <a name="l00104"></a>00104
  112. <a name="l00105"></a>00105 <span class="keywordflow">return</span> &amp;at_c&lt;0&gt;(<a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>(0,0));
  113. <a name="l00106"></a>00106 }
  114. <a name="l00107"></a>00107
  115. <a name="l00110"></a>00110 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> HomogeneousView&gt;
  116. <a name="l00111"></a><a class="code" href="g_i_l_0140.html#ga696176662e719ef5637c2ed4d9a2035">00111</a> <span class="keyword">typename</span> detail::channel_pointer_type&lt;HomogeneousView&gt;::type <a class="code" href="g_i_l_0140.html#ga696176662e719ef5637c2ed4d9a2035" title="Returns C pointer to the the channels of a given color plane of a planar homogeneous...">planar_view_get_raw_data</a>(<span class="keyword">const</span> HomogeneousView&amp; <a class="code" href="g_i_l_0135.html#g55e45a15dddfc0d870c2f7fb9739cb2e" title="Returns the non-constant-pixel view of any image. The returned view is any view.">view</a>, <span class="keywordtype">int</span> plane_index) {
  117. <a name="l00112"></a>00112 BOOST_STATIC_ASSERT((is_planar&lt;HomogeneousView&gt;::value &amp;&amp; <a class="code" href="g_i_l_0628.html" title="Basic views must be over basic locators.">view_is_basic&lt;HomogeneousView&gt;::value</a>));
  118. <a name="l00113"></a>00113 <span class="keywordflow">return</span> dynamic_at_c(view.row_begin(0),plane_index);
  119. <a name="l00114"></a>00114 }
  120. <a name="l00115"></a>00115
  121. <a name="l00116"></a>00116
  122. <a name="l00120"></a>00120
  123. <a name="l00125"></a>00125 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcConstRefP, <span class="keyword">typename</span> DstP, <span class="keyword">typename</span> CC=default_color_converter &gt; <span class="comment">// const_reference to the source pixel and destination pixel value</span>
  124. <a name="l00126"></a><a class="code" href="g_i_l_0022.html">00126</a> <span class="keyword">class </span><a class="code" href="g_i_l_0022.html" title="Function object that given a source pixel, returns it converted to a given color...">color_convert_deref_fn</a> : <span class="keyword">public</span> <a class="code" href="g_i_l_0475.html" title="Helper base class for pixel dereference adaptors.">deref_base</a>&lt;color_convert_deref_fn&lt;SrcConstRefP,DstP,CC&gt;, DstP, DstP, const DstP&amp;, SrcConstRefP, DstP, false&gt; {
  125. <a name="l00127"></a>00127 <span class="keyword">private</span>:
  126. <a name="l00128"></a>00128 CC _cc; <span class="comment">// color-converter</span>
  127. <a name="l00129"></a>00129 <span class="keyword">public</span>:
  128. <a name="l00130"></a>00130 <a class="code" href="g_i_l_0022.html" title="Function object that given a source pixel, returns it converted to a given color...">color_convert_deref_fn</a>() {}
  129. <a name="l00131"></a>00131 <a class="code" href="g_i_l_0022.html" title="Function object that given a source pixel, returns it converted to a given color...">color_convert_deref_fn</a>(CC cc_in) : _cc(cc_in) {}
  130. <a name="l00132"></a>00132
  131. <a name="l00133"></a>00133 DstP operator()(SrcConstRefP srcP)<span class="keyword"> const </span>{
  132. <a name="l00134"></a>00134 DstP dstP;
  133. <a name="l00135"></a>00135 _cc(srcP,dstP);
  134. <a name="l00136"></a>00136 <span class="keywordflow">return</span> dstP;
  135. <a name="l00137"></a>00137 }
  136. <a name="l00138"></a>00138 };
  137. <a name="l00139"></a>00139
  138. <a name="l00140"></a>00140 <span class="keyword">namespace </span>detail {
  139. <a name="l00141"></a>00141 <span class="comment">// Add color converter upon dereferencing</span>
  140. <a name="l00142"></a>00142 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcView, <span class="keyword">typename</span> CC, <span class="keyword">typename</span> DstP, <span class="keyword">typename</span> SrcP&gt;
  141. <a name="l00143"></a>00143 <span class="keyword">struct </span>_color_converted_view_type {
  142. <a name="l00144"></a>00144 <span class="keyword">private</span>:
  143. <a name="l00145"></a>00145 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0022.html" title="Function object that given a source pixel, returns it converted to a given color...">color_convert_deref_fn&lt;typename SrcView::const_t::reference,DstP,CC&gt;</a> deref_t;
  144. <a name="l00146"></a>00146 <span class="keyword">typedef</span> <span class="keyword">typename</span> SrcView::template add_deref&lt;deref_t&gt; add_ref_t;
  145. <a name="l00147"></a>00147 <span class="keyword">public</span>:
  146. <a name="l00148"></a>00148 <span class="keyword">typedef</span> <span class="keyword">typename</span> add_ref_t::type type;
  147. <a name="l00149"></a>00149 <span class="keyword">static</span> type make(<span class="keyword">const</span> SrcView&amp; sv,CC cc) {<span class="keywordflow">return</span> add_ref_t::make(sv,deref_t(cc));}
  148. <a name="l00150"></a>00150 };
  149. <a name="l00151"></a>00151
  150. <a name="l00152"></a>00152 <span class="comment">// If the Src view has the same pixel type as the target, there is no need for color conversion</span>
  151. <a name="l00153"></a>00153 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcView, <span class="keyword">typename</span> CC, <span class="keyword">typename</span> DstP&gt;
  152. <a name="l00154"></a>00154 <span class="keyword">struct </span>_color_converted_view_type&lt;SrcView,CC,DstP,DstP&gt; {
  153. <a name="l00155"></a>00155 <span class="keyword">typedef</span> SrcView type;
  154. <a name="l00156"></a>00156 <span class="keyword">static</span> type make(<span class="keyword">const</span> SrcView&amp; sv,CC) {<span class="keywordflow">return</span> sv;}
  155. <a name="l00157"></a>00157 };
  156. <a name="l00158"></a>00158 } <span class="comment">// namespace detail</span>
  157. <a name="l00159"></a>00159
  158. <a name="l00160"></a>00160
  159. <a name="l00163"></a>00163 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcView, <span class="keyword">typename</span> DstP, <span class="keyword">typename</span> CC=default_color_converter&gt;
  160. <a name="l00164"></a><a class="code" href="g_i_l_0434.html">00164</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0434.html" title="Returns the type of a view that does color conversion upon dereferencing its pixels...">color_converted_view_type</a> : <span class="keyword">public</span> detail::_color_converted_view_type&lt;SrcView,
  161. <a name="l00165"></a>00165 CC,
  162. <a name="l00166"></a>00166 DstP,
  163. <a name="l00167"></a>00167 typename SrcView::value_type&gt; {
  164. <a name="l00168"></a>00168 GIL_CLASS_REQUIRE(DstP, boost::gil, <a class="code" href="g_i_l_0328.html" title="Pixel concept that allows for changing its channels.">MutablePixelConcept</a>)<span class="comment">//why does it have to be mutable???</span>
  165. <a name="l00169"></a>00169 };
  166. <a name="l00170"></a>00170
  167. <a name="l00171"></a>00171
  168. <a name="l00174"></a>00174 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> DstP, <span class="keyword">typename</span> View, <span class="keyword">typename</span> CC&gt;
  169. <a name="l00175"></a><a class="code" href="g_i_l_0161.html#gb5114cdb6c2a34f6706952f80baf2dfa">00175</a> <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0434.html" title="Returns the type of a view that does color conversion upon dereferencing its pixels...">color_converted_view_type&lt;View,DstP,CC&gt;::type</a> <a class="code" href="g_i_l_0161.html#g4e84970128101b572125f025dc81f8e0" title="overload of generic color_converted_view with the default color-converter">color_converted_view</a>(<span class="keyword">const</span> View&amp; src,CC cc) {
  170. <a name="l00176"></a>00176 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0434.html" title="Returns the type of a view that does color conversion upon dereferencing its pixels...">color_converted_view_type&lt;View,DstP,CC&gt;::make</a>(src,cc);
  171. <a name="l00177"></a>00177 }
  172. <a name="l00178"></a>00178
  173. <a name="l00181"></a>00181 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> DstP, <span class="keyword">typename</span> View&gt;
  174. <a name="l00182"></a>00182 <span class="keyword">inline</span> <span class="keyword">typename</span> color_converted_view_type&lt;View,DstP&gt;::type
  175. <a name="l00183"></a><a class="code" href="g_i_l_0161.html#gf2cd4971200b4e54dd2fda3cb9e24d0f">00183</a> <a class="code" href="g_i_l_0161.html#g4e84970128101b572125f025dc81f8e0" title="overload of generic color_converted_view with the default color-converter">color_converted_view</a>(<span class="keyword">const</span> View&amp; src) {
  176. <a name="l00184"></a>00184 <span class="keywordflow">return</span> color_converted_view&lt;DstP&gt;(src,<a class="code" href="g_i_l_0452.html" title="class for color-converting one pixel to another">default_color_converter</a>());
  177. <a name="l00185"></a>00185 }
  178. <a name="l00186"></a>00186
  179. <a name="l00190"></a>00190
  180. <a name="l00192"></a>00192 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  181. <a name="l00193"></a>00193 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_y_step_type&lt;View&gt;::type flipped_up_down_view(<span class="keyword">const</span> View&amp; src) {
  182. <a name="l00194"></a>00194 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_y_step_type&lt;View&gt;::type RView;
  183. <a name="l00195"></a>00195 <span class="keywordflow">return</span> RView(src.dimensions(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(0,src.height()-1),-1));
  184. <a name="l00196"></a>00196 }
  185. <a name="l00197"></a>00197
  186. <a name="l00201"></a>00201
  187. <a name="l00203"></a>00203 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  188. <a name="l00204"></a>00204 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_x_step_type&lt;View&gt;::type flipped_left_right_view(<span class="keyword">const</span> View&amp; src) {
  189. <a name="l00205"></a>00205 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_x_step_type&lt;View&gt;::type RView;
  190. <a name="l00206"></a>00206 <span class="keywordflow">return</span> RView(src.dimensions(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(src.width()-1,0),-1,1));
  191. <a name="l00207"></a>00207 }
  192. <a name="l00208"></a>00208
  193. <a name="l00212"></a>00212
  194. <a name="l00214"></a>00214 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  195. <a name="l00215"></a>00215 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type transposed_view(<span class="keyword">const</span> View&amp; src) {
  196. <a name="l00216"></a>00216 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type RView;
  197. <a name="l00217"></a>00217 <span class="keywordflow">return</span> RView(src.height(),src.width(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(0,0),1,1,<span class="keyword">true</span>));
  198. <a name="l00218"></a>00218 }
  199. <a name="l00219"></a>00219
  200. <a name="l00223"></a>00223
  201. <a name="l00225"></a>00225 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  202. <a name="l00226"></a>00226 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type rotated90cw_view(<span class="keyword">const</span> View&amp; src) {
  203. <a name="l00227"></a>00227 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type RView;
  204. <a name="l00228"></a>00228 <span class="keywordflow">return</span> RView(src.height(),src.width(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(0,src.height()-1),-1,1,<span class="keyword">true</span>));
  205. <a name="l00229"></a>00229 }
  206. <a name="l00230"></a>00230
  207. <a name="l00234"></a>00234
  208. <a name="l00236"></a>00236 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  209. <a name="l00237"></a>00237 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type rotated90ccw_view(<span class="keyword">const</span> View&amp; src) {
  210. <a name="l00238"></a>00238 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_xy_step_transposed_type&lt;View&gt;::type RView;
  211. <a name="l00239"></a>00239 <span class="keywordflow">return</span> RView(src.height(),src.width(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(src.width()-1,0),1,-1,<span class="keyword">true</span>));
  212. <a name="l00240"></a>00240 }
  213. <a name="l00241"></a>00241
  214. <a name="l00245"></a>00245
  215. <a name="l00247"></a>00247 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  216. <a name="l00248"></a>00248 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_type&lt;View&gt;::type rotated180_view(<span class="keyword">const</span> View&amp; src) {
  217. <a name="l00249"></a>00249 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_xy_step_type&lt;View&gt;::type RView;
  218. <a name="l00250"></a>00250 <span class="keywordflow">return</span> RView(src.dimensions(),<span class="keyword">typename</span> RView::xy_locator(src.xy_at(src.width()-1,src.height()-1),-1,-1));
  219. <a name="l00251"></a>00251 }
  220. <a name="l00252"></a>00252
  221. <a name="l00256"></a>00256
  222. <a name="l00258"></a>00258 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  223. <a name="l00259"></a>00259 <span class="keyword">inline</span> View subimage_view(<span class="keyword">const</span> View&amp; src, <span class="keyword">const</span> <span class="keyword">typename</span> View::point_t&amp; topleft, <span class="keyword">const</span> <span class="keyword">typename</span> View::point_t&amp; dimensions) {
  224. <a name="l00260"></a>00260 <span class="keywordflow">return</span> View(dimensions,src.xy_at(topleft));
  225. <a name="l00261"></a>00261 }
  226. <a name="l00262"></a>00262
  227. <a name="l00264"></a>00264 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  228. <a name="l00265"></a>00265 <span class="keyword">inline</span> View subimage_view(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> xMin, <span class="keywordtype">int</span> yMin, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height) {
  229. <a name="l00266"></a>00266 <span class="keywordflow">return</span> View(width,height,src.xy_at(xMin,yMin));
  230. <a name="l00267"></a>00267 }
  231. <a name="l00268"></a>00268
  232. <a name="l00272"></a>00272
  233. <a name="l00274"></a>00274 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  234. <a name="l00275"></a>00275 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_type&lt;View&gt;::type subsampled_view(<span class="keyword">const</span> View&amp; src, <span class="keyword">typename</span> View::coord_t xStep, <span class="keyword">typename</span> View::coord_t yStep) {
  235. <a name="l00276"></a>00276 assert(xStep&gt;0 &amp;&amp; yStep&gt;0);
  236. <a name="l00277"></a>00277 <span class="keyword">typedef</span> <span class="keyword">typename</span> dynamic_xy_step_type&lt;View&gt;::type RView;
  237. <a name="l00278"></a>00278 <span class="keywordflow">return</span> RView((src.width()+(xStep-1))/xStep,(src.height()+(yStep-1))/yStep,
  238. <a name="l00279"></a>00279 <span class="keyword">typename</span> RView::xy_locator(src.xy_at(0,0),xStep,yStep));
  239. <a name="l00280"></a>00280 }
  240. <a name="l00281"></a>00281
  241. <a name="l00283"></a>00283 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  242. <a name="l00284"></a>00284 <span class="keyword">inline</span> <span class="keyword">typename</span> dynamic_xy_step_type&lt;View&gt;::type subsampled_view(<span class="keyword">const</span> View&amp; src, <span class="keyword">const</span> <span class="keyword">typename</span> View::point_t&amp; step) {
  243. <a name="l00285"></a>00285 <span class="keywordflow">return</span> subsampled_view(src,step.x,step.y);
  244. <a name="l00286"></a>00286 }
  245. <a name="l00287"></a>00287
  246. <a name="l00291"></a>00291
  247. <a name="l00292"></a>00292 <span class="keyword">namespace </span>detail {
  248. <a name="l00293"></a>00293 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keywordtype">bool</span> AreChannelsTogether&gt; <span class="keyword">struct </span>__nth_channel_view_basic;
  249. <a name="l00294"></a>00294
  250. <a name="l00295"></a>00295 <span class="comment">// nth_channel_view when the channels are not adjacent in memory. This can happen for multi-channel interleaved images </span>
  251. <a name="l00296"></a>00296 <span class="comment">// or images with a step</span>
  252. <a name="l00297"></a>00297 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  253. <a name="l00298"></a>00298 <span class="keyword">struct </span>__nth_channel_view_basic&lt;View,false&gt; {
  254. <a name="l00299"></a>00299 <span class="keyword">typedef</span> <span class="keyword">typename</span> view_type&lt;typename channel_type&lt;View&gt;::type, gray_layout_t, <span class="keyword">false</span>, <span class="keyword">true</span>, view_is_mutable&lt;View&gt;::value&gt;::type type;
  255. <a name="l00300"></a>00300
  256. <a name="l00301"></a>00301 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) {
  257. <a name="l00302"></a>00302 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::xy_locator locator_t;
  258. <a name="l00303"></a>00303 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::x_iterator x_iterator_t;
  259. <a name="l00304"></a>00304 <span class="keyword">typedef</span> <span class="keyword">typename</span> iterator_adaptor_get_base&lt;x_iterator_t&gt;::type x_iterator_base_t;
  260. <a name="l00305"></a>00305 x_iterator_t sit(x_iterator_base_t(&amp;(src(0,0)[n])),src.pixels().pixel_size());
  261. <a name="l00306"></a>00306 <span class="keywordflow">return</span> type(src.dimensions(),locator_t(sit, src.pixels().row_size()));
  262. <a name="l00307"></a>00307 }
  263. <a name="l00308"></a>00308 };
  264. <a name="l00309"></a>00309
  265. <a name="l00310"></a>00310 <span class="comment">// nth_channel_view when the channels are together in memory (true for simple grayscale or planar images)</span>
  266. <a name="l00311"></a>00311 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  267. <a name="l00312"></a>00312 <span class="keyword">struct </span>__nth_channel_view_basic&lt;View,true&gt; {
  268. <a name="l00313"></a>00313 <span class="keyword">typedef</span> <span class="keyword">typename</span> view_type&lt;typename channel_type&lt;View&gt;::type, gray_layout_t, <span class="keyword">false</span>, <span class="keyword">false</span>, view_is_mutable&lt;View&gt;::value&gt;::type type;
  269. <a name="l00314"></a>00314 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) {
  270. <a name="l00315"></a>00315 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::x_iterator x_iterator_t;
  271. <a name="l00316"></a>00316 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0140.html#g558c29855a5b73404d4d21f22832a624" title="Constructing image views from raw interleaved pixel data.">interleaved_view</a>(src.width(),src.height(),(x_iterator_t)&amp;(src(0,0)[n]), src.pixels().row_size());
  272. <a name="l00317"></a>00317 }
  273. <a name="l00318"></a>00318 };
  274. <a name="l00319"></a>00319
  275. <a name="l00320"></a>00320 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keywordtype">bool</span> IsBasic&gt; <span class="keyword">struct </span>__nth_channel_view;
  276. <a name="l00321"></a>00321
  277. <a name="l00322"></a>00322 <span class="comment">// For basic (memory-based) views dispatch to __nth_channel_view_basic</span>
  278. <a name="l00323"></a>00323 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>__nth_channel_view&lt;View,true&gt; {
  279. <a name="l00324"></a>00324 <span class="keyword">private</span>:
  280. <a name="l00325"></a>00325 <span class="keyword">typedef</span> <span class="keyword">typename</span> View::x_iterator src_x_iterator;
  281. <a name="l00326"></a>00326
  282. <a name="l00327"></a>00327 <span class="comment">// Determines whether the channels of a given pixel iterator are adjacent in memory.</span>
  283. <a name="l00328"></a>00328 <span class="comment">// Planar and grayscale iterators have channels adjacent in memory, whereas multi-channel interleaved and iterators with non-fundamental step do not.</span>
  284. <a name="l00329"></a>00329 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, adjacent=
  285. <a name="l00330"></a>00330 !iterator_is_step&lt;src_x_iterator&gt;::value &amp;&amp;
  286. <a name="l00331"></a>00331 (is_planar&lt;src_x_iterator&gt;::value ||
  287. <a name="l00332"></a>00332 num_channels&lt;View&gt;::value==1));
  288. <a name="l00333"></a>00333 <span class="keyword">public</span>:
  289. <a name="l00334"></a>00334 <span class="keyword">typedef</span> <span class="keyword">typename</span> __nth_channel_view_basic&lt;View,adjacent&gt;::type type;
  290. <a name="l00335"></a>00335
  291. <a name="l00336"></a>00336 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) {
  292. <a name="l00337"></a>00337 <span class="keywordflow">return</span> __nth_channel_view_basic&lt;View,adjacent&gt;::make(src,n);
  293. <a name="l00338"></a>00338 }
  294. <a name="l00339"></a>00339 };
  295. <a name="l00340"></a>00340
  296. <a name="l00345"></a>00345 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcP&gt; <span class="comment">// SrcP is a reference to PixelConcept (could be pixel value or const/non-const reference)</span>
  297. <a name="l00346"></a>00346 <span class="comment">// Examples: pixel&lt;T,L&gt;, pixel&lt;T,L&gt;&amp;, const pixel&lt;T,L&gt;&amp;, planar_pixel_reference&lt;T&amp;,L&gt;, planar_pixel_reference&lt;const T&amp;,L&gt;</span>
  298. <a name="l00347"></a><a class="code" href="g_i_l_0515.html">00347</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn</a> {
  299. <a name="l00348"></a>00348 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, is_mutable=<a class="code" href="g_i_l_0600.html" title="Given a model of a pixel, determines whether the model represents a pixel reference...">pixel_is_reference&lt;SrcP&gt;::value</a> &amp;&amp; <a class="code" href="g_i_l_0602.html" title="Determines if the given pixel reference is mutable (i.e. its channels can be changed)...">pixel_reference_is_mutable&lt;SrcP&gt;::value</a>);
  300. <a name="l00349"></a>00349 <span class="keyword">private</span>:
  301. <a name="l00350"></a>00350 <span class="keyword">typedef</span> <span class="keyword">typename</span> remove_reference&lt;SrcP&gt;::type src_pixel_t;
  302. <a name="l00351"></a>00351 <span class="keyword">typedef</span> <span class="keyword">typename</span> channel_type&lt;src_pixel_t&gt;::type channel_t;
  303. <a name="l00352"></a>00352 <span class="keyword">typedef</span> <span class="keyword">typename</span> src_pixel_t::const_reference const_ref_t;
  304. <a name="l00353"></a>00353 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0604.html" title="Returns the type of a homogeneous pixel reference given the channel type, layout...">pixel_reference_type&lt;channel_t,gray_layout_t,false,is_mutable&gt;::type</a> ref_t;
  305. <a name="l00354"></a>00354 <span class="keyword">public</span>:
  306. <a name="l00355"></a>00355 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn&lt;const_ref_t&gt;</a> <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">const_t</a>;
  307. <a name="l00356"></a>00356 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0606.html" title="Returns the type of a homogeneous pixel given the channel type and layout.">pixel_value_type&lt;channel_t,gray_layout_t&gt;::type</a> <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">value_type</a>;
  308. <a name="l00357"></a>00357 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0604.html" title="Returns the type of a homogeneous pixel reference given the channel type, layout...">pixel_reference_type&lt;channel_t,gray_layout_t,false,false&gt;::type</a> const_reference;
  309. <a name="l00358"></a>00358 <span class="keyword">typedef</span> SrcP argument_type;
  310. <a name="l00359"></a>00359 <span class="keyword">typedef</span> <span class="keyword">typename</span> mpl::if_c&lt;is_mutable, ref_t, value_type&gt;::type reference;
  311. <a name="l00360"></a>00360 <span class="keyword">typedef</span> reference result_type;
  312. <a name="l00361"></a>00361
  313. <a name="l00362"></a>00362 <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn</a>(<span class="keywordtype">int</span> n=0) : _n(n) {}
  314. <a name="l00363"></a>00363 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> P&gt; <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn&lt;P&gt;</a>&amp; d) : _n(d.<a class="code" href="g_i_l_0515.html#da0e3adfe5f3db62623fb73a49c120b3">_n</a>) {}
  315. <a name="l00364"></a>00364
  316. <a name="l00365"></a>00365 <span class="keywordtype">int</span> _n; <span class="comment">// the channel to use</span>
  317. <a name="l00366"></a>00366
  318. <a name="l00367"></a>00367 result_type operator()(argument_type srcP)<span class="keyword"> const </span>{
  319. <a name="l00368"></a>00368 <span class="keywordflow">return</span> result_type(srcP[_n]);
  320. <a name="l00369"></a>00369 }
  321. <a name="l00370"></a>00370 };
  322. <a name="l00371"></a>00371
  323. <a name="l00372"></a>00372 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>__nth_channel_view&lt;View,false&gt; {
  324. <a name="l00373"></a>00373 <span class="keyword">private</span>:
  325. <a name="l00374"></a>00374 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0515.html" title="Function object that returns a grayscale reference of the N-th channel of a given...">nth_channel_deref_fn&lt;typename View::reference&gt;</a> deref_t;
  326. <a name="l00375"></a>00375 <span class="keyword">typedef</span> <span class="keyword">typename</span> View::template add_deref&lt;deref_t&gt; AD;
  327. <a name="l00376"></a>00376 <span class="keyword">public</span>:
  328. <a name="l00377"></a>00377 <span class="keyword">typedef</span> <span class="keyword">typename</span> AD::type type;
  329. <a name="l00378"></a>00378 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) {
  330. <a name="l00379"></a>00379 <span class="keywordflow">return</span> AD::make(src, deref_t(n));
  331. <a name="l00380"></a>00380 }
  332. <a name="l00381"></a>00381 };
  333. <a name="l00382"></a>00382 } <span class="comment">// namespace detail</span>
  334. <a name="l00383"></a>00383
  335. <a name="l00390"></a>00390 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  336. <a name="l00391"></a><a class="code" href="g_i_l_0578.html">00391</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0578.html" title="Given a source image view type View, returns the type of an image view over a single...">nth_channel_view_type</a> {
  337. <a name="l00392"></a>00392 <span class="keyword">private</span>:
  338. <a name="l00393"></a>00393 GIL_CLASS_REQUIRE(View, boost::gil, <a class="code" href="g_i_l_0308.html" title="GIL&amp;#39;s 2-dimensional view over immutable GIL pixels.">ImageViewConcept</a>)
  339. <a name="l00394"></a>00394 <span class="keyword">typedef</span> detail::__nth_channel_view&lt;View,view_is_basic&lt;View&gt;::value&gt; VB;
  340. <a name="l00395"></a>00395 <span class="keyword">public</span>:
  341. <a name="l00396"></a>00396 <span class="keyword">typedef</span> <span class="keyword">typename</span> VB::type type;
  342. <a name="l00397"></a>00397 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) { <span class="keywordflow">return</span> VB::make(src,n); }
  343. <a name="l00398"></a>00398 };
  344. <a name="l00399"></a>00399
  345. <a name="l00400"></a>00400
  346. <a name="l00402"></a>00402 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
  347. <a name="l00403"></a>00403 <span class="keyword">typename</span> <a class="code" href="g_i_l_0578.html" title="Given a source image view type View, returns the type of an image view over a single...">nth_channel_view_type&lt;View&gt;::type</a> nth_channel_view(<span class="keyword">const</span> View&amp; src, <span class="keywordtype">int</span> n) {
  348. <a name="l00404"></a>00404 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0578.html" title="Given a source image view type View, returns the type of an image view over a single...">nth_channel_view_type&lt;View&gt;::make</a>(src,n);
  349. <a name="l00405"></a>00405 }
  350. <a name="l00406"></a>00406
  351. <a name="l00407"></a>00407
  352. <a name="l00408"></a>00408
  353. <a name="l00409"></a>00409
  354. <a name="l00410"></a>00410
  355. <a name="l00411"></a>00411
  356. <a name="l00412"></a>00412
  357. <a name="l00416"></a>00416
  358. <a name="l00417"></a>00417 <span class="keyword">namespace </span>detail {
  359. <a name="l00418"></a>00418 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View, <span class="keywordtype">bool</span> AreChannelsTogether&gt; <span class="keyword">struct </span>__kth_channel_view_basic;
  360. <a name="l00419"></a>00419
  361. <a name="l00420"></a>00420 <span class="comment">// kth_channel_view when the channels are not adjacent in memory. This can happen for multi-channel interleaved images </span>
  362. <a name="l00421"></a>00421 <span class="comment">// or images with a step</span>
  363. <a name="l00422"></a>00422 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt;
  364. <a name="l00423"></a>00423 <span class="keyword">struct </span>__kth_channel_view_basic&lt;K,View,false&gt; {
  365. <a name="l00424"></a>00424 <span class="keyword">private</span>:
  366. <a name="l00425"></a>00425 <span class="keyword">typedef</span> <span class="keyword">typename</span> kth_element_type&lt;typename View::value_type,K&gt;::type channel_t;
  367. <a name="l00426"></a>00426 <span class="keyword">public</span>:
  368. <a name="l00427"></a>00427 <span class="keyword">typedef</span> <span class="keyword">typename</span> view_type&lt;channel_t, gray_layout_t, false, true, view_is_mutable&lt;View&gt;::value&gt;::type type;
  369. <a name="l00428"></a>00428
  370. <a name="l00429"></a>00429 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src) {
  371. <a name="l00430"></a>00430 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::xy_locator locator_t;
  372. <a name="l00431"></a>00431 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::x_iterator x_iterator_t;
  373. <a name="l00432"></a>00432 <span class="keyword">typedef</span> <span class="keyword">typename</span> iterator_adaptor_get_base&lt;x_iterator_t&gt;::type x_iterator_base_t;
  374. <a name="l00433"></a>00433 x_iterator_t sit(x_iterator_base_t(&amp;at_c&lt;K&gt;(src(0,0))),src.pixels().pixel_size());
  375. <a name="l00434"></a>00434 <span class="keywordflow">return</span> type(src.dimensions(),locator_t(sit, src.pixels().row_size()));
  376. <a name="l00435"></a>00435 }
  377. <a name="l00436"></a>00436 };
  378. <a name="l00437"></a>00437
  379. <a name="l00438"></a>00438 <span class="comment">// kth_channel_view when the channels are together in memory (true for simple grayscale or planar images)</span>
  380. <a name="l00439"></a>00439 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt;
  381. <a name="l00440"></a>00440 <span class="keyword">struct </span>__kth_channel_view_basic&lt;K,View,true&gt; {
  382. <a name="l00441"></a>00441 <span class="keyword">private</span>:
  383. <a name="l00442"></a>00442 <span class="keyword">typedef</span> <span class="keyword">typename</span> kth_element_type&lt;typename View::value_type, K&gt;::type channel_t;
  384. <a name="l00443"></a>00443 <span class="keyword">public</span>:
  385. <a name="l00444"></a>00444 <span class="keyword">typedef</span> <span class="keyword">typename</span> view_type&lt;channel_t, gray_layout_t, false, false, view_is_mutable&lt;View&gt;::value&gt;::type type;
  386. <a name="l00445"></a>00445 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src) {
  387. <a name="l00446"></a>00446 <span class="keyword">typedef</span> <span class="keyword">typename</span> type::x_iterator x_iterator_t;
  388. <a name="l00447"></a>00447 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0140.html#g558c29855a5b73404d4d21f22832a624" title="Constructing image views from raw interleaved pixel data.">interleaved_view</a>(src.width(),src.height(),(x_iterator_t)&amp;at_c&lt;K&gt;(src(0,0)), src.pixels().row_size());
  389. <a name="l00448"></a>00448 }
  390. <a name="l00449"></a>00449 };
  391. <a name="l00450"></a>00450
  392. <a name="l00451"></a>00451 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View, <span class="keywordtype">bool</span> IsBasic&gt; <span class="keyword">struct </span>__kth_channel_view;
  393. <a name="l00452"></a>00452
  394. <a name="l00453"></a>00453 <span class="comment">// For basic (memory-based) views dispatch to __kth_channel_view_basic</span>
  395. <a name="l00454"></a>00454 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>__kth_channel_view&lt;K,View,true&gt; {
  396. <a name="l00455"></a>00455 <span class="keyword">private</span>:
  397. <a name="l00456"></a>00456 <span class="keyword">typedef</span> <span class="keyword">typename</span> View::x_iterator src_x_iterator;
  398. <a name="l00457"></a>00457
  399. <a name="l00458"></a>00458 <span class="comment">// Determines whether the channels of a given pixel iterator are adjacent in memory.</span>
  400. <a name="l00459"></a>00459 <span class="comment">// Planar and grayscale iterators have channels adjacent in memory, whereas multi-channel interleaved and iterators with non-fundamental step do not.</span>
  401. <a name="l00460"></a>00460 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, adjacent=
  402. <a name="l00461"></a>00461 !iterator_is_step&lt;src_x_iterator&gt;::value &amp;&amp;
  403. <a name="l00462"></a>00462 (is_planar&lt;src_x_iterator&gt;::value ||
  404. <a name="l00463"></a>00463 num_channels&lt;View&gt;::value==1));
  405. <a name="l00464"></a>00464 <span class="keyword">public</span>:
  406. <a name="l00465"></a>00465 <span class="keyword">typedef</span> <span class="keyword">typename</span> __kth_channel_view_basic&lt;K,View,adjacent&gt;::type type;
  407. <a name="l00466"></a>00466
  408. <a name="l00467"></a>00467 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src) {
  409. <a name="l00468"></a>00468 <span class="keywordflow">return</span> __kth_channel_view_basic&lt;K,View,adjacent&gt;::make(src);
  410. <a name="l00469"></a>00469 }
  411. <a name="l00470"></a>00470 };
  412. <a name="l00471"></a>00471
  413. <a name="l00476"></a>00476 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> SrcP&gt; <span class="comment">// SrcP is a reference to PixelConcept (could be pixel value or const/non-const reference)</span>
  414. <a name="l00477"></a>00477 <span class="comment">// Examples: pixel&lt;T,L&gt;, pixel&lt;T,L&gt;&amp;, const pixel&lt;T,L&gt;&amp;, planar_pixel_reference&lt;T&amp;,L&gt;, planar_pixel_reference&lt;const T&amp;,L&gt;</span>
  415. <a name="l00478"></a><a class="code" href="g_i_l_0513.html">00478</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn</a> {
  416. <a name="l00479"></a>00479 BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, is_mutable=<a class="code" href="g_i_l_0600.html" title="Given a model of a pixel, determines whether the model represents a pixel reference...">pixel_is_reference&lt;SrcP&gt;::value</a> &amp;&amp; <a class="code" href="g_i_l_0602.html" title="Determines if the given pixel reference is mutable (i.e. its channels can be changed)...">pixel_reference_is_mutable&lt;SrcP&gt;::value</a>);
  417. <a name="l00480"></a>00480 <span class="keyword">private</span>:
  418. <a name="l00481"></a>00481 <span class="keyword">typedef</span> <span class="keyword">typename</span> remove_reference&lt;SrcP&gt;::type src_pixel_t;
  419. <a name="l00482"></a>00482 <span class="keyword">typedef</span> <span class="keyword">typename</span> kth_element_type&lt;src_pixel_t, K&gt;::type channel_t;
  420. <a name="l00483"></a>00483 <span class="keyword">typedef</span> <span class="keyword">typename</span> src_pixel_t::const_reference const_ref_t;
  421. <a name="l00484"></a>00484 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0604.html" title="Returns the type of a homogeneous pixel reference given the channel type, layout...">pixel_reference_type&lt;channel_t,gray_layout_t,false,is_mutable&gt;::type</a> ref_t;
  422. <a name="l00485"></a>00485 <span class="keyword">public</span>:
  423. <a name="l00486"></a>00486 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn&lt;K,const_ref_t&gt;</a> <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">const_t</a>;
  424. <a name="l00487"></a>00487 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0606.html" title="Returns the type of a homogeneous pixel given the channel type and layout.">pixel_value_type&lt;channel_t,gray_layout_t&gt;::type</a> <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">value_type</a>;
  425. <a name="l00488"></a>00488 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0604.html" title="Returns the type of a homogeneous pixel reference given the channel type, layout...">pixel_reference_type&lt;channel_t,gray_layout_t,false,false&gt;::type</a> const_reference;
  426. <a name="l00489"></a>00489 <span class="keyword">typedef</span> SrcP argument_type;
  427. <a name="l00490"></a>00490 <span class="keyword">typedef</span> <span class="keyword">typename</span> mpl::if_c&lt;is_mutable, ref_t, value_type&gt;::type reference;
  428. <a name="l00491"></a>00491 <span class="keyword">typedef</span> reference result_type;
  429. <a name="l00492"></a>00492
  430. <a name="l00493"></a>00493 <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn</a>() {}
  431. <a name="l00494"></a>00494 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> P&gt; <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn&lt;K,P&gt;</a>&amp;) {}
  432. <a name="l00495"></a>00495
  433. <a name="l00496"></a>00496 result_type operator()(argument_type srcP)<span class="keyword"> const </span>{
  434. <a name="l00497"></a>00497 <span class="keywordflow">return</span> result_type(at_c&lt;K&gt;(srcP));
  435. <a name="l00498"></a>00498 }
  436. <a name="l00499"></a>00499 };
  437. <a name="l00500"></a>00500
  438. <a name="l00501"></a>00501 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt; <span class="keyword">struct </span>__kth_channel_view&lt;K,View,false&gt; {
  439. <a name="l00502"></a>00502 <span class="keyword">private</span>:
  440. <a name="l00503"></a>00503 <span class="keyword">typedef</span> <a class="code" href="g_i_l_0513.html" title="Function object that returns a grayscale reference of the K-th channel (specified...">kth_channel_deref_fn&lt;K,typename View::reference&gt;</a> deref_t;
  441. <a name="l00504"></a>00504 <span class="keyword">typedef</span> <span class="keyword">typename</span> View::template add_deref&lt;deref_t&gt; AD;
  442. <a name="l00505"></a>00505 <span class="keyword">public</span>:
  443. <a name="l00506"></a>00506 <span class="keyword">typedef</span> <span class="keyword">typename</span> AD::type type;
  444. <a name="l00507"></a>00507 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src) {
  445. <a name="l00508"></a>00508 <span class="keywordflow">return</span> AD::make(src, deref_t());
  446. <a name="l00509"></a>00509 }
  447. <a name="l00510"></a>00510 };
  448. <a name="l00511"></a>00511 } <span class="comment">// namespace detail</span>
  449. <a name="l00512"></a>00512
  450. <a name="l00519"></a>00519 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt;
  451. <a name="l00520"></a><a class="code" href="g_i_l_0559.html">00520</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0559.html" title="Given a source image view type View, returns the type of an image view over a given...">kth_channel_view_type</a> {
  452. <a name="l00521"></a>00521 <span class="keyword">private</span>:
  453. <a name="l00522"></a>00522 GIL_CLASS_REQUIRE(View, boost::gil, <a class="code" href="g_i_l_0308.html" title="GIL&amp;#39;s 2-dimensional view over immutable GIL pixels.">ImageViewConcept</a>)
  454. <a name="l00523"></a>00523 <span class="keyword">typedef</span> detail::__kth_channel_view&lt;K,View,view_is_basic&lt;View&gt;::value&gt; VB;
  455. <a name="l00524"></a>00524 <span class="keyword">public</span>:
  456. <a name="l00525"></a>00525 <span class="keyword">typedef</span> <span class="keyword">typename</span> VB::type type;
  457. <a name="l00526"></a>00526 <span class="keyword">static</span> type make(<span class="keyword">const</span> View&amp; src) { <span class="keywordflow">return</span> VB::make(src); }
  458. <a name="l00527"></a>00527 };
  459. <a name="l00528"></a>00528
  460. <a name="l00530"></a>00530 <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> K, <span class="keyword">typename</span> View&gt;
  461. <a name="l00531"></a>00531 <span class="keyword">typename</span> <a class="code" href="g_i_l_0559.html" title="Given a source image view type View, returns the type of an image view over a given...">kth_channel_view_type&lt;K,View&gt;::type</a> kth_channel_view(<span class="keyword">const</span> View&amp; src) {
  462. <a name="l00532"></a>00532 <span class="keywordflow">return</span> <a class="code" href="g_i_l_0559.html" title="Given a source image view type View, returns the type of an image view over a given...">kth_channel_view_type&lt;K,View&gt;::make</a>(src);
  463. <a name="l00533"></a>00533 }
  464. <a name="l00534"></a>00534
  465. <a name="l00535"></a>00535 } } <span class="comment">// namespace boost::gil</span>
  466. <a name="l00536"></a>00536
  467. <a name="l00537"></a>00537 <span class="preprocessor">#endif</span>
  468. </pre></div></div>
  469. <hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:14 2009 for Generic Image Library by&nbsp;
  470. <a href="http://www.doxygen.org/index.html">
  471. <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
  472. </body>
  473. </html>