


\begin{DoxyItemize}
\item \hyperlink{a00002}{Installation}
\item \hyperlink{a00003}{Foreword}
\item \hyperlink{a00004}{Site}
\item \hyperlink{a00005}{Site set}
\item \hyperlink{a00006}{Image}
\item \hyperlink{a00007}{Structural elements: Window and neighborhood}
\item \hyperlink{a00008}{Sites, psites and dpoints}
\item \hyperlink{a00009}{Iterators}
\item \hyperlink{a00010}{Memory management}
\item \hyperlink{a00011}{Basic routines}
\item \hyperlink{a00012}{Input / Output}
\item \hyperlink{a00013}{Graphs and images}
\item \hyperlink{a00014}{Useful global variables}
\item \hyperlink{a00015}{Useful macros}
\item \hyperlink{a00016}{Common Compilation Errors}  
\end{DoxyItemize}\hypertarget{installation}{}\section{Installation}\label{installation}
\hypertarget{d7/d46/a00002_requirements}{}\subsection{Requirements}\label{d7/d46/a00002_requirements}
\hypertarget{d7/d46/a00002_compexample}{}\subsubsection{To compile the user examples}\label{d7/d46/a00002_compexample}
\hypertarget{d7/d46/a00002_compdoc}{}\subsubsection{To compile the documentation (Optional)}\label{d7/d46/a00002_compdoc}
\hypertarget{d7/d46/a00002_devolena}{}\subsubsection{To develop in Olena}\label{d7/d46/a00002_devolena}
\hypertarget{d7/d46/a00002_getolena}{}\subsection{Getting Olena}\label{d7/d46/a00002_getolena}
\hypertarget{d7/d46/a00002_buildingolena}{}\subsection{Building Olena}\label{d7/d46/a00002_buildingolena}
 \hypertarget{foreword}{}\section{Foreword}\label{foreword}
\hypertarget{d1/d7c/a00003_generality}{}\subsection{Generality}\label{d1/d7c/a00003_generality}
\hypertarget{d1/d7c/a00003_dirtree}{}\subsection{Directory hierarchy}\label{d1/d7c/a00003_dirtree}
\hypertarget{d1/d7c/a00003_compilehint}{}\subsection{Writing and compiling a program with Olena}\label{d1/d7c/a00003_compilehint}
 \hypertarget{site}{}\section{Site}\label{site}
 \hypertarget{siteset}{}\section{Site set}\label{siteset}
\hyperlink{a00009}{Iterators} \hypertarget{dd/dad/a00005_sitesetinterface}{}\subsection{Basic interface}\label{dd/dad/a00005_sitesetinterface}
\hypertarget{dd/dad/a00005_sitesetopinterface}{}\subsection{Optional interface}\label{dd/dad/a00005_sitesetopinterface}



\begin{DoxyCodeInclude}
  box2d b(2,3);

  // The bbox can be retrived in constant time.
  std::cout << b.bbox() << std::endl;

  // nsites can be retrieved in constant time.
  std::cout << "nsites = " << b.nsites() << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
[(0,0)..(1,2)]
nsites = 6
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  p_array<point2d> arr;
  arr.insert(point2d(1,0));
  arr.insert(point2d(1,1));

  // The bbox is computed thanks to bbox() algorithm.
  box2d box = geom::bbox(arr);
  std::cout << box << std::endl;

  // p_array provides nsites(),
  // it can be retrieved in constant time.
  std::cout << "nsites = " << arr.nsites() << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
[(1,0)..(1,1)]
nsites = 2
\end{DoxyCodeInclude}


 \hypertarget{image}{}\section{Image}\label{image}
\hypertarget{de/d21/a00006_definition}{}\subsection{Definition}\label{de/d21/a00006_definition}
\hypertarget{de/d21/a00006_imatypes}{}\subsection{Possible image types}\label{de/d21/a00006_imatypes}
\hypertarget{de/d21/a00006_imapossvalues}{}\subsection{Possible value types}\label{de/d21/a00006_imapossvalues}
\hypertarget{de/d21/a00006_imadomain}{}\subsection{Domain}\label{de/d21/a00006_imadomain}



\begin{DoxyCodeInclude}
  // Define a box2d from (-2,-3) to (3,5).
  box2d b = make::box2d(-2,-3, 3,5);
  // Initialize an image with b as domain.
  image2d<int> ima(b);

  std::cout << "b = " << b << std::endl;
  std::cout << "domain = " << ima.domain() << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
b = [(-2,-3)..(3,5)]
domain = [(-2,-3)..(3,5)]
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  // Create an image on a 2D box
  // with 10 columns and 10 rows.
  image2d<bool> ima(make::box2d(10, 10));

  mln_site_(image2d<bool>) p1(20, 20);
  mln_site_(image2d<bool>) p2(3, 3);

  std::cout << "has(p1)? "
            << (ima.has(p1) ? "true" : "false")
            << std::endl;

  std::cout << "has(p2)? "
            << (ima.has(p2) ? "true" : "false")
            << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
has(p1)? false
has(p2)? true
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  point2d p(9,9);

  // At (9, 9), both values change.
  ima1(p) = 'M';
  ima2(p) = 'W';

  bool b = (ima1(p) == ima2(p));
  std::cout << (b ? "True" : "False") << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
False
\end{DoxyCodeInclude}


\hypertarget{de/d21/a00006_imaborder}{}\subsection{Border and extension}\label{de/d21/a00006_imaborder}
\hypertarget{de/d21/a00006_imabordersection}{}\subsubsection{Image border}\label{de/d21/a00006_imabordersection}



\begin{DoxyCodeInclude}
  bool vals[3][3] = { { 0, 1, 1 },
                      { 1, 0, 0 },
                      { 1, 1, 0 } };

  image2d<bool> ima_def = make::image(vals);
  border::fill(ima_def, false);
  debug::println_with_border(ima_def);

  std::cout << "===========" << std::endl << std::endl;

  border::thickness = 0;
  image2d<bool> ima_bt0 = make::image(vals);
  debug::println_with_border(ima_bt0);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
- - - - - - - - - 
- - - - - - - - - 
- - - - - - - - - 
- - - - | | - - - 
- - - | - - - - - 
- - - | | - - - - 
- - - - - - - - - 
- - - - - - - - - 
- - - - - - - - - 

===========

- | | 
| - - 
| | - 

\end{DoxyCodeInclude}


\hypertarget{de/d21/a00006_imextgeneral}{}\subsubsection{Generality on image extension}\label{de/d21/a00006_imextgeneral}
imamorphed \hypertarget{de/d21/a00006_extexample}{}\subsubsection{Different extensions}\label{de/d21/a00006_extexample}



\begin{DoxyCodeInclude}
  image2d<rgb8> lena;
  io::ppm::load(lena, MLN_IMG_DIR "/small.ppm");
  box2d bbox_enlarged = lena.domain();
  bbox_enlarged.enlarge(border::thickness);
  mln_VAR(ima_roi, lena | fun::p2b::big_chess<box2d>(lena.domain(), 10));
\end{DoxyCodeInclude}










\hypertarget{de/d21/a00006_extval}{}\paragraph{Extension with a value}\label{de/d21/a00006_extval}



\begin{DoxyCodeInclude}
  mln_VAR(ext_with_val, extended_to(extend(ima_roi, literal::blue), bbox_enlarged
      ));
\end{DoxyCodeInclude}






\hypertarget{de/d21/a00006_extfun}{}\paragraph{Extension with a function}\label{de/d21/a00006_extfun}



\begin{DoxyCodeInclude}
namespace mln
{

  struct my_ext : public Function_v2v<my_ext>
  {

    typedef value::rgb8 result;

    value::rgb8 operator()(const point2d& p) const
    {
      if ((p.row() + p.col()) % 20)
        return literal::black;
      return literal::white;
    }

  };

} // end of namespace mln
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  mln_VAR(ext_with_fun, extended_to(extend(ima_roi, my_ext()), bbox_enlarged));
\end{DoxyCodeInclude}






\hypertarget{de/d21/a00006_extima}{}\paragraph{Extension with an image}\label{de/d21/a00006_extima}



\begin{DoxyCodeInclude}
  mln_VAR(ext_with_ima, extend(ima_roi, lena));
\end{DoxyCodeInclude}













\begin{DoxyCodeInclude}
  // Default border size is set to 0.

  // Image defined on a box2d from
  // (0, 0) to (2, 2)
  image2d<int> ima1(2, 3);

  std::cout << "ima1.has(0, 0) : "
            << ima1.has(point2d(0, 0)) << std::endl;

  std::cout << "ima1.has(-3, 0) : "
            << ima1.has(point2d(-3, 0)) << std::endl;

  std::cout << "ima1.has(2, 5) : "
            << ima1.has(point2d(2, 5)) << std::endl;

  std::cout << "=========" << std::endl;

  // Set default border size to 0.
  border::thickness = 0;

  // Image defined on a box2d from
  // (0, 0) to (2, 2)
  image2d<int> ima2(2, 3);

  std::cout << "ima2.has(0, 0) : "
            << ima2.has(point2d(0, 0)) << std::endl;

  std::cout << "ima2.has(-3, 0) : "
            << ima2.has(point2d(-3, 0)) << std::endl;

  std::cout << "ima2.has(2, 5) : "
            << ima2.has(point2d(2, 5)) << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
ima1.has(0, 0) : 1
ima1.has(-3, 0) : 1
ima1.has(2, 5) : 1
=========
ima2.has(0, 0) : 1
ima2.has(-3, 0) : 0
ima2.has(2, 5) : 0
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  border::thickness = 30;

  // Declare the image to be rotated.
  image2d<value::rgb8> ima1_(220, 220);
  data::fill(ima1_, literal::cyan);
  border::fill(ima1_, literal::yellow);
  // Set an infinite extension.
  mln_VAR(ima1, extend(ima1_, pw::cst(literal::yellow)));

  // Declare the output image.
  image2d<value::rgb8> ima2(220, 220);
  data::fill(ima2, literal::cyan);
  border::fill(ima2, literal::yellow);

  box2d extended_domain= ima1.domain();
  extended_domain.enlarge(border::thickness);

  // Draw the domain bounding box
  draw::box(ima1, geom::bbox(ima1_), literal::red);
  // Save the image, including its border.
  doc::ppmsave(ima1 | extended_domain, "ima2d-rot");

  // Define and apply a point-wise rotation
  fun::x2x::rotation<2,float> rot1(0.5, literal::zero);
  image2d<value::rgb8>::fwd_piter p(ima1.domain());
  for_all(p)
  {
    algebra::vec<2,float> pv = p.to_site().to_vec();
    algebra::vec<2,float> v = rot1.inv()(pv);
    ima2(p) = ima1(v);
  }

  draw::box(ima2, ima2.bbox(), literal::red);
  doc::ppmsave(extended_to(ima2, extended_domain), "ima2d-rot");
\end{DoxyCodeInclude}













\begin{DoxyCodeInclude}
  my_routine(ima | ima.domain());
\end{DoxyCodeInclude}


\hypertarget{de/d21/a00006_imainterface}{}\subsection{Interface}\label{de/d21/a00006_imainterface}
\hypertarget{de/d21/a00006_imaio}{}\subsection{Load and save images}\label{de/d21/a00006_imaio}



\begin{DoxyCodeInclude}
  image2d<bool> ima;
  io::pbm::load(ima, MLN_DOC_DIR "/img/small.pbm");
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  io::pbm::save(ima, MLN_DOC_DIR "/figures/ima_save.pbm");
\end{DoxyCodeInclude}


\hypertarget{de/d21/a00006_imacreate}{}\subsection{Create an image}\label{de/d21/a00006_imacreate}



\begin{DoxyCodeInclude}
  // Build an empty image;
  image2d<value::int_u8> img1a;

  // Build an image with 2 rows
  // and 3 columns sites
  image2d<value::int_u8> img1b(box2d(2, 3));
  image2d<value::int_u8> img1c(2, 3);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  bool vals[6][5] = {
      {0, 1, 1, 0, 0},
      {0, 1, 1, 0, 0},
      {0, 0, 0, 0, 0},
      {1, 1, 0, 1, 0},
      {1, 0, 1, 1, 1},
      {1, 0, 0, 0, 0}
  };
  image2d<bool> ima = make::image(vals);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  image2d<value::int_u8> img2a(2, 3);
  image2d<value::int_u8> img2b;

  initialize(img2b, img2a);
  data::fill(img2b, img2a);
\end{DoxyCodeInclude}


\hyperlink{a00011_fillop}{Fill} \hypertarget{de/d21/a00006_imaaccessmodval}{}\subsection{Access and modify values}\label{de/d21/a00006_imaaccessmodval}



\begin{DoxyCodeInclude}
  box2d b(2,3);
  image2d<value::int_u8> ima(b);

  // On image2d, Site <=> point2d
  point2d p(1, 2);

  // Associate '9' as value for the site/point2d (1,2).
  // The value is returned by reference and can be changed.
  opt::at(ima, 1,2) = 9;
  std::cout << "opt::at(ima, 1,2) = " << opt::at(ima, 1,2)
            << std::endl;
  std::cout << "ima(p) = " << ima(p) << std::endl;

  std::cout << "---" << std::endl;


  // Associate '2' as value for the site/point2d (1,2).
  // The value is returned by reference
  // and can be changed as well.
  ima(p) = 2;
  std::cout << "opt::at(ima, 1,2) = " << opt::at(ima, 1,2)
            << std::endl;
  std::cout << "ima(p) = " << ima(p) << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
opt::at(ima, 1,2) = 9
ima(p) = 9
---
opt::at(ima, 1,2) = 2
ima(p) = 2
\end{DoxyCodeInclude}


\hyperlink{a00009}{Iterators} \hypertarget{de/d21/a00006_imasize}{}\subsection{Image size}\label{de/d21/a00006_imasize}



\begin{DoxyCodeInclude}
  image2d<int> ima(make::box2d(0,0, 10,12));

  std::cout << "nrows = " << ima.nrows()
            << " - "
            << "ncols = " << ima.ncols()
            << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
nrows = 11 - ncols = 13
\end{DoxyCodeInclude}


 \hypertarget{winneigh}{}\section{Structural elements: Window and neighborhood}\label{winneigh}
\hypertarget{de/d5e/a00007_sedef}{}\subsection{Define an element}\label{de/d5e/a00007_sedef}
\hypertarget{de/d5e/a00007_winwin}{}\subsubsection{Window}\label{de/d5e/a00007_winwin}
\hypertarget{de/d5e/a00007_neighborhood}{}\subsubsection{Neighborhood}\label{de/d5e/a00007_neighborhood}



\begin{DoxyCodeInclude}
  label_8 nlabels;
  image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
\end{DoxyCodeInclude}


\hypertarget{de/d5e/a00007_customse}{}\subsubsection{Custom structural elements}\label{de/d5e/a00007_customse}



\begin{DoxyCodeInclude}
  window2d win;
  win.insert(-1, -1);
  win.insert(-1,  0);
  win.insert(-1,  1);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
o -
o X 
o - 
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  bool b[9]     =   { 1, 0, 0,
                      1, 0, 0,
                      1, 0, 0 };

  bool b2[3][3] = { { 1, 0, 0 },
                    { 1, 0, 0 },
                    { 1, 0, 0 } };

  window2d win = convert::to<window2d>(b);
  window2d win2 = convert::to<window2d>(b2);
\end{DoxyCodeInclude}


\hypertarget{de/d5e/a00007_convneighwin}{}\subsubsection{Conversion between Neighborhoods and Windows}\label{de/d5e/a00007_convneighwin}
 \hypertarget{sitesandco}{}\section{Sites, psites and dpoints}\label{sitesandco}
\hypertarget{d4/dee/a00008_sitessite}{}\subsection{Need for site}\label{d4/dee/a00008_sitessite}



\begin{DoxyCodeInclude}
 c 0 1 2 3
r
  +-+-+-+-+
0 | |x| | |
  +-+-+-+-+
1 | | | | |
  +-+-+-+-+
\end{DoxyCodeInclude}


\hypertarget{d4/dee/a00008_sitespsite}{}\subsection{Need for psite}\label{d4/dee/a00008_sitespsite}



\begin{DoxyCodeInclude}
unsigned my_values(const mln::point2d& p)
{
  if (p.row() == 0)
    return 8;
  return 9;
}
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  p_array<point2d> arr;
  arr.append(point2d(3, 6));
  arr.append(point2d(3, 7));
  arr.append(point2d(3, 8));
  arr.append(point2d(4, 8));
  arr.append(point2d(4, 9));
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  mln_VAR(ima, my_values | arr);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
c  6 7 8 9
r
   +-+-+-+
3  | |x| |
   +-+-+-+-+
4      | | |
       +-+-+
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
arr[] = 0 1 2 3 4
       +-+-+-+-+-+
       | |x| | | |
       +-+-+-+-+-+
\end{DoxyCodeInclude}


\hypertarget{d4/dee/a00008_sitespsitensite}{}\subsection{From psite to site}\label{d4/dee/a00008_sitespsitensite}
\hypertarget{d4/dee/a00008_sitesdpoint}{}\subsection{Dpoint}\label{d4/dee/a00008_sitesdpoint}



\begin{DoxyCodeInclude}
  dpoint2d dp(-1,0);
  point2d p(1,1);

  std::cout << p + dp << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
(0,1)
\end{DoxyCodeInclude}


 \hypertarget{iterators}{}\section{Iterators}\label{iterators}



\begin{DoxyCodeInclude}
  box2d b(3, 2);
  mln_piter_(box2d) p(b);

  for_all(p)
    std::cout << p; //prints every site coordinates.
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
(0,0)(0,1)(1,0)(1,1)(2,0)(2,1)
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
template <typename I>
void fill(I& ima, mln_value(I) v)
{
  mln_piter(I) p(ima.domain());
  for_all(p)
    ima(p) = v;
}
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
template <typename I, typename J>
void paste(const I& data, J& dest)
{
  mln_piter(I) p(data.domain());
  for_all(p)
  dest(p) = data(p);
}
\end{DoxyCodeInclude}


\hyperlink{a00015}{Useful macros}  \hypertarget{imamemmgmt}{}\section{Memory management}\label{imamemmgmt}



\begin{DoxyCodeInclude}
  image2d<int> ima1(box2d(2, 3));
  image2d<int> ima2;
  point2d p(1,2);

  ima2 = ima1; // ima1.id() == ima2.id()
  // and both point to the same memory area.

  ima2(p) = 2; // ima1 is modified as well.

  // prints "2 - 2"
  std::cout << ima2(p) << " - " << ima1(p) << std::endl;
  // prints "true"
  std::cout << (ima2.id_() == ima1.id_()) << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  image2d<int> ima1(5, 5);
  image2d<int> ima3 = duplicate(ima1); // Makes a deep copy.

  point2d p(2, 2);
  ima3(p) = 3;

  std::cout << ima3(p) << " - " << ima1(p) << std::endl;
  std::cout << (ima3.id_() == ima1.id_()) << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
3 - 0
0
\end{DoxyCodeInclude}


 \hypertarget{basicops}{}\section{Basic routines}\label{basicops}
\hypertarget{da/d45/a00011_fillop}{}\subsection{Fill}\label{da/d45/a00011_fillop}



\begin{DoxyCodeInclude}
  image2d<char> imga(5, 5);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  data::fill(imga, 'a');
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  data::fill((imga | box2d(1,2)).rw(), 'a');
\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_pasteop}{}\subsection{Paste}\label{da/d45/a00011_pasteop}



\begin{DoxyCodeInclude}
  image2d<unsigned char> imgb(make::box2d(5,5, 7,8));
  // Initialize imga with the same domain as imgb.
  image2d<unsigned char> imga(imgb.domain());

  // Initialize the image values.
  data::fill(imgb, 'b');

  // Paste the content of imgb in imga.
  data::paste(imgb, imga);

  debug::println(imga);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
98 98 98 98 
98 98 98 98 
98 98 98 98 

\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  image2d<int> ima1(5, 5);
  image2d<int> ima2(10, 10);

  std::cout << "ima1.domain() = " << ima1.domain()
            << std::endl;
  std::cout << "ima2.domain() = " << ima2.domain()
            << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  image2d<int> ima1(5, 5);
  image2d<int> ima2(10, 10);

  std::cout << "ima1.domain() = " << ima1.domain()
            << std::endl;
  std::cout << "ima2.domain() = " << ima2.domain()
            << std::endl;
\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_blobs}{}\subsection{Blobs}\label{da/d45/a00011_blobs}



\begin{DoxyCodeInclude}
  bool vals[6][5] = {
      {0, 1, 1, 0, 0},
      {0, 1, 1, 0, 0},
      {0, 0, 0, 0, 0},
      {1, 1, 0, 1, 0},
      {1, 0, 1, 1, 1},
      {1, 0, 0, 0, 0}
  };
  image2d<bool> ima = make::image(vals);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  label_8 nlabels;
  image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
\end{DoxyCodeInclude}






\hypertarget{da/d45/a00011_logicalnot}{}\subsection{Logical not}\label{da/d45/a00011_logicalnot}



\begin{DoxyCodeInclude}
  bool vals[5][5] = {
    {1, 0, 1, 0, 0},
    {0, 1, 0, 1, 0},
    {1, 0, 1, 0, 0},
    {0, 1, 0, 1, 0},
    {0, 1, 0, 1, 0}
  };
  image2d<bool> ima = make::image(vals);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  image2d<bool> ima_neg = logical::not_(ima);
\end{DoxyCodeInclude}













\begin{DoxyCodeInclude}
  logical::not_inplace(ima);
\end{DoxyCodeInclude}






\hypertarget{da/d45/a00011_compute}{}\subsection{Compute}\label{da/d45/a00011_compute}
\hypertarget{da/d45/a00011_accu}{}\subsubsection{Accumulators}\label{da/d45/a00011_accu}



\begin{DoxyCodeInclude}
data::compute(accu::meta::stat::max, ima);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  data::compute(accu::meta::stat::max(), ima);
\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_exlblcompute}{}\subsubsection{Example with labeling::compute()}\label{da/d45/a00011_exlblcompute}



\begin{DoxyCodeInclude}
  bool vals[6][5] = {
      {0, 1, 1, 0, 0},
      {0, 1, 1, 0, 0},
      {0, 0, 0, 0, 0},
      {1, 1, 0, 1, 0},
      {1, 0, 1, 1, 1},
      {1, 0, 0, 0, 0}
  };
  image2d<bool> ima = make::image(vals);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  label_8 nlabels;
  image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  util::array<box2d> boxes =
      labeling::compute(accu::meta::shape::bbox(),
                        lbl,
                        nlabels);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  for (unsigned i = 1; i <= nlabels; ++i)
    std::cout << boxes[i] << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
[(0,1)..(1,2)]
[(3,0)..(5,1)]
[(3,2)..(4,4)]
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  unsigned nsites = geom::nsites(ima);
\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_partima}{}\subsection{Working with parts of an image}\label{da/d45/a00011_partima}



\begin{DoxyCodeInclude}
//function_p2b
bool my_function_p2b(mln::point2d p);

//function_p2v
//V is the value type used in the image.
template <typename V>
V my_function_p2v(mln::point2d p);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  bool vals[6][5] = {
      {0, 1, 1, 0, 0},
      {0, 1, 1, 0, 0},
      {0, 0, 0, 0, 0},
      {1, 1, 0, 1, 0},
      {1, 0, 1, 1, 1},
      {1, 0, 0, 0, 0}
  };
  image2d<bool> ima = make::image(vals);
\end{DoxyCodeInclude}






\hypertarget{da/d45/a00011_restrictsiteset}{}\subsubsection{Restrict an image with a site set}\label{da/d45/a00011_restrictsiteset}



\begin{DoxyCodeInclude}
  p_array<point2d> arr;

  // We add two points in the array.
  arr.append(point2d(0, 1));
  arr.append(point2d(4, 0));

  // We restrict the image to the sites
  // contained in arr and fill these ones
  // with 0.
  // We must call "rw()" here.
  data::fill((ima | arr).rw(), 0);

  debug::println((ima | arr));

  mln_VAR(ima2, ima | arr);
  // We do not need to call "rw()" here.
  data::fill(ima2, 0);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  - 
    
    
    
-   

  - 
    
    
    
-   

\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_restrictpred}{}\subsubsection{Restrict an image with a predicate}\label{da/d45/a00011_restrictpred}



\begin{DoxyCodeInclude}
  label_8 nlabels;
  image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  mln_VAR(lbl_2, lbl | (pw::value(lbl) == pw::cst(2u)));
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  image2d<rgb8> ima2;
  initialize(ima2, ima);
  data::fill(ima2, literal::black);

  data::fill((ima2 | lbl_2.domain()).rw(), literal::red);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
  label_8 nlabels;
  image2d<label_8> lab = labeling::blobs(ima, c4(), nlabels);

  image2d<rgb8> ima2;
  initialize(ima2, ima);
  data::fill(ima2, literal::black);

  data::fill((ima2 | (pw::value(lab) == pw::cst(2u))).rw(), literal::red);
\end{DoxyCodeInclude}


\hypertarget{da/d45/a00011_restrictcfun}{}\subsubsection{Restrict an image with a C function}\label{da/d45/a00011_restrictcfun}



\begin{DoxyCodeInclude}
bool row_oddity(mln::point2d p)
{
  return p.row() % 2;
}
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  image2d<rgb8> ima2;
  initialize(ima2, ima);
  data::fill(ima2, literal::black);

  data::fill((ima2 | row_oddity).rw(), literal::red);
\end{DoxyCodeInclude}









\begin{DoxyCodeInclude}
ima | sub_D
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
0 1 0
1 1 1
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  mln_VAR(imab1, ima | (pw::value(ima) == pw::cst(1u)));
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
1 
1 1 1
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
box2d b1(1,0, 1, 2);
mln_VAR(imac, imab1 | b1);

// Print:
// 1 1 1
debug::prinln(imac);

box2d b2(0,0, 1, 1);
// Will fail at runtime.
// ima.domain().has((0,0)) is false.
mln_VAR(imad, imab1 | b2);
debug::prinln(imad);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
ima / sub_D
\end{DoxyCodeInclude}


 \hypertarget{inputoutput}{}\section{Input / Output}\label{inputoutput}
\hypertarget{df/d86/a00012_ioim}{}\subsection{ImageMagick}\label{df/d86/a00012_ioim}
\hypertarget{df/d86/a00012_iodcm}{}\subsection{GDCM}\label{df/d86/a00012_iodcm}
 \hypertarget{graphandima}{}\section{Graphs and images}\label{graphandima}
\hypertarget{d7/dd4/a00013_graphdesc}{}\subsection{Description}\label{d7/dd4/a00013_graphdesc}
\hypertarget{d7/dd4/a00013_graphexample}{}\subsection{Example}\label{d7/dd4/a00013_graphexample}



\begin{DoxyCodeInclude}
     0 1 2 3 4
  .-----------
0 |  0       2
1 |    \   / |
2 |      1   |
3 |       \  |
4 |        3-4
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  util::graph g;

  for (unsigned i = 0; i < 5; ++i)
    g.add_vertex(); // Add vertex 'i';
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  g.add_edge(0, 1); // Associated to edge 0.
  g.add_edge(1, 2); // Associated to edge 1.
  g.add_edge(1, 3); // Associated to edge 2.
  g.add_edge(3, 4); // Associated to edge 3.
  g.add_edge(4, 2); // Associated to edge 4.
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  typedef fun::i2v::array<point2d> F;
  F f(5); // We need to map 5 vertices.
  f(0) = point2d(0, 0);
  f(1) = point2d(2, 2);
  f(2) = point2d(0, 4);
  f(3) = point2d(4, 3);
  f(4) = point2d(4, 4);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  typedef p_vertices<util::graph, F> pv_t;
  pv_t pv(g, f);
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
template <typename S>
struct viota_t : public mln::Function_v2v< viota_t<S> >
{
  typedef unsigned result;

  viota_t(unsigned size)
  {
    v_.resize(size);
    for(unsigned i = 0; i < size; ++i)
      v_[i] = 10 + i;
  }

  unsigned
  operator()(const mln_psite(S)& p) const
  {
    return v_[p.v().id()];
  }

  protected:
    std::vector<result> v_;
};
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}

  // Constructs an image
  viota_t<pv_t> viota(pv.nsites());
  mln_VAR(graph_vertices_ima, viota | pv);

  //Prints each vertex and its associated data.
  mln_piter_(graph_vertices_ima_t) p(graph_vertices_ima.domain());
  for_all(p)
    std::cout << "graph_vertices_ima(" << p << ") = "
              << graph_vertices_ima(p) << std::endl;

\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
graph_vertices_ima((0,0)) = 10
graph_vertices_ima((2,2)) = 11
graph_vertices_ima((0,4)) = 12
graph_vertices_ima((4,3)) = 13
graph_vertices_ima((4,4)) = 14
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
  // Function which maps sites to data.
  viota_t viota(g.v_nmax());

  // Iterator on vertices.
  mln_vertex_iter_(util::graph) v(g);

  // Prints each vertex and its associated value.
  for_all(v)
    std::cout << v << " : " << viota(v) << std::endl;
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
0 : 10
1 : 11
2 : 12
3 : 13
4 : 14
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
    // Iterator on vertices.
    mln_vertex_iter_(util::graph) v(g);

    // Iterator on v's edges.
    mln_vertex_nbh_edge_iter_(util::graph) e(v);

    // Prints the graph
    // List all edges for each vertex.
    for_all(v)
    {
      std::cout << v << " : ";
      for_all(e)
        std::cout << e << " ";
      std::cout << std::endl;
    }
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
0 : (0,1) 
1 : (0,1) (1,2) (1,3) 
2 : (1,2) (2,4) 
3 : (1,3) (3,4) 
4 : (3,4) (2,4) 
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
    // Iterator on edges.
    mln_edge_iter_(util::graph) e(g);

    // Iterator on edges adjacent to e.
    mln_edge_nbh_edge_iter_(util::graph) ne(e);

    // Prints the graph
    // List all adjacent edges for each edge.
    for_all(e)
    {
      std::cout << e << " : ";
      for_all(ne)
        std::cout << ne << " ";
      std::cout << std::endl;
    }
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
(0,1) : (1,2) (1,3) 
(1,2) : (0,1) (1,3) (2,4) 
(1,3) : (0,1) (1,2) (3,4) 
(3,4) : (1,3) (2,4) 
(2,4) : (1,2) (3,4) 
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
    // Iterator on vertices.
    mln_vertex_iter_(util::graph) v(g);

    // Iterator on vertices adjacent to v.
    mln_vertex_nbh_vertex_iter_(util::graph) nv(v);

    // Prints the graph
    // List all adjacent edges for each edge.
    for_all(v)
    {
      std::cout << v << " : ";
      for_all(nv)
        std::cout << nv << " ";
      std::cout << std::endl;
    }
\end{DoxyCodeInclude}





\begin{DoxyCodeInclude}
0 : 1 
1 : 0 2 3 
2 : 1 4 
3 : 1 4 
4 : 3 2 
\end{DoxyCodeInclude}


 \hypertarget{globalvars}{}\section{Useful global variables}\label{globalvars}
 \hypertarget{macros}{}\section{Useful macros}\label{macros}
\hypertarget{dd/d1b/a00015_vardeclmacros}{}\subsection{Variable declaration macros}\label{dd/d1b/a00015_vardeclmacros}
\hypertarget{dd/d1b/a00015_macrositerators}{}\subsection{Iterator type macros}\label{dd/d1b/a00015_macrositerators}
\hypertarget{dd/d1b/a00015_macrosdefit}{}\subsubsection{Default iterator types}\label{dd/d1b/a00015_macrosdefit}
\hypertarget{dd/d1b/a00015_macrosfwdit}{}\subsubsection{Forward iterator types}\label{dd/d1b/a00015_macrosfwdit}
\hypertarget{dd/d1b/a00015_macrosbkdit}{}\subsubsection{Backward iterators}\label{dd/d1b/a00015_macrosbkdit}
\hypertarget{dd/d1b/a00015_macrosgraphit}{}\subsubsection{Graph iterators}\label{dd/d1b/a00015_macrosgraphit}
 \hypertarget{compilerrors}{}\section{Common Compilation Errors}\label{compilerrors}
 