Commit 8ede84af authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add step 3 in tutorial.

	* doc/tutorial/figures/tuto3_rw_image-1.ppm
	* doc/tutorial/figures/tuto3_rw_image-2.ppm
	* doc/tutorial/figures/tuto3_rw_image-3.ppm
	* doc/tutorial/outputs/tuto3_rw_image.txt: add new reference files.

	* doc/tutorial/samples/ima-load.cc.raw: rename as...
	* doc/tutorial/samples/ima-load.cc: ... this.

	* doc/tutorial/samples/ima-save.cc: extract less lines of code.

	* doc/tutorial/samples/Makefile.am,
	* doc/tutorial/samples/tuto3_rw_image.cc: add a new tutorial example.

	* doc/tutorial/tutorial.tex: write step 3.

	* Makefile.am,
	* img/small-enlarged.png,
	* img/small.png,
	* img/small.ppm: add new useful images and make them part of the
	distribution.

	* tests/data/Makefile.am: comment non activated test.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3132 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 1f74e72c
2009-01-05 Guillaume Lazzara <z@lrde.epita.fr>
Add step 3 in tutorial.
* doc/tutorial/figures/tuto3_rw_image-1.ppm
* doc/tutorial/figures/tuto3_rw_image-2.ppm
* doc/tutorial/figures/tuto3_rw_image-3.ppm
* doc/tutorial/outputs/tuto3_rw_image.txt: add new reference files.
* doc/tutorial/samples/ima-load.cc.raw: rename as...
* doc/tutorial/samples/ima-load.cc: ... this.
* doc/tutorial/samples/ima-save.cc: extract less lines of code.
* doc/tutorial/samples/Makefile.am,
* doc/tutorial/samples/tuto3_rw_image.cc: add a new tutorial example.
* doc/tutorial/tutorial.tex: write step 3.
* Makefile.am,
* img/small-enlarged.png,
* img/small.png,
* img/small.ppm: add new useful images and make them part of the
distribution.
* tests/data/Makefile.am: comment non activated test.
2009-01-05 Guillaume Lazzara <z@lrde.epita.fr>
 
Add is_valid and invalidate to util::graph
......@@ -35,6 +35,9 @@ img/picasso.pbm \
img/space_debris.pgm \
img/picasso.pgm \
img/small.pbm \
img/small-enlarged.png \
img/small.png \
img/small.ppm \
img/lena.ppm \
img/small.pgm
......
......@@ -44,8 +44,9 @@ noinst_PROGRAMS = \
win-create-1 \
win-create-2
noinst_PROGRAMS += \
tuto1_first_image
noinst_PROGRAMS += \
tuto1_first_image \
tuto3_rw_image
accu_right_instanciation_SOURCES = accu-right-instanciation.cc
borderthickness_SOURCES = borderthickness.cc
......@@ -88,6 +89,7 @@ win_create_1_SOURCES = win-create-1.cc
win_create_2_SOURCES = win-create-2.cc
tuto1_first_image_SOURCES = tuto1_first_image.cc
tuto3_rw_image_SOURCES = tuto3_rw_image.cc
all: clean-figures
mkdir -p $(OUTPUTS_BUILDDIR)
......
......@@ -3,7 +3,6 @@ int main()
{
using namespace mln;
// \{
bool vals[5][5] = {
{1, 0, 1, 0, 0},
{0, 1, 0, 1, 0},
......@@ -13,8 +12,7 @@ int main()
};
image2d<bool> ima = make::image(vals);
// ...
// \{
io::pbm::save(ima, "../figures/ima_save.pbm");
// \}
}
#include <mln/essential/2d.hh>
#include <tests/data.hh>
#include <doc/tutorial/tools/sample_utils.hh>
int main()
{
using namespace mln;
// \{
image2d<value::rgb16> ima(40, 40);
// \}
// \{
data::fill(ima, literal::red);
// \}
// \{
for (def::coord row = 20; row < 30; ++row)
for (def::coord col = 20; col < 30; ++col)
ima(point2d(row, col)) = literal::blue;
// \}
// \{
for (def::coord row = 20; row < 30; ++row)
for (def::coord col = 20; col < 30; ++col)
opt::at(ima, row, col) = literal::blue;
// \}
doc::ppmsave(ima, "tuto3_rw_image");
image2d<value::rgb16> ima2 = duplicate(ima);
// \{
image2d<value::rgb16> lena;
io::ppm::load(lena, MLN_IMG_DIR "/small.ppm");
// \}
// \{
data::fill(ima, lena);
// \}
doc::ppmsave(ima, "tuto3_rw_image");
ima = ima2;
// \{
data::paste(ima, lena);
// \}
doc::ppmsave(lena, "tuto3_rw_image");
}
......@@ -51,7 +51,7 @@
\label{#1}
\backslash endhtmlonly%
\backslash page #1 #2%
\backslash htmlonly%
\backslash htmlonly %
}
% #1 : section name
......@@ -60,13 +60,13 @@
\label{#1}
\backslash endhtmlonly%
\backslash section #1 #2%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxysubsection}[2]{%
\label{#1}
\backslash endhtmlonly%
\backslash subsection #1 #2%
\backslash htmlonly%
\backslash htmlonly %
}
% #1 - part number (Optional)
......@@ -74,19 +74,19 @@
\newcommand{\doxycode}[2][1]{
\backslash endhtmlonly%
\backslash include #2-#1.cc%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxyrawcode}[1]{
\backslash endhtmlonly%
\backslash include #1.cc.raw%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxyoutput}[1]{
\backslash endhtmlonly%
\backslash include #1.txt%
\backslash htmlonly%
\backslash htmlonly %
}
% Include file '#1' from a splitted output.
......@@ -95,25 +95,31 @@
\newcommand{\doxymoutput}[2][1]{
\backslash endhtmlonly%
\backslash include #2-#1.txt%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxyfigure}[3][1]{
\backslash endhtmlonly%
\backslash image html #2-#1.png%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxyimg}[1]{
\backslash endhtmlonly%
\backslash image html #1.png%
\backslash htmlonly %
}
\newcommand{\doxyref}[1]{
\backslash endhtmlonly%
\backslash ref #1%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\doxysee}[1]{
\backslash endhtmlonly%
\backslash see #1%
\backslash htmlonly%
\backslash htmlonly %
}
\newcommand{\tutotoc}[2]{%
......@@ -148,6 +154,10 @@ $$
\pgfimage[width=#3]{figures/#2-#1}%
\label{#1}%
}
\renewcommand{\doxyimg}[2]{%
\pgfimage[width=#2]{../../img/#1.png}%
\label{#1}%
}
\renewcommand{\doxyref}[1]{\ref{#1}}
\renewcommand{\doxysee}[1]{\ref{#1}}
\renewcommand{\tutotoc}[2]{}
......@@ -292,10 +302,11 @@ $$
\backslash page tutorial Tutorial
- \backslash subpage tutoforeword
- \backslash subpage loadnsave
- \backslash subpage tutofirstimage
- \backslash subpage tutochangeimage
- \backslash subpage tutogenericity
- \backslash subpage tutoconvimage
- \backslash subpage tutodataimage
- \backslash subpage tutowinneighb
- \backslash subpage tutograph
......@@ -313,6 +324,7 @@ $$
- \backslash subpage graphandima
- \backslash subpage arithmops
- \backslash subpage mathtools
- \backslash subpage debugtools
- \backslash subpage globalvars
- \backslash subpage macros
\backslash htmlonly
......@@ -342,19 +354,64 @@ A copy of the license is provided in the file COPYING.DOC.
- image2d
- typical use case
\begin{center}%
\hspace{1cm} Go to \doxyref{loadnsave}~ \longrightarrow%
\end{center}%
%====================================
\doxychapter{tutofirstimage}{Step 1: Your first image}
\doxychapter{loadnsave}{Step 1: Load and save images}
After this step you should know how to:
After this step you shoud know how to:
\begin{itemize}
\item create an image,
\item display an image in console mode,
\item load an image,
\item save an image.
\end{itemize}
\vspace{2cm}
Currently, Olena supports the following input image formats:
\begin{itemize}
\item PBM
\item PFM
\item PGM
\item PNM
\item PPM
\end{itemize}
This support is provided through two headers for each type, \header{save.hh} and
\header{load.hh}.
They are located in \hpath{mln/io/$<$image-format$>$/}.
Once the right header is included, the image can be loaded:
\doxycode{ima-load}
If you wan to save an image, simply call the save routine in the proper namespace:
\doxycode{ima-save}
According to the image value type, the proper file format must be chosen.
The supported file formats and their associated image value types are listed
in section \doxyref{imaio}.
\vspace{2cm}
\tutotoc{tutoforeword}{tutofirstimage}
%====================================
\doxychapter{tutofirstimage}{Step 2: Create your first image}
After this step you should know how to:
\begin{itemize}
\item create an image,
\item display an image in console mode.
\end{itemize}
The full example can be found in \doxyref{tuto1_first_image.cc}.
\vspace{2cm}
First, declare an array of bool which will represent the image grid. Each each
cell in this grid is a site and each cell contains a value, \val{true} or
\val{false}.
......@@ -370,6 +427,8 @@ several other ways described in section \doxyref{imacreate}.
To be sure that the data is correctly initialized, it is possible to display the
image in the standard output using debug::println.
\doxycode[3]{tuto1_first_image}
Output:
\doxyoutput{tuto1_first_image}
Finally, you may want to save the image. Since we use bool as image value, the
PBM format is the best choice. Therefore, we use io::pbm::save.
......@@ -381,25 +440,82 @@ The output image looks like the following:
In this first step we used a boolean image. Many other value types are available
though. A more detailed description can be found in section
\doxyref{imapossvalues}.
Likewise, according to the value type, the proper file format must be chosen.
The supported file formats are listed in section \doxyref{imaio}.
\tutotoc{tutoforeword}{tutochangeimage}
\vspace{2cm}
\begin{center}
\tutotoc{loadnsave}{tutochangeimage}
\end{center}
%====================================
\doxychapter{tutochangeimage}{Step 2: Read and write images}
\doxychapter{tutochangeimage}{Step 3: Read and write images}
After this step you should know how to:
\begin{itemize}
\item modify/initialize image values,
\item copy and paste data to an image.
\end{itemize}
The full example can be found in \doxyref{tuto3_rw_image.cc}.
\vspace{2cm}
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:
\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}
\doxycode[4]{tuto3_rw_image}
The corresponding image:
\doxyfigure[1]{tuto3_rw_image}
An image can also be initialized/modified thanks to another image.
Let's load a new image.
\doxycode[5]{tuto3_rw_image}
\var{lena} looks like:
\doxyimg{small-enlarged}
If we want to initialize \var{ima} with \var{lena}, we can use \code{data::fill}:
\doxycode[6]{tuto3_rw_image}
Output:
\doxyfigure[2]{tuto3_rw_image}
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}
Output:
\doxyfigure[3]{tuto3_rw_image}
More details can be found in section \doxyref{fillop} and \doxyref{pasteop} in
the reference guide.
\vspace{2cm}
\begin{center}
\tutotoc{tutofirstimage}{tutogenericity}
\end{center}
%====================================
\doxychapter{tutoconvimage}{Step 3: Conversion between image values}
\doxychapter{tutogenericity}{Step 4: Genericity and algorithms}
%====================================
\doxychapter{tutodataimage}{Step 4: Fill and paste data}
\doxychapter{tutoconvimage}{Step 5: Conversion between image values}
%====================================
\doxychapter{tutowinneighb}{Step 5: Using structural elements with algorithms}
\doxychapter{tutowinneighb}{Step 6: Using structural elements with algorithms}
%====================================
\doxychapter{tutograph}{Step 6: Handle graphes with an image}
\doxychapter{tutograph}{Step 7: Handle graphes with an image}
\end{htmlonly}
......@@ -996,10 +1112,18 @@ They are located in \hpath{mln/io/$<$image-format$>$/}.
Once the right header is included, the image can be loaded:
\doxyrawcode{ima-load}
Note that for the PBM format, you \textbf{MUST} use ``\type{bool}'' as value type.
No special value type is required for other formats though.
\doxycode{ima-load}
Note that each format is associated to specific image value types:
\begin{tabular}{|l|l|}
\\hline
Format & Value type \\ \hline
PBM & bool \\
PFM & float, double, float01\_* \\
PGM & unsigned, long, int, int\_u*, gl* \\
PNM & See PGM, PBM and PPM \\
PPM & rgb* \\
\end{tabular}
\doxycode{ima-save}
%
......@@ -2146,4 +2270,16 @@ mln\_vertex\_nbh\_vertex\_iter(G) & G : graph type & Iterator on the vertices ad
mln\_edge\_nbh\_edge\_iter(G) & G : graph type & Iterator on the edges adjacent to an edge. \\
\end{tabular}
%====================================
\newpage
\clearpage
%Ugly workaround to avoid missing chapter references in doxygen.
\begin{htmlonly}
\doxychapter{2}{}
\end{htmlonly}
\doxychapter{debugtools}{Debugging tools}
FIXME write it
\end{document}
......@@ -18,6 +18,7 @@ memset__SOURCES = memset_.cc
paste_SOURCES = paste.cc
# Lengthy tests.
fill_full_SOURCES = fill_full.cc
# FIXME: enable it when make full-check is enabled.
#fill_full_SOURCES = fill_full.cc
TESTS = $(check_PROGRAMS)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment