#247: mln_min() of a floating type is not the effective minimum of the range
value
-----------------------------------------------------+----------------------
Reporter: David Coeurjolly and Julien Marquegnies | Owner: Olena Team
Type: defect | Status: new
Priority: critical | Milestone:
Component: Milena | Version: 2.0
Keywords: |
-----------------------------------------------------+----------------------
According to David Coeurjolly
{{{
int main()
{
mln::accu::stat::max<double> mm;
mm.init();
mm.take(-0.02);
mm.take(-0.92);
mm.take(-0.03);
std::cout<<" max= "<<mm.to_result()<<std::endl;
}
}}}
In many situations (w/o init, w/o 'to_result() method in the ostream), I
always get a wrong value (2.22-308, which seems to be min_val for positive
double).
Julien Marquegnies confirmed that mln_min(double) or mln_min(float)
returns DBL_MIN instead of -DBL_MAX.
According to the meaning of mln_min/max which are supposed to give the
lower and upper bounds of the range values, returning -DBL_MAX
'''should''' fix the issue.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/247>
Olena <http://olena.lrde.epita.fr>
Olena, a software platform dedicated to image processing.
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch next has been updated
via 6c73505ca244e78dfc6557fe69387381d2e81916 (commit)
from 861239963254a72f51b25bfd8323a12ff4a58b82 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
6c73505 Update lrde-scmstats.sh.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 8 ++++++++
lrde-scmstats.sh | 21 ++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* lrde-scmstats.sh: Look more like lrde-upload.sh.
Ensure generated data is readable from the Web.
Anonymize some names as requested by some contributors.
---
ChangeLog | 8 ++++++++
lrde-scmstats.sh | 21 ++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 75e4788..31ebcf6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-25 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Update lrde-scmstats.sh.
+
+ * lrde-scmstats.sh: Look more like lrde-upload.sh.
+ Ensure generated data is readable from the Web.
+ Anonymize some names as requested by some contributors.
+
2011-11-24 Guillaume Lazzara <z(a)lrde.epita.fr>
* distrib/macports/Portfile.in: Fix maintainers field.
diff --git a/lrde-scmstats.sh b/lrde-scmstats.sh
index 859f100..f1f0073 100755
--- a/lrde-scmstats.sh
+++ b/lrde-scmstats.sh
@@ -17,7 +17,7 @@
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-# This file is run by the LRDE autobuilder before compilation.
+# This file is run by the LRDE autobuilder before the build.
# It is not meant to be distributed with Olena.
set -ex
@@ -25,19 +25,22 @@ set -ex
# Buildbot will tell us the name of the branch being compiled using $1.
branch=$1
-# We might want to filter stats for specific branches.
-# Currently gitstats does not allow that.
+# Filter stats for specific branches.
case "$branch" in
-# # Consider these branches only.
+ # Consider these branches only.
master|next|swilena|mesh-segm-skel|stable/scribo|unstable/scribo) ;;
-# # Don't upload other branches.
+ # Don't compute statistics for other branches.
*) exit ;;
esac
-DEST=/lrde/dload/olena/stats/
+subdir=$branch
+DEST=/lrde/dload/olena/stats/$subdir
-# option '-c commit_end=$branch' is not needed since buildbot and git
-# only checkout the current branch as 'master'.
-gitstats . $DEST/$branch
+# Compute statistics.
+gitstats . $DEST
+# Anonymize some names.
+find "$DEST" -name "*.html" -exec sed -i 's/J.r.me Darbon/JD/g' {} \;
+# Expose uploaded files.
+chmod -R a+rX $DEST
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch apps-morphers has been updated
discards 1c0192b12c825aa99845049dec9f41b4a63585d7 (commit)
discards d10d4508a41f5d5709cdfe65a03c5298226d7dac (commit)
discards 8d55a9e8af616eaf0dd3521699fb264ef4500d1d (commit)
via bd2670fbf582fc5c238507bdb3d9543d5bcb0577 (commit)
via 849c13701f8eb2e08d838979c7b3539332cf099a (commit)
via dcad6adc4a6b9469f79c055f1c2a5138c74e6f29 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (1c0192b12c825aa99845049dec9f41b4a63585d7)
\
N -- N -- N (bd2670fbf582fc5c238507bdb3d9543d5bcb0577)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
bd2670f New morpher example: recording a watershed transform.
849c137 Work around decorated_image's lack of properties, for the recorder.
dcad6ad Fix the initialization of mln::decorated_image.
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch apps-morphers has been updated
via 1c0192b12c825aa99845049dec9f41b4a63585d7 (commit)
via d10d4508a41f5d5709cdfe65a03c5298226d7dac (commit)
via 8d55a9e8af616eaf0dd3521699fb264ef4500d1d (commit)
from 21c2800d395c87adb3e456adb3a2f1ece83fe0fd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
1c0192b New morpher example: recording a watershed transform.
d10d450 Work around decorated_image's lack of properties, for the recorder.
8d55a9e * mln/tag/init.hh (tag::data_t): New tag type. (tag::data): New tag. * mln/core/image/imorph/decorated_image.hh (init_(tag::data_t, D&, const decorated_image<I,D>&)) (init_(tag::data_t, D&, const decorated_image<I,D2>&)) (init_(tag::image_t, decorated_image<I,D>&, const J&)): New functions.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 37 ++++++++
milena/apps/morphers/Makefile.am | 3 +
milena/apps/morphers/mask+channel.cc | 7 +-
milena/apps/morphers/mask+recorder.cc | 6 +-
milena/apps/morphers/recorder-wst.cc | 106 +++++++++++++++++++++++
milena/apps/morphers/recorder.cc | 5 +-
milena/apps/morphers/recorder.hh | 77 +++++++++++++++--
milena/mln/core/image/imorph/decorated_image.hh | 26 ++++++
milena/mln/tag/init.hh | 3 +
9 files changed, 250 insertions(+), 20 deletions(-)
create mode 100644 milena/apps/morphers/recorder-wst.cc
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* apps/morphers/recorder-wst.cc: New.
* apps/morphers/Makefile.am (noinst_PROGRAMS): Add recorder-wst.
(recorder_wst_SOURCES): New.
(MOSTLYCLEANFILES): lena-wst??????.ppm.
---
milena/ChangeLog | 9 +++
milena/apps/morphers/Makefile.am | 3 +
milena/apps/morphers/recorder-wst.cc | 106 ++++++++++++++++++++++++++++++++++
3 files changed, 118 insertions(+), 0 deletions(-)
create mode 100644 milena/apps/morphers/recorder-wst.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4b904dc..2b98497 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+ New morpher example: recording a watershed transform.
+
+ * apps/morphers/recorder-wst.cc: New.
+ * apps/morphers/Makefile.am (noinst_PROGRAMS): Add recorder-wst.
+ (recorder_wst_SOURCES): New.
+ (MOSTLYCLEANFILES): lena-wst??????.ppm.
+
+2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Work around decorated_image's lack of properties, for the recorder.
* apps/morphers/recorder.hh
diff --git a/milena/apps/morphers/Makefile.am b/milena/apps/morphers/Makefile.am
index d448c1d..a3b9a41 100644
--- a/milena/apps/morphers/Makefile.am
+++ b/milena/apps/morphers/Makefile.am
@@ -25,15 +25,18 @@ AM_CXXFLAGS = $(APPS_CXXFLAGS)
noinst_PROGRAMS = \
mask+channel \
recorder \
+ recorder-wst \
mask+recorder
mask_channel_SOURCES = mask+channel.cc
recorder_SOURCES = recorder.cc recorder.hh
+recorder_wst_SOURCES = recorder-wst.cc recorder.hh
mask_recorder_SOURCES = mask+recorder.cc recorder.hh
MOSTLYCLEANFILES = \
lena-mask-channel.ppm \
lena-fill??????.ppm \
+ lena-wst??????.ppm \
lena-roi-fill??????.ppm
# FIXME: Also produce movies (see comments in recorder.cc and
diff --git a/milena/apps/morphers/recorder-wst.cc b/milena/apps/morphers/recorder-wst.cc
new file mode 100644
index 0000000..e4aade5
--- /dev/null
+++ b/milena/apps/morphers/recorder-wst.cc
@@ -0,0 +1,106 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+/// \file
+/// \brief Exercise a morpher recording every change in the morphed
+/// image with the watershed transform.
+///
+/// To produce an AVI movie from the `lena-wst*.ppm' files, use:
+///
+/// for f in lena-wst*ppm; convert $f -scale 2500% $(basename $f .ppm).png
+/// mencoder "mf://lena-wst*.png" -o lena-wst.avi -ovc lavc -lavcopts vcodec=mjpeg
+///
+/// The output `lena-wst.avi' can be embedded in a PDF file. */
+
+#include <string>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/colors.hh>
+
+#include <mln/morpho/gradient.hh>
+#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/watershed/flooding.hh>
+
+#include <mln/test/predicate.hh>
+#include <mln/pw/value.hh>
+
+#include <mln/labeling/colorize.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include "apps/morphers/recorder.hh"
+
+#include "apps/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using mln::value::int_u8;
+ using mln::value::label_8;
+
+ typedef image2d<int_u8> I;
+ I lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
+
+ // Gradient.
+ I grad = morpho::gradient(lena, win_c4p());
+ // Simplification of the gradient.
+ unsigned lambda = 5;
+ I closed_grad = morpho::closing::area(grad, c4(), lambda);
+ // Attach recorder to closed gradient.
+ decorated_image< I, recorder<I> > closed_grad_rec = record(closed_grad);
+
+ // Watershed transform.
+ typedef label_8 L;
+ L nbasins;
+ typedef mln_ch_value_(I, L) J;
+ decorated_image< J, recorder<J> > wst_rec =
+ morpho::watershed::flooding(closed_grad_rec, c4(), nbasins);
+ std::cout << nbasins << std::endl;
+
+ // Dump recorded frames.
+ /* FIXME: Hand-made (it partly duplicates ppm::save() for
+ decorated_image's). We should be able to process sequences of
+ images. */
+ for (size_t i = 0; i < wst_rec.decoration().sequence.size(); ++i)
+ {
+ J frame = wst_rec.decoration().sequence[i];
+
+ // Skip ``empty'' frames.
+ if (test::predicate(frame.domain(), pw::value(frame) == 0))
+ continue;
+
+ std::stringstream s;
+ s << std::setfill ('0') << std::setw (6) << i;
+ io::ppm::save(labeling::colorize(value::rgb8(), frame, nbasins),
+ std::string("lena-wst") + s.str() + ".ppm");
+ }
+}
--
1.7.2.5
* apps/morphers/recorder-wst.cc: New.
* apps/morphers/Makefile.am (noinst_PROGRAMS): Add recorder-wst.
(recorder_wst_SOURCES): New.
(MOSTLYCLEANFILES): lena-wst??????.ppm.
---
milena/ChangeLog | 9 +++
milena/apps/morphers/Makefile.am | 3 +
milena/apps/morphers/recorder-wst.cc | 106 ++++++++++++++++++++++++++++++++++
3 files changed, 118 insertions(+), 0 deletions(-)
create mode 100644 milena/apps/morphers/recorder-wst.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4b904dc..2b98497 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+ New morpher example: recording a watershed transform.
+
+ * apps/morphers/recorder-wst.cc: New.
+ * apps/morphers/Makefile.am (noinst_PROGRAMS): Add recorder-wst.
+ (recorder_wst_SOURCES): New.
+ (MOSTLYCLEANFILES): lena-wst??????.ppm.
+
+2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Work around decorated_image's lack of properties, for the recorder.
* apps/morphers/recorder.hh
diff --git a/milena/apps/morphers/Makefile.am b/milena/apps/morphers/Makefile.am
index d448c1d..a3b9a41 100644
--- a/milena/apps/morphers/Makefile.am
+++ b/milena/apps/morphers/Makefile.am
@@ -25,15 +25,18 @@ AM_CXXFLAGS = $(APPS_CXXFLAGS)
noinst_PROGRAMS = \
mask+channel \
recorder \
+ recorder-wst \
mask+recorder
mask_channel_SOURCES = mask+channel.cc
recorder_SOURCES = recorder.cc recorder.hh
+recorder_wst_SOURCES = recorder-wst.cc recorder.hh
mask_recorder_SOURCES = mask+recorder.cc recorder.hh
MOSTLYCLEANFILES = \
lena-mask-channel.ppm \
lena-fill??????.ppm \
+ lena-wst??????.ppm \
lena-roi-fill??????.ppm
# FIXME: Also produce movies (see comments in recorder.cc and
diff --git a/milena/apps/morphers/recorder-wst.cc b/milena/apps/morphers/recorder-wst.cc
new file mode 100644
index 0000000..e4aade5
--- /dev/null
+++ b/milena/apps/morphers/recorder-wst.cc
@@ -0,0 +1,106 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+/// \file
+/// \brief Exercise a morpher recording every change in the morphed
+/// image with the watershed transform.
+///
+/// To produce an AVI movie from the `lena-wst*.ppm' files, use:
+///
+/// for f in lena-wst*ppm; convert $f -scale 2500% $(basename $f .ppm).png
+/// mencoder "mf://lena-wst*.png" -o lena-wst.avi -ovc lavc -lavcopts vcodec=mjpeg
+///
+/// The output `lena-wst.avi' can be embedded in a PDF file. */
+
+#include <string>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/colors.hh>
+
+#include <mln/morpho/gradient.hh>
+#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/watershed/flooding.hh>
+
+#include <mln/test/predicate.hh>
+#include <mln/pw/value.hh>
+
+#include <mln/labeling/colorize.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include "apps/morphers/recorder.hh"
+
+#include "apps/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using mln::value::int_u8;
+ using mln::value::label_8;
+
+ typedef image2d<int_u8> I;
+ I lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
+
+ // Gradient.
+ I grad = morpho::gradient(lena, win_c4p());
+ // Simplification of the gradient.
+ unsigned lambda = 5;
+ I closed_grad = morpho::closing::area(grad, c4(), lambda);
+ // Attach recorder to closed gradient.
+ decorated_image< I, recorder<I> > closed_grad_rec = record(closed_grad);
+
+ // Watershed transform.
+ typedef label_8 L;
+ L nbasins;
+ typedef mln_ch_value_(I, L) J;
+ decorated_image< J, recorder<J> > wst_rec =
+ morpho::watershed::flooding(closed_grad_rec, c4(), nbasins);
+ std::cout << nbasins << std::endl;
+
+ // Dump recorded frames.
+ /* FIXME: Hand-made (it partly duplicates ppm::save() for
+ decorated_image's). We should be able to process sequences of
+ images. */
+ for (size_t i = 0; i < wst_rec.decoration().sequence.size(); ++i)
+ {
+ J frame = wst_rec.decoration().sequence[i];
+
+ // Skip ``empty'' frames.
+ if (test::predicate(frame.domain(), pw::value(frame) == 0))
+ continue;
+
+ std::stringstream s;
+ s << std::setfill ('0') << std::setw (6) << i;
+ io::ppm::save(labeling::colorize(value::rgb8(), frame, nbasins),
+ std::string("lena-wst") + s.str() + ".ppm");
+ }
+}
--
1.7.2.5
* apps/morphers/recorder.hh
(trait::image_< decorated_image<I,D> >): Replace with..
(trait::image_< decorated_image<I, recorder<I> > >): ...this.
Add a value_storage property.
(ch_value_< decorated_image< image_<I>, data_< recorder<I> > >, V >):
New trait, to handle changes of value types in images decorated
with a recorder.
* apps/morphers/mask+channel.cc,
* apps/morphers/mask+recorder.cc,
* apps/morphers/recorder.cc:
Simplify these programs thanks to the preceding changes.
---
milena/ChangeLog | 16 +++++++
milena/apps/morphers/mask+channel.cc | 7 +--
milena/apps/morphers/mask+recorder.cc | 6 +--
milena/apps/morphers/recorder.cc | 5 +--
milena/apps/morphers/recorder.hh | 77 ++++++++++++++++++++++++++++++---
5 files changed, 91 insertions(+), 20 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 84c70af..4b904dc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+ Work around decorated_image's lack of properties, for the recorder.
+
+ * apps/morphers/recorder.hh
+ (trait::image_< decorated_image<I,D> >): Replace with..
+ (trait::image_< decorated_image<I, recorder<I> > >): ...this.
+ Add a value_storage property.
+ (ch_value_< decorated_image< image_<I>, data_< recorder<I> > >, V >):
+ New trait, to handle changes of value types in images decorated
+ with a recorder.
+ * apps/morphers/mask+channel.cc,
+ * apps/morphers/mask+recorder.cc,
+ * apps/morphers/recorder.cc:
+ Simplify these programs thanks to the preceding changes.
+
+2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix the initialization of mln::decorated_image.
* mln/tag/init.hh (tag::data_t): New tag type.
diff --git a/milena/apps/morphers/mask+channel.cc b/milena/apps/morphers/mask+channel.cc
index 2e170a2..130a168 100644
--- a/milena/apps/morphers/mask+channel.cc
+++ b/milena/apps/morphers/mask+channel.cc
@@ -61,10 +61,7 @@ int main()
image2d<rgb8> lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
fun::green green;
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value((thru(green, lena).rw() |
- make::box2d(5,5, 10,10)).rw(),
- 255);
+ data::fill((thru(green, lena).rw() | make::box2d(5,5, 10,10)).rw(),
+ 255);
io::ppm::save(lena, "lena-mask-channel.ppm");
}
diff --git a/milena/apps/morphers/mask+recorder.cc b/milena/apps/morphers/mask+recorder.cc
index 2693dbc..067ff6e 100644
--- a/milena/apps/morphers/mask+recorder.cc
+++ b/milena/apps/morphers/mask+recorder.cc
@@ -59,9 +59,7 @@ int main()
typedef image2d<rgb8> I;
I lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
decorated_image< I, recorder<I> > lena_rec = record(lena);
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value((lena_rec | make::box2d(5,5, 10,10)).rw(),
- literal::green);
+ data::fill((lena_rec | make::box2d(5,5, 10,10)).rw(),
+ literal::green);
ppm::save(lena_rec, "lena-roi-fill");
}
diff --git a/milena/apps/morphers/recorder.cc b/milena/apps/morphers/recorder.cc
index 4a3f1ab..86af667 100644
--- a/milena/apps/morphers/recorder.cc
+++ b/milena/apps/morphers/recorder.cc
@@ -56,9 +56,6 @@ int main()
typedef image2d<rgb8> I;
I lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
decorated_image< I, recorder<I> > lena_rec = record(lena);
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value(lena_rec,
- literal::green);
+ data::fill(lena_rec, literal::green);
ppm::save(lena_rec, "lena-fill");
}
diff --git a/milena/apps/morphers/recorder.hh b/milena/apps/morphers/recorder.hh
index 98b5f70..f8fc4f4 100644
--- a/milena/apps/morphers/recorder.hh
+++ b/milena/apps/morphers/recorder.hh
@@ -36,6 +36,8 @@
#include <string>
+#include <mln/trait/ch_value.hh>
+
#include <mln/core/image/imorph/decorated_image.hh>
#include <mln/value/rgb8.hh>
@@ -47,22 +49,29 @@
#include "apps/data.hh"
-// FIXME: mln::decorated_image lacks a proper definition of
-// properties! (see mln/core/image/imorph/decorated_image.hh). We use
-// the following (minimal) set of properties as a workaround.
+// Forward declaration.
+template <typename I> struct recorder;
+
+/* FIXME: mln::decorated_image lacks a proper definition of
+ properties! (see mln/core/image/imorph/decorated_image.hh). We use
+ the following (minimal) set of properties as a workaround for the
+ recorder decoration. */
namespace mln
{
-
namespace trait
{
- template <typename I, typename D>
- struct image_< decorated_image<I,D> >
+ template <typename I>
+ struct image_< decorated_image< I, recorder<I> > >
: default_image_morpher< I,
mln_value(I),
- decorated_image<I,D> >
+ decorated_image< I, recorder<I> > >
{
typedef trait::image::category::identity_morpher category;
+
+ // Prevent fast processing of images requiring a specific
+ // interface that we are unable to retrieve now.
+ typedef trait::image::value_storage::disrupted value_storage;
};
} // end of namespace mln::trait
@@ -87,6 +96,60 @@ struct recorder
std::vector<I> sequence;
};
+/* Skeleton of an image decorated with a recorder.
+
+ Initialy, I (Roland) wanted to add this to mln/trait/ch_value.hh:
+
+ template < template <class, class> class M, typename I, typename D,
+ typename V >
+ struct ch_value_< M< tag::image_<I>, tag::data_<D> >, V >
+ {
+ typedef M< mln_ch_value(I, V), D > ret;
+ };
+
+ However, this would not work in the case of the recorder since the
+ type D of the data attached to the image (of type I) has to be
+ changed as well. Indeed the initial decoration contains a sequence
+ of images of type I, which should be changed into a sequence of
+ images of type mln_ch_value(I, V).
+
+ There are several option to improve this. One is to create a
+ ch_value trait for data/decorations such as `recorder<I>'. Another
+ one is to refine the skeleton of decorated_image<I, D> to have it
+ convey the type the data stored in the decoration, e.g, changing
+
+ typedef decorated_image< tag::image_<I>, tag::data_<D> > skeleton;
+
+ into something like
+
+ typedef decorated_image< tag::image_<I>, tag::data_<D, V> > skeleton;
+
+ but this seems overly complicated.
+
+ The workaround chosen here is very local, and address the very
+ specific case of decorated_image< I, recorder<I> >. */
+
+namespace mln
+{
+ namespace trait
+ {
+ namespace impl
+ {
+ template < typename I, typename V >
+ struct ch_value_< decorated_image< tag::image_<I>,
+ tag::data_< recorder<I> > >,
+ V >
+ {
+ typedef decorated_image< mln_ch_value(I, V),
+ recorder< mln_ch_value(I, V) > > ret;
+ };
+ } // end namespace mln::trait::impl
+
+ } // end namespace mln::trait
+
+} // end namespace mln
+
+// Helper.
template <typename I>
mln::decorated_image< I, recorder<I> >
record(mln::Image<I>& ima)
--
1.7.2.5
* apps/morphers/recorder.hh
(trait::image_< decorated_image<I,D> >): Replace with..
(trait::image_< decorated_image<I, recorder<I> > >): ...this.
Add a value_storage property.
(ch_value_< decorated_image< image_<I>, data_< recorder<I> > >, V >):
New trait, to handle changes of value types in images decorated
with a recorder.
* apps/morphers/mask+channel.cc,
* apps/morphers/mask+recorder.cc,
* apps/morphers/recorder.cc:
Simplify these programs thanks to the preceding changes.
---
milena/ChangeLog | 16 +++++++
milena/apps/morphers/mask+channel.cc | 7 +--
milena/apps/morphers/mask+recorder.cc | 6 +--
milena/apps/morphers/recorder.cc | 5 +--
milena/apps/morphers/recorder.hh | 77 ++++++++++++++++++++++++++++++---
5 files changed, 91 insertions(+), 20 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 84c70af..4b904dc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+ Work around decorated_image's lack of properties, for the recorder.
+
+ * apps/morphers/recorder.hh
+ (trait::image_< decorated_image<I,D> >): Replace with..
+ (trait::image_< decorated_image<I, recorder<I> > >): ...this.
+ Add a value_storage property.
+ (ch_value_< decorated_image< image_<I>, data_< recorder<I> > >, V >):
+ New trait, to handle changes of value types in images decorated
+ with a recorder.
+ * apps/morphers/mask+channel.cc,
+ * apps/morphers/mask+recorder.cc,
+ * apps/morphers/recorder.cc:
+ Simplify these programs thanks to the preceding changes.
+
+2011-11-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix the initialization of mln::decorated_image.
* mln/tag/init.hh (tag::data_t): New tag type.
diff --git a/milena/apps/morphers/mask+channel.cc b/milena/apps/morphers/mask+channel.cc
index 2e170a2..130a168 100644
--- a/milena/apps/morphers/mask+channel.cc
+++ b/milena/apps/morphers/mask+channel.cc
@@ -61,10 +61,7 @@ int main()
image2d<rgb8> lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
fun::green green;
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value((thru(green, lena).rw() |
- make::box2d(5,5, 10,10)).rw(),
- 255);
+ data::fill((thru(green, lena).rw() | make::box2d(5,5, 10,10)).rw(),
+ 255);
io::ppm::save(lena, "lena-mask-channel.ppm");
}
diff --git a/milena/apps/morphers/mask+recorder.cc b/milena/apps/morphers/mask+recorder.cc
index 2693dbc..067ff6e 100644
--- a/milena/apps/morphers/mask+recorder.cc
+++ b/milena/apps/morphers/mask+recorder.cc
@@ -59,9 +59,7 @@ int main()
typedef image2d<rgb8> I;
I lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
decorated_image< I, recorder<I> > lena_rec = record(lena);
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value((lena_rec | make::box2d(5,5, 10,10)).rw(),
- literal::green);
+ data::fill((lena_rec | make::box2d(5,5, 10,10)).rw(),
+ literal::green);
ppm::save(lena_rec, "lena-roi-fill");
}
diff --git a/milena/apps/morphers/recorder.cc b/milena/apps/morphers/recorder.cc
index 4a3f1ab..86af667 100644
--- a/milena/apps/morphers/recorder.cc
+++ b/milena/apps/morphers/recorder.cc
@@ -56,9 +56,6 @@ int main()
typedef image2d<rgb8> I;
I lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
decorated_image< I, recorder<I> > lena_rec = record(lena);
- /* FIXME: Cheat: use generic fill as mln::decorated_image does not
- define properly its properties. */
- data::impl::generic::fill_with_value(lena_rec,
- literal::green);
+ data::fill(lena_rec, literal::green);
ppm::save(lena_rec, "lena-fill");
}
diff --git a/milena/apps/morphers/recorder.hh b/milena/apps/morphers/recorder.hh
index 98b5f70..f8fc4f4 100644
--- a/milena/apps/morphers/recorder.hh
+++ b/milena/apps/morphers/recorder.hh
@@ -36,6 +36,8 @@
#include <string>
+#include <mln/trait/ch_value.hh>
+
#include <mln/core/image/imorph/decorated_image.hh>
#include <mln/value/rgb8.hh>
@@ -47,22 +49,29 @@
#include "apps/data.hh"
-// FIXME: mln::decorated_image lacks a proper definition of
-// properties! (see mln/core/image/imorph/decorated_image.hh). We use
-// the following (minimal) set of properties as a workaround.
+// Forward declaration.
+template <typename I> struct recorder;
+
+/* FIXME: mln::decorated_image lacks a proper definition of
+ properties! (see mln/core/image/imorph/decorated_image.hh). We use
+ the following (minimal) set of properties as a workaround for the
+ recorder decoration. */
namespace mln
{
-
namespace trait
{
- template <typename I, typename D>
- struct image_< decorated_image<I,D> >
+ template <typename I>
+ struct image_< decorated_image< I, recorder<I> > >
: default_image_morpher< I,
mln_value(I),
- decorated_image<I,D> >
+ decorated_image< I, recorder<I> > >
{
typedef trait::image::category::identity_morpher category;
+
+ // Prevent fast processing of images requiring a specific
+ // interface that we are unable to retrieve now.
+ typedef trait::image::value_storage::disrupted value_storage;
};
} // end of namespace mln::trait
@@ -87,6 +96,60 @@ struct recorder
std::vector<I> sequence;
};
+/* Skeleton of an image decorated with a recorder.
+
+ Initialy, I (Roland) wanted to add this to mln/trait/ch_value.hh:
+
+ template < template <class, class> class M, typename I, typename D,
+ typename V >
+ struct ch_value_< M< tag::image_<I>, tag::data_<D> >, V >
+ {
+ typedef M< mln_ch_value(I, V), D > ret;
+ };
+
+ However, this would not work in the case of the recorder since the
+ type D of the data attached to the image (of type I) has to be
+ changed as well. Indeed the initial decoration contains a sequence
+ of images of type I, which should be changed into a sequence of
+ images of type mln_ch_value(I, V).
+
+ There are several option to improve this. One is to create a
+ ch_value trait for data/decorations such as `recorder<I>'. Another
+ one is to refine the skeleton of decorated_image<I, D> to have it
+ convey the type the data stored in the decoration, e.g, changing
+
+ typedef decorated_image< tag::image_<I>, tag::data_<D> > skeleton;
+
+ into something like
+
+ typedef decorated_image< tag::image_<I>, tag::data_<D, V> > skeleton;
+
+ but this seems overly complicated.
+
+ The workaround chosen here is very local, and address the very
+ specific case of decorated_image< I, recorder<I> >. */
+
+namespace mln
+{
+ namespace trait
+ {
+ namespace impl
+ {
+ template < typename I, typename V >
+ struct ch_value_< decorated_image< tag::image_<I>,
+ tag::data_< recorder<I> > >,
+ V >
+ {
+ typedef decorated_image< mln_ch_value(I, V),
+ recorder< mln_ch_value(I, V) > > ret;
+ };
+ } // end namespace mln::trait::impl
+
+ } // end namespace mln::trait
+
+} // end namespace mln
+
+// Helper.
template <typename I>
mln::decorated_image< I, recorder<I> >
record(mln::Image<I>& ima)
--
1.7.2.5