📄 group__cimg__structure.html
字号:
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>The CImg Library - C++ Template Image Processing Library</title> <meta content="David Tschumperle" name="author"> <link rel="shortcut icon" type="image/x-icon" href="http://cimg.sourceforge.net/favicon.ico" /> <link rel="icon" type="image/png" href="favicon.png" /> <style type="text/css" media=screen> <!-- a:active{text-decoration:none; color:#303090} a:link{text-decoration:none; color:#303090} a:visited{text-decoration:none; color:#303090} a:hover{text-decoration:none; color:#4E9F71} --> </style> </head> <body bgcolor="#ffffff" fgcolor="#000000" alink="#ff0000" link="#0000ee" vlink="#551a8b"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="1024"> <tbody> <tr> <td> <hr noshade="noshade" size="1" width="100%"> <center> <a href="http://cimg.sourceforge.net"><img src="../img/CImgLogo2.jpg" border="0"><img src="../img/CImgLogo.jpg" border="0"></a><br> <table style="width: 100%; text-align: left;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="vertical-align: top; text-align: right;"><font face="Arial,Helvetica"><big> <b>C++ Template Image Processing Library.</b></big></font></td> <td style="vertical-align: top; text-align: right;"> <a href="http://www.cnrs.fr/"><img src="../img/logoCNRS.gif" border="0"></a> <a href="http://www.greyc.ensicaen.fr/EquipeImage/"><img src="../img/logoGREYC.gif" border="0"></a> <a href="http://www-sop.inria.fr"><img src="../img/logoINRIA.gif" border="0"></a> </td> </tr> </tbody> </table> </center> <hr noshade="noshade" size="1" width="100%"> <center> <table style="width: 100%; text-align: left; margin-left: auto; margin-right: auto; background-color: rgb(238, 238, 255);" border="0" cellpadding="3" cellspacing="0"> <tbody> <tr> <td style="text-align: center; vertical-align: top;"> <font face="Arial,Helvetica" color="#FFFFFF" size="-1"> <b>[</b> <a target="_parent" href="../index.shtml">Introduction</a> <b>]</b>-<b>[</b> <a target="_parent" href="../news.shtml">News</a> <b>]</b>-<b>[</b> <a target="_parent" href="../download.shtml">Download</a> <b>]</b>-<b>[</b> <a target="_parent" href="../screenshots.shtml">Screenshots</a> <b>]</b>-<b>[</b> <a target="_parent" href="../reference/group__cimg__faq.html">FAQ</a> <b>]</b>-<b>[</b> <a target="_parent" href="../reference/group__cimg__tutorial.html">Tutorial</a> <b>]</b>-<b>[</b> <a target="_parent" href="../links.shtml">Links</a> <b>]</b>-<b>[</b> <a target="_parent" href="http://sourceforge.net/forum/forum.php?forum_id=334630">Forums-Eng</a> <b>]</b>-<b>[</b> <a target="_parent" href="http://sourceforge.net/forum/forum.php?forum_id=421080">Forums-Fr</a> <b>]</b>-<b>[</b> <a target="_parent" href="../reference/index.html">Reference</a> <b>]</b>-<b>[</b> <a target="_parent" href="http://sourceforge.net/projects/cimg/">SourceForge Repository</a> <b>]</b> </font></td> </tr> </tbody> </table> </center> <hr noshade="noshade" size="1" width="100%"> <noscript> </noscript> </td> </tr> </tbody> </table> </body></html><!-- Generated by Doxygen 1.5.1 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main 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><h1>CImg Library Overview</h1><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>The <b>CImg Library</b> is an image processing library, designed for C++ programmers. It provides useful classes and functions to load/save, display and process various types of images.<h2><a class="anchor" name="s1">Library structure</a></h2>The CImg Library consists in a <b>single header file</b> CImg.h providing a set of C++ template classes that can be used in your own sources, to load/save, process and display images or list of images. Very portable (Unix/X11,Windows, MacOS X, FreeBSD,..), efficient, simple to use, it's a pleasant toolkit for coding image processing stuffs in C++.<p>The header file CImg.h contains all the classes and functions that compose the library itself. This is one originality of the CImg Library. This particularly means that :<ul><li>No pre-compilation of the library is needed, since the compilation of the CImg functions is done at the same time as the compilation of your own C++ code.</li><li>No complex dependencies have to be handled : Just include the CImg.h file, and you get a working C++ image processing toolkit.</li><li>The compilation is done on the fly : only CImg functionalities really used by your program are compiled and appear in the compiled executable program. This leads to very compact code, without any unused stuffs.</li><li>Class members and functions are inlined, leading to better performance during the program execution.</li></ul><p>The CImg Library is structured as follows :<p><ul><li>All library classes and functions are defined in the namespace <a class="el" href="namespacecimg__library.html">cimg_library</a>. This namespace encapsulates the library functionalities and avoid any class name collision that could happen with other includes. Generally, one uses this namespace as a default namespace : <div class="fragment"><pre class="fragment"><span class="preprocessor"> #include "CImg.h"</span> <span class="keyword">using namespace </span>cimg_library; ...</pre></div></li></ul><p><ul><li>The namespace <a class="el" href="namespacecimg__library_1_1cimg.html">cimg_library::cimg</a> defines a set of <em>low-level</em> functions and variables used by the library. Documented functions in this namespace can be safely used in your own program. But, <b>never</b> use the <a class="el" href="namespacecimg__library_1_1cimg.html">cimg_library::cimg</a> namespace as a default namespace, since it contains functions whose names are already defined in the standard C/C++ library.</li></ul><p><ul><li>The class <a class="el" href="structcimg__library_1_1_c_img.html">cimg_library::CImg</a><T> represents images up to 4-dimensions wide, containing pixels of type <code>T</code> (template parameter). This is actually the main class of the library.</li></ul><p><ul><li>The class <a class="el" href="structcimg__library_1_1_c_img_list.html">cimg_library::CImgList</a><T> represents lists of cimg_library::CImg<T> images. It can be used for instance to store different frames of an image sequence.</li></ul><p><ul><li>The class <a class="el" href="structcimg__library_1_1_c_img_display.html">cimg_library::CImgDisplay</a> is able to display images or image lists into graphical display windows. As you may guess, the code of this class is highly system-dependent but this is transparent for the programmer, as environment variables are automatically set by the CImg library (see also <a class="el" href="group__cimg__environment.html">Setting Environment Variables</a>).</li></ul><p><ul><li>The class <a class="el" href="structcimg__library_1_1_c_img_stats.html">cimg_library::CImgStats</a> represents image statistics. Use it to compute the minimum, maximum, mean and variance of pixel values of images, as well as the corresponding min/max pixel location.</li></ul><p><ul><li>The class <a class="el" href="structcimg__library_1_1_c_img_exception.html">cimg_library::CImgException</a> (and its subclasses) are used by the library to throw exceptions when errors occur. Those exceptions can be catched with a bloc <code>try { ..} catch (CImgException) { .. }</code>. Subclasses define precisely the type of encountered errors.</li></ul><p>Knowing these five classes is <b>enough</b> to get benefit of the CImg Library functionalities.<h2><a class="anchor" name="s2">CImg version of "Hello world".</a></h2>Below is a very simple code that creates a "Hello World" image. This shows you basically how a CImg program looks like.<p><div class="fragment"><pre class="fragment"><span class="preprocessor"> #include "CImg.h"</span> <span class="keyword">using namespace </span>cimg_library; <span class="keywordtype">int</span> main() { CImg<unsigned char> img(640,400,1,3); <span class="comment">// Define a 640x400 color image with 8 bits per color component.</span> img.fill(0); <span class="comment">// Set pixel values to 0 (color : black)</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> purple[3]={255,0,255}; <span class="comment">// Define a purple color</span> img.draw_text(<span class="stringliteral">"Hello World"</span>,100,100,purple); <span class="comment">// Draw a purple "Hello world" at coordinates (100,100).</span> img.display(<span class="stringliteral">"My first CImg code"</span>); <span class="comment">// Display the image in a display window.</span> <span class="keywordflow">return</span> 0; }</pre></div><p>Which can be also written in a more compact way as :<p><div class="fragment"><pre class="fragment"><span class="preprocessor"> #include "CImg.h"</span> <span class="keyword">using namespace </span>cimg_library; <span class="keywordtype">int</span> main() { <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> purple[3]={255,0,255}; CImg<unsigned char>(640,400,1,3,0).draw_text(<span class="stringliteral">"Hello World"</span>,100,100,purple).display(<span class="stringliteral">"My first CImg code"</span>); <span class="keywordflow">return</span> 0; }</pre></div><p>Generally, you can write very small code that performs complex image processing tasks. The CImg Library is very simple to use and provide a lot of interesting algorithms for image manipulation.<h2><a class="anchor" name="s3">How to compile ?</a></h2>The CImg library is a very light and user-friendly library : only standard system libraries are used. It avoid to handle complex dependancies and problems with library compatibility. The only thing you need is a (quite modern) C++ compiler :<p><ul><li><b>Microsoft Visual C++ 6.0, Visual Studio.NET and Visual Express Edition</b> : Use project files and solution files provided in the CImg Library package (directory 'compilation/') to see how it works.</li><li><b>Intel ICL compiler</b> : Use the following command to compile a CImg-based program with ICL : <div class="fragment"><pre class="fragment"> icl /Ox hello_world.cpp user32.lib gdi32.lib</pre></div></li><li><b>g++ (MingW windows version)</b> : Use the following command to compile a CImg-based program with g++, on Windows : <div class="fragment"><pre class="fragment"> g++ -o hello_word.exe hello_word.cpp -O2 -lgdi32</pre></div></li><li><b>g++ (Linux version)</b> : Use the following command to compile a CImg-based program with g++, on Linux : <div class="fragment"><pre class="fragment"> g++ -o hello_word.exe hello_world.cpp -O2 -L/usr/X11R6/lib -lm -lpthread -lX11</pre></div></li><li><b>g++ (Solaris version)</b> : Use the following command to compile a CImg-based program with g++, on Solaris : <div class="fragment"><pre class="fragment"> g++ -o hello_word.exe hello_world.cpp -O2 -lm -lpthread -R/usr/X11R6/lib -lrt -lnsl -lsocket</pre></div></li><li><b>g++ (Mac OS X version)</b> : Use the following command to compile a CImg-based program with g++, on Mac OS X : <div class="fragment"><pre class="fragment"> g++ -o hello_word.exe hello_world.cpp -O2 -lm -lpthread -L/usr/X11R6/lib -lm -lpthread -lX11</pre></div></li><li><b>Dev-Cpp</b> : Use the project file provided in the CImg library package to see how it works.</li></ul><p>If you are using another compilers and encounter problems, please <a href="http://www.greyc.ensicaen.fr/~dtschump">write me</a> since maintaining compatibility is one of the priority of the CImg Library. Nevertheless, old compilers that does not respect the C++ norm will not support the CImg Library.<h2><a class="anchor" name="s4">What's next ?</a></h2>If you are ready to get more, and to start writing more serious programs with CImg, you are invited to go to the <a class="el" href="group__cimg__tutorial.html">Tutorial : Getting Started.</a> section. <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>The CImg Library - C++ Template Image Processing Library</title> <meta content="David Tschumperle" name="author"> <link rel="shortcut icon" type="image/x-icon" href="http://cimg.sourceforge.net/favicon.ico" /> <link rel="icon" type="image/png" href="favicon.png" /> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff" fgcolor="#000000" alink="#ff0000" link="#0000ee" vlink="#551a8b"> <hr noshade="noshade" size="1" width="100%"> <a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=96492&type=3" border="0" height="37" width="125"></a><!-- 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&java=0&security=5ea85181&invisible=1" alt="counter stats" border="0"></a> </noscript><!-- End of StatCounter Code --> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -