Commit 2b830a05 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Small fixes (again).

	* doc/examples/Makefile.am,
	* doc/examples/fill-subdomain.cc,
	* doc/examples/labeling-compute.cc,
	* doc/examples/tuto3/colorize.cc,
	* doc/examples/tuto4/point2d.cc,
	* doc/examples/tuto4_genericity_and_algorithms.cc: update examples.

	* doc/outputs/site_set_create.txt,
	* doc/outputs/colorize.txt,
	* doc/outputs/println.txt,
	* doc/outputs/trace.txt: rename as...

	* doc/outputs/tuto4_site_set_create.txt,
	* doc/outputs/tuto3_println.txt,
	* doc/outputs/tuto3_colorize.txt,
	* doc/outputs/tuto3_trace.txt: ... this.

	* doc/outputs/tuto4_point2d.txt: new reference output file.

	* doc/tools/split_sample.sh: add subdir names to example binary names.

	* doc/tutorial/tutorial.tex: include correct code samples.

	* mln/accu/bbox.hh: temporary disable a precondition.

	* mln/accu/compute.hh: add a fixme.

	* mln/core/image/tr_image.hh: require an image to be const in the constructor.

	* mln/core/site_set/p_array.hh: fix invalid static_cast.

	* mln/labeling/compute.hh: add more comments.

	* mln/labeling/essential.hh: add missing include.

	* mln/morpho/hit_or_miss.hh: avoid warnings.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3795 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a64ee524
2009-05-15 Guillaume Lazzara <lazzara@lrde.epita.fr>
Small fixes (again)
* doc/examples/Makefile.am,
* doc/examples/fill-subdomain.cc,
* doc/examples/labeling-compute.cc,
* doc/examples/tuto3/colorize.cc,
* doc/examples/tuto4/point2d.cc,
* doc/examples/tuto4_genericity_and_algorithms.cc: update examples.
* doc/outputs/site_set_create.txt,
* doc/outputs/colorize.txt,
* doc/outputs/println.txt,
* doc/outputs/trace.txt: rename as...
* doc/outputs/tuto4_site_set_create.txt,
* doc/outputs/tuto3_println.txt,
* doc/outputs/tuto3_colorize.txt,
* doc/outputs/tuto3_trace.txt: ... this.
* doc/outputs/tuto4_point2d.txt: new reference output file.
* doc/tools/split_sample.sh: add subdir names to example binary names.
* doc/tutorial/tutorial.tex: include correct code samples.
* mln/accu/bbox.hh: temporary disable a precondition.
* mln/accu/compute.hh: add a fixme.
* mln/core/image/tr_image.hh: require an image to be const in the constructor.
* mln/core/site_set/p_array.hh: fix invalid static_cast.
* mln/labeling/compute.hh: add more comments.
* mln/labeling/essential.hh: add missing include.
* mln/morpho/hit_or_miss.hh: avoid warnings.
2009-05-12 Guillaume Lazzara <lazzara@lrde.epita.fr>
 
Small fixes.
......@@ -53,13 +53,14 @@ tuto4_genericity_and_algorithms
# Tuto3
noinst_PROGRAMS += \
colorize \
println \
trace
tuto3_colorize \
tuto3_println \
tuto3_trace
# Tuto4
noinst_PROGRAMS += \
site_set_create
tuto4_point2d \
tuto4_site_set_create
accu_right_instanciation_SOURCES = accu-right-instanciation.cc
borderthickness_SOURCES = borderthickness.cc
......@@ -108,12 +109,13 @@ tuto3_rw_image_SOURCES = tuto3_rw_image.cc
tuto4_genericity_and_algorithms_SOURCES = tuto4_genericity_and_algorithms.cc
# Tuto 3
colorize_SOURCES = tuto3/colorize.cc
println_SOURCES = tuto3/println.cc
trace_SOURCES = tuto3/trace.cc
tuto3_colorize_SOURCES = tuto3/colorize.cc
tuto3_println_SOURCES = tuto3/println.cc
tuto3_trace_SOURCES = tuto3/trace.cc
# Tuto 4
site_set_create_SOURCES = tuto4/site_set_create.cc
tuto4_site_set_create_SOURCES = tuto4/site_set_create.cc
tuto4_point2d_SOURCES = tuto4/point2d.cc
all: clean-figures
mkdir -p $(OUTPUTS_BUILDDIR)
......
......@@ -27,7 +27,7 @@ int main()
image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
// \}
doc::ppmsave(debug::colorize(rgb8(), lbl, nlabels), "fill-subdomain");
doc::ppmsave(labeling::colorize(rgb8(), lbl, nlabels), "fill-subdomain");
// Create a new image from lbl's sites being part of component 2.
// \{
......@@ -38,7 +38,7 @@ int main()
initialize(tmp, lbl);
data::fill(tmp, 0);
data::fill((tmp | lbl_2.domain()).rw(), 1);
doc::ppmsave(debug::colorize(rgb8(), tmp, 1), "fill-subdomain");
doc::ppmsave(labeling::colorize(rgb8(), tmp, 1), "fill-subdomain");
// Create a black image from ima.
// Fill sites being part of component 2 with red.
......
......@@ -24,7 +24,7 @@ int main()
label_8 nlabels;
image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
// \}
doc::ppmsave(debug::colorize(rgb8(), lbl, nlabels),
doc::ppmsave(labeling::colorize(rgb8(), lbl, nlabels),
"labeling-compute");
......
#include <mln/core/image/image2d.hh>
#include <mln/make/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/colorize.hh>
#include <mln/labeling/colorize.hh>
#include <doc/tools/sample_utils.hh>
int main()
......@@ -17,7 +17,7 @@ int main()
65, 65, 65, 127, 127 };
image2d<int_u8> ima = make::image2d(vals);
image2d<rgb8> ima_color = debug::colorize(rgb8(), ima, 230);
image2d<rgb8> ima_color = labeling::colorize(rgb8(), ima, 230);
// \}
doc::pgmsave(ima, "colorize");
......
#include <mln/core/alias/point2d.hh>
int main()
{
using namespace mln;
// \{
point2d p(3,3);
std::cout << p << std::endl;
// \}
}
#include <mln/essential/2d.hh>
#include <mln/binarization/threshold.hh>
#include <mln/debug/colorize.hh>
#include <mln/labeling/colorize.hh>
#include <tests/data.hh>
#include <doc/tools/sample_utils.hh>
......@@ -80,7 +80,7 @@ int main()
value::label_8 nlabels;
image2d<value::label_8> label = labeling::blobs(lena_bw, c8(), nlabels);
// \}
doc::ppmsave(debug::colorize(value::rgb8(), label, nlabels), "tuto4_genericity_and_algorithms");
doc::ppmsave(labeling::colorize(value::rgb8(), label, nlabels), "tuto4_genericity_and_algorithms");
// \{
data::fill((lena | (pw::value(label) == pw::cst(0u))).rw(), literal::blue);
......
......@@ -12,7 +12,12 @@ split=false
i=1
for begin in $begins; do
partend=$((`echo $ends | cut -d ' ' -f $i` - 1))
head -n $partend $1 | tail -n $(($partend - $begin)) > $3/"`basename $1 .$2`-$i.$2"
subdir=`basename \`dirname $1\``
out_name="`basename $1 .$2`-$i.$2"
if [ "$subdir" != "examples" ] && [ "$subdir" != "outputs" ]; then
out_name="${subdir}_$out_name"
fi
head -n $partend $1 | tail -n $(($partend - $begin)) > "$3/$out_name"
i=$((i+1))
split=true
done
......
......@@ -821,11 +821,11 @@ routines/tools than what this program actually does.
Here is the full example:
\doxycode[1]{first_routine}
\doxycode[1]{tuto3_first_routine}
Let's see the different parts of the algorithm.
\doxycode[2]{first_routine}
\doxycode[2]{tuto3_first_routine}
The prototype is restrictive enough, readable and still generic.
We use concepts to statically check that the generic type passed as
parameter is what the routine expects. The ``exact'' image type is \type{I}. For
......@@ -837,12 +837,12 @@ The important point to remember is that a generic function should not return
\type{I} directly but \code{mln\_concrete(I)} instead.
\doxycode[3]{first_routine}
\doxycode[3]{tuto3_first_routine}
Like any Milena's routine, note that we use \code{trace}. This debugging tool
will be detailled in section \ref{tuto3debughints}.
\doxycode[4]{first_routine}
\doxycode[4]{tuto3_first_routine}
Since the function take some arguments thanks their concept, these object cannot
be used as such. Indeed, concepts are empty shells only used for dispatching and
concept checking, that's the reason why they are parameterized with their exact
......@@ -852,7 +852,7 @@ Of course, it is always a good idea to add few preconditions to help during
debug.
\doxycode[5]{first_routine}
\doxycode[5]{tuto3_first_routine}
In this portion of code, the image is labeled and the number of site per label
is computed. This code does not depend on the image type at all. Again, a macro
\code{mln\_ch\_value} (``mln change value'') helps us. \code{labeling::blobs} is a routine returning an
......@@ -862,7 +862,7 @@ image of the same kind as the input image but with a different value.
different value type.
\doxycode[6]{first_routine}
\doxycode[6]{tuto3_first_routine}
The output image is declared here. Like any variable, it must be initialized at
some point. To do so, \code{initialize()} is provided. It is a generic routine
which can initialize the geometry any kind of image with another image of the
......@@ -873,14 +873,14 @@ Note that the value passed to \code{data::fill} is also generic. The library
includes few generic common values from which any value type can convert to.
\doxycode[7]{first_routine}
\doxycode[7]{tuto3_first_routine}
In this part, every region from the labeled image, of which cardinality is lower
than 10 sites, is set to \val{literal::zero} in \var{output}.
Once again, a generic value is used in order to avoid a constraints on the image
value type.
\doxycode[8]{first_routine}
\doxycode[8]{tuto3_first_routine}
Don't forget to close the trace before exiting the function. Then return the
result.
......@@ -1024,9 +1024,9 @@ Since it's a global variable, at anytime in the source code, the trace can be
enabled/disabled.
Traces are enabled:
\doxycode[1]{trace}
\doxycode[1]{tuto3_trace}
\code{labeleling::blobs} is run and the debug is then disabled.
\doxycode[2]{trace}
\doxycode[2]{tuto3_trace}
The previous code will produce the following trace:
......@@ -1055,21 +1055,21 @@ been disabled just before it is called.
Milena also provides a lot of debug tools. Here is a small list of the tools:
\begin{itemize}
\item mln::debug::println, print an image in the console.
\doxycode[1]{println}
\doxymoutput[1]{println}
\doxycode[1]{tuto3_println}
\doxymoutput[1]{tuto3_println}
\item mln::debug::println\_with\_border, print an image in the console withs
its border.
\doxycode[2]{println}
\doxymoutput[2]{println}
\doxycode[2]{tuto3_println}
\doxymoutput[2]{tuto3_println}
\item mln::debug::colorize, colorize a label image with random colors.
\doxycode[1]{colorize}
\item mln::labeling::colorize, colorize a label image with random colors.
\doxycode[1]{tuto3_colorize}
\begin{center}
\begin{tabular}{c c c}
\doxyfigure[1]{colorize}{3cm} & ~\huge{$\rightarrow$}~ &
\doxyfigure[2]{colorize}{3cm} \\
\doxyfigure[1]{tuto3_colorize}{3cm} & ~\huge{$\rightarrow$}~ &
\doxyfigure[2]{tuto3_colorize}{3cm} \\
\end{tabular}
\end{center}
\end{itemize}
......@@ -1090,7 +1090,7 @@ compilation time w.r.t compilation options (O1, DNDEBUG).
This chapter aims at explaining how images are stored and which objects compose
an image in Milena. We will start to talk about the localization of a pixel and
then the image itself which includes the values.
then the image itself which stores the values.
%**************************
......@@ -1103,9 +1103,12 @@ A site can be any kind of localization element.
For instance, in an image defined on a 2D regular grid, it is a 2D point with
\var{row} and \var{col} coordinates.
\doxycode{tuto4_point2d}
The site type in an image is defined by its underlying site set.
%**************************
\doxysection{tuto4images}{Site sets}
......
......@@ -202,7 +202,7 @@ namespace mln
const box<P>&
bbox<P>::to_result() const
{
mln_precondition(is_valid_);
// mln_precondition(is_valid_);
return b_;
}
......
......@@ -150,6 +150,7 @@ namespace mln
mln_precondition(exact(input).is_valid());
//FIXME: why adding util::pix here?
typedef mln_accu_with(A, util::pix<I>) A_;
util::pix<I>* pix_; // So we can pass a pixel below (pixel has
// no ctor without arg).
......
......@@ -53,7 +53,7 @@ namespace mln
template <typename S, typename I, typename T>
struct data< tr_image<S,I,T> >
{
data(const S& s, I& ima, const T& tr);
data(const S& s, const I& ima, const T& tr);
I ima_;
T tr_;
......@@ -107,7 +107,7 @@ namespace mln
/// Constructors.
tr_image(const S& s, I& ima, const T& tr);
tr_image(const S& s, const I& ima, const T& tr);
/* FIXME: What's the purpose of this ctor? AFAIK, morphers
objects (and images in general) cannot have their structure /
core data altered after they're built. Here, there's a
......@@ -117,7 +117,7 @@ namespace mln
tr_image();
/// Initialize an empty image.
void init_(const S& s, I& ima, const T& tr);
void init_(const S& s, const I& ima, const T& tr);
/// Test if this image has been initialized.
bool is_valid() const;
......@@ -149,7 +149,7 @@ namespace mln
template <typename S, typename I, typename T>
inline
data< tr_image<S,I,T> >::data(const S& s, I& ima, const T& tr)
data< tr_image<S,I,T> >::data(const S& s, const I& ima, const T& tr)
: ima_(ima),
tr_(tr),
s_(s)
......@@ -160,7 +160,7 @@ namespace mln
template <typename S, typename I, typename T>
inline
tr_image<S,I,T>::tr_image(const S& s, I& ima, const T& tr)
tr_image<S,I,T>::tr_image(const S& s, const I& ima, const T& tr)
{
init_(s, ima, tr);
}
......@@ -168,7 +168,7 @@ namespace mln
template <typename S, typename I, typename T>
inline
void
tr_image<S,I,T>::init_(const S& s, I& ima, const T& tr)
tr_image<S,I,T>::init_(const S& s, const I& ima, const T& tr)
{
mln_precondition(ima.is_valid());
this->data_ = new internal::data< tr_image<S,I,T> >(s, ima, tr);
......@@ -225,7 +225,8 @@ namespace mln
template <typename S, typename I, typename T>
inline
tr_image<S,I,T>
transposed_image(const Site_Set<S>& s, Image<I>& ima, const Function_x2x<T>& t)
transposed_image(const Site_Set<S>& s, const Image<I>& ima,
const Function_x2x<T>& t)
{
tr_image<S,I,T> tmp(exact(s), exact(ima), exact(t));
return tmp;
......
......@@ -208,7 +208,6 @@ namespace mln
bool is_valid() const;
operator mln_element(S)() const; // Does it cause ambiguities with "operator int" ?
operator util::index() const;
operator int() const; // To interoperate, e.g., with fun::i2v expecting an int.
operator unsigned() const; // To avoid ambiguity when an unsigned is expected.
......@@ -360,7 +359,7 @@ namespace mln
if (! has(p.index()))
return false;
// The type of rhs below is mln_site(p_array<P>).
mln_invariant(static_cast<P>(p) == static_cast<P>((*this)[p.index()]));
mln_invariant(p == static_cast<P>((*this)[p.index()]));
return true;
}
......@@ -585,13 +584,6 @@ namespace mln
p_ = (*s_)[i_];
}
template <typename S>
inline
p_indexed_psite<S>::operator mln_element(S)() const
{
return p_;
}
template <typename S>
inline
p_indexed_psite<S>::operator util::index() const
......
......@@ -36,8 +36,16 @@
///
/// \todo write fastest version.
///
/// \todo Move versions without 'input' as arg into mln::set
///
/// TODO: Move versions without 'input' as arg into mln::set
/// and change 'input' from Image to Site_Set!
/// ==> NO, see below. (Z)
///
/// The overload not taking 'input' as argument works on sites and would be a good
/// candidate for set::compute. However, the fact that this version of compute
/// is in the namespace 'labeling' means that it produces several results at the
/// same time for each labels which is not the case of other implementations of
/// compute.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/accumulator.hh>
......
......@@ -33,6 +33,7 @@
/// File that includes essential labeling routines.
# include <mln/labeling/blobs.hh>
# include <mln/labeling/colorize.hh>
# include <mln/labeling/compute.hh>
# include <mln/labeling/relabel.hh>
......
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