Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 65f8aa69c4b85eb2463f24ce9ff49b95 > files > 448

cimg-devel-1.5.9-3.mga5.i586.rpm

<xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
    <title>The CImg Library - C++ Template Image Processing Toolkit</title>
    <meta content="David Tschumperle" name="author"></meta>
    <link rel="shortcut icon" type="image/x-icon" href="http://cimg.sourceforge.net/favicon.ico"></link>
    <link rel="icon" type="image/png" href="favicon.png"></link>
    <link href="doxygen.css" rel="stylesheet" type="text/css">
    <link href="tabs.css" rel="stylesheet" type="text/css">
    <style type="text/css">
      <!--
          body {background-color:#C0C0C0; font-family:sans-serif; }
          a { font-weight:bold; color:#636363; }
          a:active{text-decoration:none; color:#000000}
          a:link{text-decoration:none; color:#000000}
          a:visited{text-decoration:none; color:#000000}
          a:hover{text-decoration:underline; color:#4E9F71}
        -->
    </style>
    <script language="JavaScript" type="text/javascript">
      <!-- Original:  Eric King (eric_andrew_king@hotmail.com) is used to display images in popup windows -->
      <!-- Web Site:  http://redrival.com/eak/ -->
      <!-- This script and many more are available free online at -->
      <!-- The JavaScript Source!! http://javascript.internet.com -->
      <!-- Begin
           function NewWindow(mypage, myname, w, h, scroll) {
           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
           win = window.open(mypage, myname, winprops)
           if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
           }
           //  End -->
    </script>
    <script type="text/javascript" src="../jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
      $('#cssmenu > ul').prepend('<li class="mobile"><a href="#"><span>Menu <i>&#9776;</i></span></a></li>');
      $('#cssmenu > ul > li > a').click(function(e) {
      $('#cssmenu li').removeClass('active');
      $(this).closest('li').addClass('active');
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
      $(this).closest('li').removeClass('active');
      checkElement.slideUp('normal');
      }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
      $('#cssmenu ul ul:visible').slideUp('normal');
      checkElement.slideDown('normal');
      }
      if( $(this).parent().hasClass('mobile') ) {
      e.preventDefault();
      $('#cssmenu').toggleClass('expand');
      }
      if($(this).closest('li').find('ul').children().length == 0) {
      return true;
      } else {
      return false;
      }
      });
      });
    </script>
    <link rel="stylesheet" type="text/css" href="../header.css" />
  </head>
  <body>
    <table align="center" cellpadding="12" cellspacing="0" width="1024" style="border-style:solid; border-width:0px; border-color:black" bgcolor="#FFFFFF">
      <tr><td>
          <center>
            <hr noshade="noshade" size="1" width="90%"></hr>
            <br/>
            <a href="http://cimg.sourceforge.net"><img src="http://cimg.sourceforge.net/img/CImgLogo2.jpg" alt="" border="0"></img></a><br/>
            <br/>
            <hr noshade="noshade" size="1" width="90%"></hr>
            <table width="90%" align="center">
              <td width="18%">&nbsp;</td>
              <td width="65%">
                <div id='cssmenu'>
                  <ul>
                    <li class='first'><a href='http://cimg.sourceforge.net/index.shtml'><span>Home</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/download.shtml'><span>Download</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/screenshots.shtml'><span>Screenshots</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/reference/group__cimg__faq.html'><span>FAQ</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/reference/group__cimg__tutorial.html'><span>Tutorial</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/reference/index.html'><span>Documentation</span></a></li>
                    <li><a href='http://sourceforge.net/projects/cimg/forums/forum/334630'><span>Forum</span></a></li>
                    <li><a href='http://cimg.sourceforge.net/links.shtml'><span>Links</span></a></li>
                  </ul>
                </div>
              </td>
              <td align="right">
                <script type="text/javascript">
	          var flattr_url = 'http://cimg.sourceforge.net';
	          var flattr_btn='compact';
                </script>
                <script src="http://api.flattr.com/button/load.js" type="text/javascript"></script>
              </td>
      </tr></table>
      </center>
</td></tr>
<tr><td>
<!-- Generated by Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">How pixel data are stored with CImg.</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock">First, CImg&lt;T&gt; are <em>very</em> basic structures, which means that there are no memory tricks, weird memory alignments or disk caches used to store pixel data of images. When an image is instanced, all its pixel values are stored in memory at the same time (yes, you should avoid working with huge images when dealing with CImg, if you have only 64kb of RAM).A CImg&lt;T&gt; is basically a 4th-dimensional array (width,height,depth,dim), and its pixel data are stored linearly in a single memory buffer of general size (width*height*depth*dim). Nothing more, nothing less. The address of this memory buffer can be retrieved by the function CImg&lt;T&gt;::data(). As each image value is stored as a type T (T being known by the programmer of course), this pointer is a 'T*', or a 'const T*' if your image is 'const'. so, 'T *ptr = img.data()' gives you the pointer to the first value of the image 'img'. The overall size of the used memory for one instance image (in bytes) is then 'width*height*depth*dim*sizeof(T)'.Now, the ordering of the pixel values in this buffer follows these rules : The values are <em>not</em> interleaved, and are ordered first along the X,Y,Z and V axis respectively (corresponding to the width,height,depth,dim dimensions), starting from the upper-left pixel to the bottom-right pixel of the instane image, with a classical scanline run.So, a color image with dim=3 and depth=1, will be stored in memory as :R1R2R3R4R5R6......G1G2G3G4G5G6.......B1B2B3B4B5B6.... (i.e following a 'planar' structure)and <em>not</em> as R1G1B1R2G2B2R3G3B3... (interleaved channels), where R1 = img(0,0,0,0) is the first upper-left pixel of the red component of the image, R2 is img(1,0,0,0), G1 = img(0,0,0,1), G2 = img(1,0,0,1), B1 = img(0,0,0,2), and so on...Another example, a (1x5x1x1) CImg&lt;T&gt; (column vector A) will be stored as : A1A2A3A4A5 where A1 = img(0,0), A2 = img(0,1), ... , A5 = img(0,4).As you see, it is <em>very</em> simple and intuitive : no interleaving, no padding, just simple. This is cool not only because it is simple, but this has in fact a number of interesting properties. For instance, a 2D color image is stored in memory exactly as a 3D scalar image having a depth=3, meaning that when you are dealing with 2D color images, you can write 'img(x,y,k)' instead of 'img(x,y,0,k)' to access the kth channel of the (x,y) pixel. More generally, if you have one dimension that is 1 in your image, you can just skip it in the call to the operator(). Similarly, values of a column vector stored as an image with width=depth=spectrum=1 can be accessed by 'img(y)' instead of 'img(0,y)'. This is very convenient.Another cool thing is that it allows you to work easily with 'shared' images. A shared image is a CImg&lt;T&gt; instance that shares its memory with another one (the 'base' image). Destroying a shared image does nothing in fact. Shared images is a convenient way of modifying only <em>portions</em> (consecutive in memory) of an image. For instance, if 'img' is a 2D color image, you can write :img.get_shared_channel(0).blur(2); img.get_shared_channels(1,2).mirror('x');which just blur the red channel of the image, and mirror the two others along the X-axis. This is possible since channels of an image are not interleaved but are stored as different consecutive planes in memory, so you see that constructing a shared image is possible (and trivial). </div></div><!-- contents -->
</td></tr></table>
<center>
<p>
<a href="http://sourceforge.net">
  <img src="http://sourceforge.net/sflogo.php?group_id=96492&amp;type=3" border="0" height="37" width="125"></img>
</a>
<a href="http://sourceforge.net/donate/index.php?group_id=96492"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /> </a>
</p>
</center>
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
  <!--
      var sc_project=895001;
      var sc_invisible=1;
      var sc_partition=7;
      var sc_security="5ea85181";
      //-->
</script>
<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img  src="http://c8.statcounter.com/counter.php?sc_project=895001&amp;java=0&amp;security=5ea85181&amp;invisible=1" alt="counter stats" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
<!-- Google Analytics -->
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16976814-2']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
<!-- End Google Analytics -->
</body>
</html>