olena: olena-2.0-552-g00a1e34 Explain how to iterate over an image in tutorial.

* doc/examples/split/tuto3_rw_image-3.cc.raw, * doc/examples/split/tuto3_rw_image-4.cc.raw, * doc/examples/split/tuto3_rw_image-5.cc.raw, * doc/examples/split/tuto3_rw_image-6.cc.raw, * doc/examples/split/tuto3_rw_image-7.cc.raw, * doc/examples/split/tuto3_rw_image-8.cc.raw: Regen. * doc/examples/tuto3_rw_image.cc: Add an example with iterators. * doc/tutorial.tex: Add more explanations on iterators. --- milena/ChangeLog | 15 +++++++++ milena/doc/examples/split/tuto3_rw_image-3.cc.raw | 6 ++-- milena/doc/examples/split/tuto3_rw_image-4.cc.raw | 2 +- milena/doc/examples/split/tuto3_rw_image-5.cc.raw | 5 ++- milena/doc/examples/split/tuto3_rw_image-6.cc.raw | 3 +- milena/doc/examples/split/tuto3_rw_image-7.cc.raw | 2 +- ...3_rw_image-7.cc.raw => tuto3_rw_image-8.cc.raw} | 0 milena/doc/examples/tuto3_rw_image.cc | 6 ++++ milena/doc/tutorial.tex | 31 ++++++++++++------- 9 files changed, 50 insertions(+), 20 deletions(-) copy milena/doc/examples/split/{tuto3_rw_image-7.cc.raw => tuto3_rw_image-8.cc.raw} (100%) diff --git a/milena/ChangeLog b/milena/ChangeLog index c4a23a0..6c15ccc 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,20 @@ 2013-04-19 Guillaume Lazzara <z@lrde.epita.fr> + Explain how to iterate over an image in tutorial. + + * doc/examples/split/tuto3_rw_image-3.cc.raw, + * doc/examples/split/tuto3_rw_image-4.cc.raw, + * doc/examples/split/tuto3_rw_image-5.cc.raw, + * doc/examples/split/tuto3_rw_image-6.cc.raw, + * doc/examples/split/tuto3_rw_image-7.cc.raw, + * doc/examples/split/tuto3_rw_image-8.cc.raw: Regen. + + * doc/examples/tuto3_rw_image.cc: Add an example with iterators. + + * doc/tutorial.tex: Add more explanations on iterators. + +2013-04-19 Guillaume Lazzara <z@lrde.epita.fr> + Introduce image transformation module in documentation. * doc/mln/main.dox: Create new group. diff --git a/milena/doc/examples/split/tuto3_rw_image-3.cc.raw b/milena/doc/examples/split/tuto3_rw_image-3.cc.raw index f25ab40..88b5a64 100644 --- a/milena/doc/examples/split/tuto3_rw_image-3.cc.raw +++ b/milena/doc/examples/split/tuto3_rw_image-3.cc.raw @@ -1,3 +1,3 @@ - for (def::coord row = 20; row < 30; ++row) - for (def::coord col = 20; col < 30; ++col) - ima(point2d(row, col)) = literal::blue; + mln_piter(image2d<value::rgb8>) p(ima.domain()); + for_all(p) + ima(p) = literal::red; diff --git a/milena/doc/examples/split/tuto3_rw_image-4.cc.raw b/milena/doc/examples/split/tuto3_rw_image-4.cc.raw index 06559c5..f25ab40 100644 --- a/milena/doc/examples/split/tuto3_rw_image-4.cc.raw +++ b/milena/doc/examples/split/tuto3_rw_image-4.cc.raw @@ -1,3 +1,3 @@ for (def::coord row = 20; row < 30; ++row) for (def::coord col = 20; col < 30; ++col) - opt::at(ima, row, col) = literal::blue; + ima(point2d(row, col)) = literal::blue; diff --git a/milena/doc/examples/split/tuto3_rw_image-5.cc.raw b/milena/doc/examples/split/tuto3_rw_image-5.cc.raw index d98037c..06559c5 100644 --- a/milena/doc/examples/split/tuto3_rw_image-5.cc.raw +++ b/milena/doc/examples/split/tuto3_rw_image-5.cc.raw @@ -1,2 +1,3 @@ - image2d<value::rgb8> lena; - io::ppm::load(lena, MLN_IMG_DIR "/small.ppm"); + for (def::coord row = 20; row < 30; ++row) + for (def::coord col = 20; col < 30; ++col) + opt::at(ima, row, col) = literal::blue; diff --git a/milena/doc/examples/split/tuto3_rw_image-6.cc.raw b/milena/doc/examples/split/tuto3_rw_image-6.cc.raw index 10eb29f..d98037c 100644 --- a/milena/doc/examples/split/tuto3_rw_image-6.cc.raw +++ b/milena/doc/examples/split/tuto3_rw_image-6.cc.raw @@ -1 +1,2 @@ - data::fill(ima, lena); + image2d<value::rgb8> lena; + io::ppm::load(lena, MLN_IMG_DIR "/small.ppm"); diff --git a/milena/doc/examples/split/tuto3_rw_image-7.cc.raw b/milena/doc/examples/split/tuto3_rw_image-7.cc.raw index d362105..10eb29f 100644 --- a/milena/doc/examples/split/tuto3_rw_image-7.cc.raw +++ b/milena/doc/examples/split/tuto3_rw_image-7.cc.raw @@ -1 +1 @@ - data::paste(ima, lena); + data::fill(ima, lena); diff --git a/milena/doc/examples/split/tuto3_rw_image-7.cc.raw b/milena/doc/examples/split/tuto3_rw_image-8.cc.raw similarity index 100% copy from milena/doc/examples/split/tuto3_rw_image-7.cc.raw copy to milena/doc/examples/split/tuto3_rw_image-8.cc.raw diff --git a/milena/doc/examples/tuto3_rw_image.cc b/milena/doc/examples/tuto3_rw_image.cc index 14ba056..6e84f32 100644 --- a/milena/doc/examples/tuto3_rw_image.cc +++ b/milena/doc/examples/tuto3_rw_image.cc @@ -49,6 +49,12 @@ int main() // \} // \{ + mln_piter(image2d<value::rgb8>) p(ima.domain()); + for_all(p) + ima(p) = literal::red; + // \} + + // \{ for (def::coord row = 20; row < 30; ++row) for (def::coord col = 20; col < 30; ++col) ima(point2d(row, col)) = literal::blue; diff --git a/milena/doc/tutorial.tex b/milena/doc/tutorial.tex index e67a9da..3e016ed 100644 --- a/milena/doc/tutorial.tex +++ b/milena/doc/tutorial.tex @@ -1474,13 +1474,20 @@ After this step you should know how to: First create an empty color image with a \var{box2d} of 40x40 as domain. \doxycode[1]{tuto3_rw_image} -If you want to initialize the image with the color red, simply call data::fill as follows: +If you want to initialize the image with the color red, you can +iterate over all the image pixels using iterators: +\doxycode[3]{tuto3_rw_image} + +Or simply call data::fill as follows: \doxycode[2]{tuto3_rw_image} -Updating a site value is also possible using \code{operator()} or the -\code{opt::at()} routine. Here we create a blue square of 10x10 pixels from site -(20, 20) to (30, 30). -\doxycode[3]{tuto3_rw_image} +Updating a site value is also possible using the \code{opt::at()} +routine. Here we create a blue square of 10x10 pixels from site (20, +20) to (30, 30). +\doxycode[5]{tuto3_rw_image} + +The following code with image2d::operator() is also possible but may +be slower because of the creation of a point2d. \doxycode[4]{tuto3_rw_image} The corresponding image: \\ @@ -1489,27 +1496,27 @@ The corresponding image: \\ An image can also be initialized/modified thanks to another image. Let's load a new image. -\doxycode[5]{tuto3_rw_image} +\doxycode[6]{tuto3_rw_image} \var{lena} looks like: \\ \doxyimg{small-enlarged}{3cm} If we want to initialize \var{ima} with \var{lena}, we can use \code{data::fill}: -\doxycode[6]{tuto3_rw_image} +\doxycode[7]{tuto3_rw_image} Output: \\ \doxyfigure[2]{tuto3_rw_image}{3cm} \\ -Note that to fill an image with some data, the image domain \must be smaller -or equal to the data. +Note that to fill an image with some data, the image domain \must be +smaller or equal to the data. Likewise, it is possible to paste data from an image to another: -\doxycode[7]{tuto3_rw_image} +\doxycode[8]{tuto3_rw_image} Output: \\ \doxyfigure[3]{tuto3_rw_image}{3cm} -More details can be found in sections \doxyref{imaaccessmodval}, \doxyref{fillop} and \doxyref{pasteop} in -the reference guide. +More details can be found in sections \doxyref{imaaccessmodval}, +\doxyref{fillop} and \doxyref{pasteop} in the reference guide. \vspace{2cm} \begin{center} -- 1.7.2.5
participants (1)
-
Guillaume Lazzara