Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Create small tools for IGR.
* fabien/TODO: New.
* fabien/igr/dump2pbm.cc: Move this...
* fabien/bin/dump2pbm.cc: ...here.
* fabien/igr/dump2ppm.cc: Move this...
* fabien/bin/dump2ppm.cc: ...here.
* fabien/igr/Makefile: Update.
* fabien/igr/launch.sh: New tool.
* fabien/igr/launch2d.sh: New tool.
* fabien/igr/launch3d.sh: New tool.
* fabien/igr/seg2d.cc: New tool.
* fabien/igr/seg3d.cc: New tool.
* fabien/igr/seg_vol_irm.cc: Rename this...
* fabien/igr/seg_vol_irm.hh: ...into this.
---
TODO | 13 ++
bin/dump2pbm.cc | 35 ++++++
bin/dump2ppm.cc | 35 ++++++
igr/Makefile | 23 ++-
igr/launch.sh | 4
igr/launch2d.sh | 26 ++++
igr/launch3d.sh | 24 ++++
igr/seg2d.cc | 40 ++++++
igr/seg3d.cc | 42 +++++++
igr/seg_vol_irm.hh | 309 +++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 542 insertions(+), 9 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/dump2ppm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/seg_vol_irm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/dump2pbm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/launch.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch.sh (revision 3471)
@@ -0,0 +1,4 @@
+#!/bin/zsh
+
+./launch2d.sh
+./launch3d.sh
Property changes on: trunk/milena/sandbox/fabien/igr/launch.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 3471)
@@ -0,0 +1,309 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb1d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/neighb3d.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/pgm/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/cloud/all.hh>
+#include <mln/io/dump/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/labeling/flat_zones.hh>
+#include <mln/labeling/background.hh>
+#include <mln/literal/colors.hh>
+#include <mln/norm/l1.hh>
+
+#include <mln/geom/bbox.hh>
+
+#include <mln/labeling/blobs.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/labeling/fill_holes.hh>
+#include <mln/labeling/n_max.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/level/compute.hh>
+#include <mln/level/convert.hh>
+#include <mln/level/stretch.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/fun/internal/selector.hh>
+
+#include <mln/fun/v2b/threshold.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/center.hh>
+#include <mln/accu/max.hh>
+#include <mln/accu/sum.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/stat/deviation.hh>
+
+#include <mln/histo/compute.hh>
+
+#include <mln/set/compute.hh>
+#include <mln/value/label_16.hh>
+#include <mln/data/fill.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/morpho/elementary/gradient_internal.hh>
+#include <mln/morpho/closing.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/erosion.hh>
+
+#include <mln/win/disk2d.hh>
+#include <mln/win/sphere3d.hh>
+
+#include <mln/math/diff_abs.hh>
+
+#include <mln/convert/from_to.hh>
+
+#include <mln/metal/int.hh>
+
+#include <iostream>
+#include <fstream>
+#include <mln/debug/println.hh>
+
+using namespace mln;
+using value::int_u8;
+using value::int_u12;
+using value::int_u16;
+using value::rgb8;
+using value::label_16;
+
+
+
+template <typename T>
+struct L_to_int_u8
+: mln::fun::internal::selector_<int_u8, T, L_to_int_u8<T> >::ret
+{
+ typedef int_u8 result;
+ int_u8 operator()(const T& t) const;
+};
+
+
+
+template <typename T>
+inline
+int_u8
+L_to_int_u8<T>::operator()(const T& t) const
+{
+ return static_cast<int_u8>(t == 0 ? 0 : 1 + ((unsigned) t - 1) % 255);
+}
+
+
+
+template <typename I>
+I
+close_threshold(const Image<I>& input, metal::int_<2>, int dil, int ero)
+{
+ return morpho::erosion(morpho::dilation(input, win::disk2d(dil)), win::disk2d(ero));
+}
+
+
+
+template <typename I>
+I
+close_threshold(const Image<I>& input, metal::int_<3>, int dil, int ero)
+{
+ return morpho::erosion(morpho::dilation(input, win::sphere3d(dil)), win::sphere3d(ero));
+}
+
+
+
+template <typename I, typename N>
+unsigned
+find_threshold_value(const Image<I>& input, const Neighborhood<N>& nbh)
+{
+ int bg_thres = 30;
+ int obj_thres = 15;
+
+ mln_ch_value(I, bool) ima_bg;
+ initialize(ima_bg, input);
+ data::fill(ima_bg, false);
+
+ mln_ch_value(I, bool) ima_obj;
+ initialize(ima_obj, input);
+ data::fill(ima_obj, false);
+
+ unsigned result = 0;
+
+ histo::array<mln_value(I)> arr_histo = histo::compute(input);
+ image1d<unsigned> ima_histo;
+ convert::from_to(arr_histo, ima_histo);
+
+ // We remove the 0 value because it is not part of the image.
+ ima_histo(point1d(0)) = 0;
+
+ for (unsigned int i = 1; i < ima_histo.nelements(); ++i)
+ {
+ ima_histo(point1d(i)) += ima_histo(point1d(i - 1));
+ }
+ accu::max<unsigned> max_accu;
+ unsigned max = level::compute(max_accu, ima_histo);
+ bool low_done = false;
+ bool high_done = false;
+ for (unsigned int i = 0; i < ima_histo.nelements(); ++i)
+ {
+ if (!low_done && ((ima_histo(point1d(i)) * 100) / max) > bg_thres)
+ {
+ data::fill((ima_bg | pw::value(input) < pw::cst(i)).rw(), true);
+ low_done = true;
+ }
+ if (!high_done && ((ima_histo(point1d(i)) * 100) / max) > (100 - obj_thres))
+ {
+ data::fill((ima_obj | pw::value(input) > pw::cst(i)).rw(), true);
+ high_done = true;
+ }
+ }
+
+ // Debug output images
+ if (I::site::dim == 2)
+ {
+ io::pbm::save(ima_bg, "bg.pbm");
+ io::pbm::save(ima_obj, "obj.pbm");
+ }
+ if (I::site::dim == 3)
+ {
+ io::dump::save(ima_bg, "bg.dump");
+ io::dump::save(ima_obj, "obj.dump");
+ }
+
+ ima_bg = close_threshold(ima_bg, metal::int_<I::site::dim>(), 3, 5); // 5, 7?
+ ima_obj = close_threshold(ima_obj, metal::int_<I::site::dim>(), 3, 5);
+
+ // Debug output images
+ mln_ch_value(I, rgb8) out = level::convert(rgb8(), level::stretch(int_u8(), input));
+ data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_bg, nbh)) == true).rw(), literal::red);
+ data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_obj, nbh)) == true).rw(), literal::green);
+ if (I::site::dim == 2)
+ {
+ io::pbm::save(ima_bg, "bg_closed.pbm");
+ io::pbm::save(ima_obj, "obj_closed.pbm");
+ io::ppm::save(out, "regions_color.ppm");
+ }
+ if (I::site::dim == 3)
+ {
+ io::dump::save(ima_bg, "bg_closed.dump");
+ io::dump::save(ima_obj, "obj_closed.dump");
+ io::dump::save(out, "regions_color.dump");
+ }
+
+ histo::array<mln_value(I)> bg_histo = histo::compute(input | pw::value(ima_bg) == true);
+ histo::array<mln_value(I)> obj_histo = histo::compute(input | pw::value(ima_obj) == true);
+
+ accu::sum<unsigned> sum_accu;
+ image1d<unsigned> ima_bg_histo;
+ convert::from_to(bg_histo, ima_bg_histo);
+ ima_bg_histo(point1d(0)) = 0;
+ unsigned bg_sum = level::compute(sum_accu, ima_bg_histo);
+ // We remove the 0 value because it is not part of the image.
+ std::ofstream fout_bg("bg_histo_norm.plot");
+ for (unsigned int i = 0; i < ima_bg_histo.nelements(); ++i)
+ {
+ ima_bg_histo(point1d(i)) *= 10000;
+ ima_bg_histo(point1d(i)) /= bg_sum;
+ fout_bg << i << " " << ima_bg_histo(point1d(i)) << std::endl;
+ }
+
+ image1d<unsigned> ima_obj_histo;
+ convert::from_to(obj_histo, ima_obj_histo);
+ unsigned obj_sum = level::compute(sum_accu, ima_obj_histo);
+ std::ofstream fout_obj("obj_histo_norm.plot");
+ for (unsigned int i = 0; i < ima_obj_histo.nelements(); ++i)
+ {
+ ima_obj_histo(point1d(i)) *= 10000;
+ ima_obj_histo(point1d(i)) /= obj_sum;
+ fout_obj << i << " " << ima_obj_histo(point1d(i)) << std::endl;
+ }
+
+ // Search for the index with the min distance between histogrammes.
+ unsigned min = math::diff_abs<unsigned>(ima_bg_histo(point1d(1)), ima_obj_histo(point1d(1)));
+ for (unsigned int i = 1; i < ima_bg_histo.nelements(); ++i)
+ {
+ if (math::diff_abs<unsigned>(ima_bg_histo(point1d(i)), ima_obj_histo(point1d(i))) < min)
+ {
+ min = math::diff_abs<unsigned>(ima_bg_histo(point1d(i)), ima_obj_histo(point1d(i)));
+ result = i;
+ }
+ }
+
+ return result;
+}
+
+
+
+template <typename I, typename N>
+unsigned
+find_threshold_mean(const Image<I>& input, const Neighborhood<N>& nbh)
+{
+ unsigned result = 0;
+
+ accu::mean<unsigned> mean_accu;
+ unsigned mean = level::compute(mean_accu, (input | (pw::value(input) != 0)));
+
+ accu::stat::deviation<unsigned, unsigned, float> dev_accu(mean);
+ float deviation = level::compute(dev_accu, (input | pw::value(input) != 0));
+
+ std::cout << "mean = " << mean << std::endl << "deviation = " << deviation << std::endl;
+ return floor(deviation);
+}
+
+
+
+template <typename I, typename N, typename L>
+mln_ch_value(I, bool)
+igr_seg(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nlabels)
+{
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ // Threshold.
+
+ mln_ch_value(I, bool) ima_thres;
+ initialize(ima_thres, input);
+ data::fill(ima_thres, false);
+ //unsigned threshold_value = find_threshold_value(input, nbh);
+ unsigned threshold_value = find_threshold_mean(input, nbh);
+ data::fill((ima_thres | pw::value(input) < pw::cst(threshold_value)).rw(), true);
+
+ return ima_thres;
+}
Index: trunk/milena/sandbox/fabien/igr/seg2d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 3471)
@@ -0,0 +1,40 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/pbm/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/value/label_16.hh>
+
+#include "seg_vol_irm.hh"
+
+using namespace mln;
+using value::int_u12;
+using value::label_16;
+
+
+
+int usage()
+{
+ std::cout << "Usage: ./seg2d image.dcm" << std::endl;
+
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2)
+ return usage();
+
+ label_16 nlabels;
+ image2d<int_u12> ima;
+ io::dicom::load(ima, argv[1]);
+ io::pbm::save(igr_seg(ima, c4(), nlabels), "result.pbm");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/launch2d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 3471)
@@ -0,0 +1,26 @@
+#!/bin/zsh
+
+process_file ()
+{
+ ./seg2d $1
+ if [ -f result.pbm ]; then
+ mv result.pbm results/${2}_06_result.pbm
+ fi
+
+ if [ -f bg.pbm ]; then
+ mv bg.pbm results/${2}_01_bg.pbm
+ mv obj.pbm results/${2}_03_obj.pbm
+
+ mv bg_closed.pbm results/${2}_02_bg_closed.pbm
+ mv obj_closed.pbm results/${2}_04_obj_closed.pbm
+
+ mv regions_color.ppm results/${2}_05_regions_color.ppm
+
+ mv bg_histo_norm.plot results/${2}_bg.plot
+ mv obj_histo_norm.plot results/${2}_obj.plot
+ fi
+}
+
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" "49"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" "55"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0058.dcm" "58"
Property changes on: trunk/milena/sandbox/fabien/igr/launch2d.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/seg3d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 3471)
@@ -0,0 +1,42 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb3d.hh>
+
+#include <mln/core/image/image3d.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/dump/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/value/label_16.hh>
+
+#include "seg_vol_irm.hh"
+
+using namespace mln;
+using value::int_u12;
+using value::label_16;
+
+template <typename I, typename N, typename L>
+mln_ch_value(I, bool)
+igr_seg(const Image<I>& input_, const mln::Neighborhood<N>& nbh_, L& nlabels);
+
+int usage()
+{
+ std::cout << "Usage: ./seg3d image.dcm" << std::endl;
+
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2)
+ return usage();
+
+ label_16 nlabels;
+ image3d<int_u12> ima;
+ io::dicom::load(ima, argv[1]);
+ io::dump::save(igr_seg(ima, c6(), nlabels), "result.dump");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/launch3d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 3471)
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+process_file ()
+{
+ ./seg3d $1
+ ../bin/dump2pbm result.dump results/${2}_06_result.pbm
+
+ ../bin/dump2pbm bg.dump results/${2}_01_bg.pbm
+ ../bin/dump2pbm obj.dump results/${2}_03_obj.pbm
+
+ ../bin/dump2pbm bg_closed.dump results/${2}_02_bg_closed.pbm
+ ../bin/dump2pbm obj_closed.dump results/${2}_04_obj_closed.pbm
+
+#../bin/dump2ppm regions_color.dump results/${2}_05_colors.ppm
+
+ rm *.dump
+
+ mv bg_histo_norm.plot results/${2}_bg.plot
+ mv obj_histo_norm.plot results/${2}_obj.plot
+}
+
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" "61"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" "64"
Property changes on: trunk/milena/sandbox/fabien/igr/launch3d.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3470)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3471)
@@ -1,15 +1,20 @@
-all: seg_vol_irm.cc
- g++ -I../../../ \
- -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/Common/ \
+DICOM_INC = -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/Common/ \
-I/Users/HiSoKa/Downloads/gdcmbin/Source/Common/ \
-I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataDictionary/ \
-I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/MediaStorageAndFileFormat/ \
- -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataStructureAndEncodingDefinition/ \
- -L/Users/HiSoKa/Downloads/gdcmbin/bin \
+ -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataStructureAndEncodingDefinition/
+DICOM_LIB = -L/Users/HiSoKa/Downloads/gdcmbin/bin \
-lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
- -framework CoreFoundation \
- -DNDEBUG -O1 \
- seg_vol_irm.cc -o seg_vol_irm
+ -framework CoreFoundation
+CXXFLAGS = -DNDEBUG -O1
+
+all: 2d 3d
+
+2d: seg_vol_irm.hh seg2d.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} seg2d.cc -o seg2d
+
+3d: seg_vol_irm.hh seg3d.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} seg3d.cc -o seg3d
clean:
- rm -rf *.dump *.p?m
+ rm -rf *.dump *.p?m *.plot *.log *.csv
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 0)
+++ trunk/milena/sandbox/fabien/TODO (revision 3471)
@@ -0,0 +1,13 @@
+ ___________
+< TODO list >
+ -----------
+ \ ^__^
+ \ (oo)\_______
+ (__)\ )\/\
+ ||----w |
+ || ||
+
+[X] Create binaries
+[X] Create scripts shell
+[ ] Check standard deviation
+
Index: trunk/milena/sandbox/fabien/bin/dump2ppm.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dump2ppm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dump2ppm.cc (revision 3471)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump output.ppm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::rgb8;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<rgb8> vol;
+ io::dump::load(vol, argv[1]);
+
+ rgb8 bg = literal::black;
+ image2d<rgb8> ima = debug::slices_2d(vol, 1.f, bg);
+ io::ppm::save(ima, argv[2]);
+}
Index: trunk/milena/sandbox/fabien/bin/dump2pbm.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dump2pbm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dump2pbm.cc (revision 3471)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/int_u16.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump output.pbm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u16;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<bool> vol;
+ io::dump::load(vol, argv[1]);
+
+ int_u16 bg = 0;
+ image2d<bool> ima = debug::slices_2d(vol, 1.f, bg);
+ io::pbm::save(ima, argv[2]);
+}
1
0
* mln/level/approx/median.hh: call diameter() instead of length() on
win::ball.
* mln/level/convert.hh: fix a return type.
* mln/morpho/closing/essential.hh,
* mln/morpho/essential.hh,
* mln/morpho/opening/essential.hh: Fix includes.
---
milena/ChangeLog | 13 +++++++++++++
milena/mln/level/approx/median.hh | 2 +-
milena/mln/level/convert.hh | 2 +-
milena/mln/morpho/closing/essential.hh | 5 +++--
milena/mln/morpho/essential.hh | 2 --
milena/mln/morpho/opening/essential.hh | 5 +++--
6 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6e55f81..16c404d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes (again).
+
+ * mln/level/approx/median.hh: call diameter() instead of length() on
+ win::ball.
+
+ * mln/level/convert.hh: fix a return type.
+
+ * mln/morpho/closing/essential.hh,
+ * mln/morpho/essential.hh,
+ * mln/morpho/opening/essential.hh: Fix includes.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Small fixes related to morpho.
* mln/morpho/closing/area.hh: update copyright.
diff --git a/milena/mln/level/approx/median.hh b/milena/mln/level/approx/median.hh
index 5bf1a9e..d950ccb 100644
--- a/milena/mln/level/approx/median.hh
+++ b/milena/mln/level/approx/median.hh
@@ -136,7 +136,7 @@ namespace mln
{
trace::entering("level::approx::median");
- const unsigned len = win.length() / 3 + 1;
+ const unsigned len = win.diameter() / 3 + 1;
mln_concrete(I) output;
win::diag2d win1(len);
diff --git a/milena/mln/level/convert.hh b/milena/mln/level/convert.hh
index 39da091..e3149ff 100644
--- a/milena/mln/level/convert.hh
+++ b/milena/mln/level/convert.hh
@@ -99,7 +99,7 @@ namespace mln
template <typename V, typename I>
inline
- mln_concrete(I)
+ mln_ch_value(I,V)
convert_identity(const V& v, const Image<I>& input)
{
trace::entering("level::impl::convert_identity");
diff --git a/milena/mln/morpho/closing/essential.hh b/milena/mln/morpho/closing/essential.hh
index a478a2c..a0f8055 100644
--- a/milena/mln/morpho/closing/essential.hh
+++ b/milena/mln/morpho/closing/essential.hh
@@ -34,10 +34,11 @@
/// File that includes essential closing attributes.
#include <mln/morpho/closing/algebraic.hh>
-#include <mln/morpho/closing/leveling.hh>
#include <mln/morpho/closing/area.hh>
-#include <mln/morpho/closing/volume.hh>
#include <mln/morpho/closing/height.hh>
+#include <mln/morpho/closing/leveling.hh>
+#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/closing/volume.hh>
#endif // ! MLN_MORPHO_CLOSING_ESSENTIAL_HH
diff --git a/milena/mln/morpho/essential.hh b/milena/mln/morpho/essential.hh
index d16fcce..8034b86 100644
--- a/milena/mln/morpho/essential.hh
+++ b/milena/mln/morpho/essential.hh
@@ -33,7 +33,6 @@
/// File that includes essential morpho-related routines.
-# include <mln/morpho/closing.hh>
# include <mln/morpho/dilation.hh>
# include <mln/morpho/erosion.hh>
# include <mln/morpho/gradient.hh>
@@ -41,7 +40,6 @@
# include <mln/morpho/includes.hh>
# include <mln/morpho/laplacian.hh>
# include <mln/morpho/meyer_wst.hh>
-# include <mln/morpho/opening.hh>
# include <mln/morpho/rank_filter.hh>
# include <mln/morpho/top_hat.hh>
diff --git a/milena/mln/morpho/opening/essential.hh b/milena/mln/morpho/opening/essential.hh
index 45fbdae..77bcf16 100644
--- a/milena/mln/morpho/opening/essential.hh
+++ b/milena/mln/morpho/opening/essential.hh
@@ -34,10 +34,11 @@
/// File that includes essential opening attributes.
#include <mln/morpho/opening/algebraic.hh>
-#include <mln/morpho/opening/leveling.hh>
#include <mln/morpho/opening/area.hh>
-#include <mln/morpho/opening/volume.hh>
#include <mln/morpho/opening/height.hh>
+#include <mln/morpho/opening/leveling.hh>
+#include <mln/morpho/opening/structural.hh>
+#include <mln/morpho/opening/volume.hh>
#endif // ! MLN_MORPHO_OPENING_ESSENTIAL_HH
--
1.5.6.5
1
0
* mln/morpho/closing/area.hh: update copyright.
* mln/morpho/closing/leveling.hh: fix guard and revamp.
* mln/morpho/rank_filter.hh: update forward declaration.
* tests/morpho/Makefile.am: run tests in morpho/closing and
morpho/opening.
* tests/morpho/closing/area.cc,
* tests/morpho/closing/height.cc,
* tests/morpho/closing/sum.cc,
* tests/morpho/closing/volume.cc,
* tests/morpho/opening/area.cc,
* tests/morpho/opening/height.cc,
* tests/morpho/opening/sum.cc,
* tests/morpho/opening/volume.cc: use tiny.ppm instead of lena.ppm, it
is faster.
---
milena/ChangeLog | 23 +++++++++++++
milena/mln/morpho/closing/area.hh | 2 +-
milena/mln/morpho/closing/leveling.hh | 59 ++++++++++++++++++--------------
milena/mln/morpho/rank_filter.hh | 5 ++-
milena/tests/morpho/Makefile.am | 2 +
milena/tests/morpho/closing/area.cc | 2 +-
milena/tests/morpho/closing/height.cc | 2 +-
milena/tests/morpho/closing/sum.cc | 2 +-
milena/tests/morpho/closing/volume.cc | 2 +-
milena/tests/morpho/opening/area.cc | 2 +-
milena/tests/morpho/opening/height.cc | 2 +-
milena/tests/morpho/opening/sum.cc | 2 +-
milena/tests/morpho/opening/volume.cc | 2 +-
13 files changed, 70 insertions(+), 37 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d961175..6e55f81 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,28 @@
2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes related to morpho.
+
+ * mln/morpho/closing/area.hh: update copyright.
+
+ * mln/morpho/closing/leveling.hh: fix guard and revamp.
+
+ * mln/morpho/rank_filter.hh: update forward declaration.
+
+ * tests/morpho/Makefile.am: run tests in morpho/closing and
+ morpho/opening.
+
+ * tests/morpho/closing/area.cc,
+ * tests/morpho/closing/height.cc,
+ * tests/morpho/closing/sum.cc,
+ * tests/morpho/closing/volume.cc,
+ * tests/morpho/opening/area.cc,
+ * tests/morpho/opening/height.cc,
+ * tests/morpho/opening/sum.cc,
+ * tests/morpho/opening/volume.cc: use tiny.ppm instead of lena.ppm, it
+ is faster.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add a specialization of level::convert.
* mln/level/convert.hh: Add a specialization while the conversion
diff --git a/milena/mln/morpho/closing/area.hh b/milena/mln/morpho/closing/area.hh
index a351262..f805c31 100644
--- a/milena/mln/morpho/closing/area.hh
+++ b/milena/mln/morpho/closing/area.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
diff --git a/milena/mln/morpho/closing/leveling.hh b/milena/mln/morpho/closing/leveling.hh
index 32a34c8..7825166 100644
--- a/milena/mln/morpho/closing/leveling.hh
+++ b/milena/mln/morpho/closing/leveling.hh
@@ -26,7 +26,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_LEVELING_HH
+#ifndef MLN_MORPHO_CLOSING_LEVELING_HH
# define MLN_MORPHO_CLOSING_LEVELING_HH
/// \file mln/morpho/closing/leveling.hh
@@ -37,15 +37,20 @@
# include <mln/morpho/leveling_filter.hh>
-namespace mln {
- namespace morpho {
- namespace closing {
+namespace mln
+{
- /// Morphological leveling closing.
- template <typename I, typename N, typename A>
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& accu, const mln_result(A)& lambda);
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological leveling closing.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
@@ -53,33 +58,35 @@ namespace mln {
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N, typename A>
- inline
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& accu, const mln_result(A)& lambda)
- {
- trace::entering("morpho::closing::leveling");
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ trace::entering("morpho::closing::leveling");
- mln_precondition(exact(input).is_valid());
- mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A),
- trait::accumulator::when_pix::not_ok)::value);
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::not_ok)::value);
- mln_concrete(I) output;
- output = leveling_filter(input, nbh, accu, lambda,
- /* increasing = */ true);
+ mln_concrete(I) output;
+ output = leveling_filter(input, nbh, accu, lambda,
+ /* increasing = */ true);
- mln_postcondition(output >= input);
+ mln_postcondition(output >= input);
- trace::exiting("morpho::closing::leveling");
- return output;
- }
+ trace::exiting("morpho::closing::leveling");
+ return output;
+ }
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho::closing
+
} // end of namespace mln::morpho
+
} // end of namespace mln
diff --git a/milena/mln/morpho/rank_filter.hh b/milena/mln/morpho/rank_filter.hh
index fe99eb9..4b36695 100644
--- a/milena/mln/morpho/rank_filter.hh
+++ b/milena/mln/morpho/rank_filter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -44,7 +45,7 @@ namespace mln
/// Morphological rank_filter.
template <typename I, typename W>
mln_concrete(I)
- rank_filter(const Image<I>& input, const Window<W>& win);
+ rank_filter(const Image<I>& input, const Window<W>& win, unsigned k);
# ifndef MLN_INCLUDE_ONLY
diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am
index 4775e6f..909488f 100644
--- a/milena/tests/morpho/Makefile.am
+++ b/milena/tests/morpho/Makefile.am
@@ -4,7 +4,9 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
attribute \
+ closing \
elementary \
+ opening \
tree \
watershed
diff --git a/milena/tests/morpho/closing/area.cc b/milena/tests/morpho/closing/area.cc
index 711f178..c26f49f 100644
--- a/milena/tests/morpho/closing/area.cc
+++ b/milena/tests/morpho/closing/area.cc
@@ -49,6 +49,6 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::area(lena, c4(), 510), "out.pgm");
}
diff --git a/milena/tests/morpho/closing/height.cc b/milena/tests/morpho/closing/height.cc
index 6a9561e..575a080 100644
--- a/milena/tests/morpho/closing/height.cc
+++ b/milena/tests/morpho/closing/height.cc
@@ -48,6 +48,6 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::height(lena, c4(), 20), "out.pgm");
}
diff --git a/milena/tests/morpho/closing/sum.cc b/milena/tests/morpho/closing/sum.cc
index c933da9..269b36d 100644
--- a/milena/tests/morpho/closing/sum.cc
+++ b/milena/tests/morpho/closing/sum.cc
@@ -51,7 +51,7 @@ int main()
typedef image2d<int_u8> I;
I lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
typedef morpho::attribute::sum<I> A;
io::pgm::save(morpho::closing::leveling(lena, c4(), A(), 10000),
diff --git a/milena/tests/morpho/closing/volume.cc b/milena/tests/morpho/closing/volume.cc
index fccfa8e..d26bb6f 100644
--- a/milena/tests/morpho/closing/volume.cc
+++ b/milena/tests/morpho/closing/volume.cc
@@ -50,7 +50,7 @@ int main()
typedef image2d<int_u8> I;
I lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::volume(lena, c4(), 10000),
"ref.pgm");
diff --git a/milena/tests/morpho/opening/area.cc b/milena/tests/morpho/opening/area.cc
index bfa0df7..cd9eacf 100644
--- a/milena/tests/morpho/opening/area.cc
+++ b/milena/tests/morpho/opening/area.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::area(lena, c4(), 510);
diff --git a/milena/tests/morpho/opening/height.cc b/milena/tests/morpho/opening/height.cc
index cebfd2e..eb46824 100644
--- a/milena/tests/morpho/opening/height.cc
+++ b/milena/tests/morpho/opening/height.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::height(lena, c4(), 20);
diff --git a/milena/tests/morpho/opening/sum.cc b/milena/tests/morpho/opening/sum.cc
index 0be3b8e..6eaaafc 100644
--- a/milena/tests/morpho/opening/sum.cc
+++ b/milena/tests/morpho/opening/sum.cc
@@ -52,7 +52,7 @@ int main()
I lena;
typedef morpho::attribute::sum<I> A;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::opening::leveling(lena, c4(), A(), 10000),
"out.pgm");
}
diff --git a/milena/tests/morpho/opening/volume.cc b/milena/tests/morpho/opening/volume.cc
index 0fb7f64..c72b88c 100644
--- a/milena/tests/morpho/opening/volume.cc
+++ b/milena/tests/morpho/opening/volume.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::volume(lena, c4(), 10000);
--
1.5.6.5
1
0
* mln/level/convert.hh: Add a specialization while the conversion
value type is equal to the image value type.
* tests/level/convert.cc: add a new test.
---
milena/ChangeLog | 15 ++++-
milena/mln/level/convert.hh | 115 ++++++++++++++++++++++++++++++++++++----
milena/tests/level/convert.cc | 23 ++++++---
3 files changed, 131 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8216a5f..d961175 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add a specialization of level::convert.
+
+ * mln/level/convert.hh: Add a specialization while the conversion
+ value type is equal to the image value type.
+
+ * tests/level/convert.cc: add a new test.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Introduce distance_and_closest_point_geodesic.
@@ -24,7 +33,7 @@
Update according modifications in
distance_and_closest_point_geodesic.hh.
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Add util::couple.
@@ -33,7 +42,7 @@
* mln/util/all.hh,
* mln/util/essential.hh: include new header.
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
configure.ac: configure milena/tests/transform.
diff --git a/milena/mln/level/convert.hh b/milena/mln/level/convert.hh
index 3c7a827..39da091 100644
--- a/milena/mln/level/convert.hh
+++ b/milena/mln/level/convert.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -8,7 +9,7 @@
// This library 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.
+// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
@@ -34,6 +35,7 @@
///
/// \todo Re-write doc.
+# include <mln/core/routine/duplicate.hh>
# include <mln/fun/v2v/convert.hh>
# include <mln/level/transform.hh>
@@ -44,12 +46,11 @@ namespace mln
namespace level
{
- /*! Convert the image \p input by changing the value type.
- *
- * \param[in] v A value of the destination type.
- * \param[in] input The input image.
- * \param[out] output The result image.
- */
+ /// Convert the image \p input by changing the value type.
+ ///
+ /// \param[in] v A value of the destination type.
+ /// \param[in] input The input image.
+ /// \param[out] output The result image.
template <typename V, typename I>
mln_ch_value(I, V)
convert(const V&, const Image<I>& input);
@@ -58,18 +59,108 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename V, typename I>
+ inline
+ void
+ convert_tests(const V&, const Image<I>& input)
+ {
+ mln_precondition(exact(input).is_valid());
+ (void) input;
+ }
+
+ } // using namespace mln::level::internal
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert(const V& v, const Image<I>& input)
+ {
+ trace::entering("level::impl::generic::convert");
+ internal::convert_tests(v, input);
+
+ fun::v2v::convert<V> f;
+ mln_ch_value(I, V) output = level::transform(input, f);
+
+ trace::exiting("level::impl::generic::convert");
+ return output;
+ }
+
+ } // end of namespace mln::level::impl::generic
+
+
+ template <typename V, typename I>
+ inline
+ mln_concrete(I)
+ convert_identity(const V& v, const Image<I>& input)
+ {
+ trace::entering("level::impl::convert_identity");
+ internal::convert_tests(v, input);
+
+ mln_concrete(I) output = duplicate(input);
+
+ trace::exiting("level::impl::convert_identity");
+ return output;
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ namespace internal
+ {
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(metal::bool_<true>,
+ const V& v, const Image<I>& input)
+ {
+ return impl::convert_identity(v, input);
+ }
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(metal::bool_<false>,
+ const V& v, const Image<I>& input)
+ {
+ return impl::generic::convert(v, input);
+ }
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(const V& v, const Image<I>& input)
+ {
+ enum {
+ test = mlc_equal(V, mln_value(I))::value
+ };
+ return convert_dispatch(metal::bool_<test>(),
+ v, input);
+ }
+
+ } // end of namespace mln::level::internal
+
// Facade.
template <typename V, typename I>
inline
mln_ch_value(I, V)
- convert(const V&, const Image<I>& input)
+ convert(const V& v, const Image<I>& input)
{
trace::entering("level::convert");
- mln_precondition(exact(input).is_valid());
- fun::v2v::convert<V> f;
- mln_ch_value(I, V) output = level::transform(input, f);
+ internal::convert_tests(v, input);
+
+ mln_ch_value(I, V) output = internal::convert_dispatch(v, input);
trace::exiting("level::convert");
return output;
diff --git a/milena/tests/level/convert.cc b/milena/tests/level/convert.cc
index 9b1fd1f..f9b42ab 100644
--- a/milena/tests/level/convert.cc
+++ b/milena/tests/level/convert.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,13 +26,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/convert.cc
- *
- * \brief Tests on mln::level::convert
- */
+/// \file tests/level/convert.cc
+///
+/// Tests on mln::level::convert
#include <mln/core/image/image2d.hh>
#include <mln/level/convert.hh>
+#include <mln/level/compare.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/grays.hh>
@@ -43,8 +44,6 @@ int main()
using namespace mln;
using value::rgb8;
-// trace::quiet = false;
-
// bool -> rgb8
{
image2d<bool> ima(1, 2);
@@ -54,4 +53,14 @@ int main()
mln_assertion(opt::at(out, 0, 0) == literal::black);
mln_assertion(opt::at(out, 0, 1) == literal::white);
}
+ // bool -> bool
+ {
+ image2d<bool> ima(1, 2);
+ data::fill(ima, true);
+ opt::at(ima, 0, 0) = false;
+ image2d<bool> out = level::convert(bool(), ima);
+ mln_assertion(out == ima);
+ mln_assertion(out.buffer() != ima.buffer());
+ }
+
}
--
1.5.6.5
1
0
* mln/transform/closest_point_geodesic.hh: rename as...
* mln/transform/distance_and_closest_point_geodesic.hh: ... this.
Now returns both dmap and closest point images.
Add a version returning a closest point image containing indexes.
* mln/transform/all.hh: update includes.
* mln/transform/internal/closest_point_functor.hh: add a new functor
which build a closest point image containing sites.
* tests/Makefile.am: run transform tests.
* tests/transform/Makefile.am: update test names
.
* tests/transform/bench_closest_point_geodesic.cc: fix missing
include.
* tests/transform/closest_point_geodesic.cc: rename as...
* tests/transform/distance_and_closest_point_geodesic.cc: ... this.
Update according modifications in
distance_and_closest_point_geodesic.hh.
---
milena/ChangeLog | 26 +++
milena/mln/transform/all.hh | 2 +-
milena/mln/transform/closest_point_geodesic.hh | 81 --------
.../distance_and_closest_point_geodesic.hh | 143 ++++++++++++++
.../transform/internal/closest_point_functor.hh | 196 ++++++++++++++++++--
milena/tests/Makefile.am | 1 +
milena/tests/transform/Makefile.am | 4 +-
.../transform/bench_closest_point_geodesic.cc | 1 +
milena/tests/transform/closest_point_geodesic.cc | 54 ------
.../distance_and_closest_point_geodesic.cc | 95 ++++++++++
10 files changed, 446 insertions(+), 157 deletions(-)
delete mode 100644 milena/mln/transform/closest_point_geodesic.hh
create mode 100644 milena/mln/transform/distance_and_closest_point_geodesic.hh
delete mode 100644 milena/tests/transform/closest_point_geodesic.cc
create mode 100644 milena/tests/transform/distance_and_closest_point_geodesic.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c8b7f2c..8216a5f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Introduce distance_and_closest_point_geodesic.
+
+ * mln/transform/closest_point_geodesic.hh: rename as...
+ * mln/transform/distance_and_closest_point_geodesic.hh: ... this.
+ Now returns both dmap and closest point images.
+ Add a version returning a closest point image containing indexes.
+
+ * mln/transform/all.hh: update includes.
+
+ * mln/transform/internal/closest_point_functor.hh: add a new functor
+ which build a closest point image containing sites.
+
+ * tests/Makefile.am: run transform tests.
+
+ * tests/transform/Makefile.am: update test names
+ .
+ * tests/transform/bench_closest_point_geodesic.cc: fix missing
+ include.
+
+ * tests/transform/closest_point_geodesic.cc: rename as...
+ * tests/transform/distance_and_closest_point_geodesic.cc: ... this.
+ Update according modifications in
+ distance_and_closest_point_geodesic.hh.
+
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add util::couple.
* mln/util/couple.hh: New. behaves like a std::pair.
diff --git a/milena/mln/transform/all.hh b/milena/mln/transform/all.hh
index 256a4e8..4967197 100644
--- a/milena/mln/transform/all.hh
+++ b/milena/mln/transform/all.hh
@@ -42,7 +42,7 @@ namespace mln
} // end of namespace mln
-# include <mln/transform/closest_point_geodesic.hh>
+# include <mln/transform/distance_and_closest_point_geodesic.hh>
# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
# include <mln/transform/influence_zone_front.hh>
diff --git a/milena/mln/transform/closest_point_geodesic.hh b/milena/mln/transform/closest_point_geodesic.hh
deleted file mode 100644
index 0761d00..0000000
--- a/milena/mln/transform/closest_point_geodesic.hh
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library 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 this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library 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.
-
-#ifndef MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-# define MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-
-/// \file mln/transform/closest_point_geodesic.hh
-///
-/// Geodesic closest point transform.
-///
-/// \todo Add a version to retrieve both distance and closest point
-/// maps.
-
-# include <mln/canvas/distance_geodesic.hh>
-# include <mln/transform/internal/closest_point_functor.hh>
-
-
-
-namespace mln
-{
-
- namespace transform
- {
-
- /// Discrete geodesic distance transform.
- template <typename I, typename N, typename D>
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I, typename N, typename D>
- inline
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
- {
- trace::entering("transform::closest_point_geodesic");
-
- mln_precondition(exact(input).is_valid());
- mln_precondition(exact(nbh).is_valid());
-
- internal::closest_point_functor<I> f;
- (void) mln::canvas::distance_geodesic(input, nbh, max, f);
-
- trace::exiting("transform::closest_point_geodesic");
- return f.cp_ima;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::transform
-
-} // end of namespace mln
-
-
-#endif // ! MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/distance_and_closest_point_geodesic.hh b/milena/mln/transform/distance_and_closest_point_geodesic.hh
new file mode 100644
index 0000000..efc63ab
--- /dev/null
+++ b/milena/mln/transform/distance_and_closest_point_geodesic.hh
@@ -0,0 +1,143 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+# define MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+
+/// \file mln/transform/distance_and_closest_point_geodesic.hh
+///
+/// Distance and geodesic closest point transform.
+
+# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/closest_point_functor.hh>
+
+# include <mln/data/fill.hh>
+# include <mln/util/couple.hh>
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] input Image from which the geodesic distance is computed.
+ /// \param[in] nbh Neighborhood
+ /// \param[in] max Max distance of propagation.
+ ///
+ /// \return a couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains sites.
+ ///
+ /// \post The returned images have the same domain as \p input.
+ template <typename I, typename N, typename D>
+ util::couple<mln_ch_value(I,D), mln_ch_value(I,mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] pset an array of sites.
+ /// \param[in] closest_point_domain domain of the returned image.
+ /// \param[in] nbh neighborhood
+ /// \param[in] max max distance of propagation.
+ ///
+ /// \return A couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains site indexes.
+ ///
+ /// \post The returned image domains are defined on \p closest_point_domain.
+ template <typename P, typename N, typename D>
+ util::couple<mln_image_from_grid(mln_grid(P),D),
+ mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename D>
+ inline
+ util::couple<mln_ch_value(I,D), mln_ch_value(I, mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_closest_point_geodesic");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
+
+ internal::closest_point_functor_with_sites<I> f;
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(input, nbh,
+ max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+ template <typename P, typename N, typename D>
+ inline
+ util::couple<mln_image_from_grid(mln_grid(P),D), mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_and_closest_point_geodesic");
+
+ mln_precondition(closest_point_domain.is_valid());
+ mln_precondition(exact(nbh).is_valid());
+ mln_precondition(geom::bbox(pset) <= closest_point_domain);
+
+ typedef mln_image_from_grid(mln_grid(P), bool) I;
+ internal::closest_point_functor_with_indexes<I> f(pset);
+
+ I ima(closest_point_domain);
+ data::fill(ima, false);
+ data::fill((ima | pset).rw(), true);
+
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(ima, nbh, max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/internal/closest_point_functor.hh b/milena/mln/transform/internal/closest_point_functor.hh
index 5cbac15..8df47b7 100644
--- a/milena/mln/transform/internal/closest_point_functor.hh
+++ b/milena/mln/transform/internal/closest_point_functor.hh
@@ -47,31 +47,55 @@ namespace mln
{
template <typename I>
- struct closest_point_functor
+ struct closest_point_functor_with_indexes
{
typedef mln_value(I) V;
- typedef mln_psite(I) P;
+ typedef mln_psite(I) P;
- closest_point_functor(const p_array<P>& pset);
+ closest_point_functor_with_indexes(const p_array<P>& pset);
mln_ch_value(I,unsigned) cp_ima;
const p_array<P>& pset_;
+ /// Generic version interface.
void init(const I&);
bool inqueue_p_wrt_input_p(const V& input_p);
void init_p(const P&);
bool inqueue_p_wrt_input_n(const V& input_n);
void process(const P&, const P&);
- void init_(const I& input)
- {
- init(input);
- }
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
+ };
+
+
+ template <typename I>
+ struct closest_point_functor_with_sites
+ {
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ closest_point_functor_with_sites();
+
+ mln_ch_value(I,P) cp_ima;
- bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p == true; }
- void init_p_(unsigned) { }//cp_ima.element(p) = pset_(cp_ima.point_at_index(p)); }
- bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == false; }
- void process_(unsigned p, unsigned n) { cp_ima.element(n) = cp_ima.element(p); }
+ /// Generic version interface.
+ void init(const I&);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ void init_p(const P&);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P&, const P&);
+
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned p);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
};
@@ -79,7 +103,8 @@ namespace mln
template <typename I>
inline
- closest_point_functor<I>::closest_point_functor(const p_array<mln_psite(I)>& pset)
+ closest_point_functor_with_indexes<I>::closest_point_functor_with_indexes(
+ const p_array<mln_psite(I)>& pset)
: pset_(pset)
{
}
@@ -87,20 +112,111 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init(const I& input)
+ closest_point_functor_with_indexes<I>::init(const I& input)
{
initialize(cp_ima, input);
data::fill(cp_ima, 0u);
mln_piter(p_array<mln_psite(I)>) p(pset_);
for_all(p)
- cp_ima(p) = p.index();
+ cp_ima(p) = cp_ima.index_of_point(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_p(const P&)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::process(const P& p, const P& n)
+ {
+ cp_ima(n) = cp_ima(p);
+ }
+
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::init_p_(unsigned)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
+
+ /// ///
+ /// closest_point_functor_with_sites ///
+ /// ///
+
+
+ template <typename I>
+ inline
+ closest_point_functor_with_sites<I>::closest_point_functor_with_sites()
+ {
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init(const I& input)
+ {
+ initialize(cp_ima, input);
+ data::fill(cp_ima, literal::origin);
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p(const V& input_p)
{
return input_p == true;
}
@@ -108,26 +224,68 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init_p(const P&)
+ closest_point_functor_with_sites<I>::init_p(const P& p)
{
-// cp_ima(p) = p;
+ cp_ima(p) = p;
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n(const V& input_n)
{
return input_n == false;
}
template <typename I>
inline
- void closest_point_functor<I>::process(const P& p, const P& n)
+ void
+ closest_point_functor_with_sites<I>::process(const P& p, const P& n)
{
cp_ima(n) = cp_ima(p);
}
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_sites<I>::init_p_(unsigned p)
+ {
+ cp_ima.element(p) = cp_ima.point_at_index(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform::internal
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 523af72..0e05a0f 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -41,6 +41,7 @@ SUBDIRS = \
topo \
trace \
trait \
+ transform \
unit_test \
util \
value \
diff --git a/milena/tests/transform/Makefile.am b/milena/tests/transform/Makefile.am
index 4ee9cfd..04087f7 100644
--- a/milena/tests/transform/Makefile.am
+++ b/milena/tests/transform/Makefile.am
@@ -4,14 +4,14 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
bench_closest_point_geodesic \
- closest_point_geodesic \
+ distance_and_closest_point_geodesic \
distance_front \
distance_geodesic \
influence_zone_front \
influence_zone_geodesic
bench_closest_point_geodesic_SOURCES = bench_closest_point_geodesic.cc
-closest_point_geodesic_SOURCES = closest_point_geodesic.cc
+distance_and_closest_point_geodesic_SOURCES = distance_and_closest_point_geodesic.cc
distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
influence_zone_front_SOURCES = influence_zone_front.cc
diff --git a/milena/tests/transform/bench_closest_point_geodesic.cc b/milena/tests/transform/bench_closest_point_geodesic.cc
index 974a734..06a6b44 100644
--- a/milena/tests/transform/bench_closest_point_geodesic.cc
+++ b/milena/tests/transform/bench_closest_point_geodesic.cc
@@ -36,6 +36,7 @@
#include <mln/data/fill.hh>
#include <mln/opt/at.hh>
#include <mln/transform/closest_point_geodesic.hh>
+#include <mln/value/int_u8.hh>
int main()
diff --git a/milena/tests/transform/closest_point_geodesic.cc b/milena/tests/transform/closest_point_geodesic.cc
deleted file mode 100644
index c9bb97c..0000000
--- a/milena/tests/transform/closest_point_geodesic.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library 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 this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library 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 tests/transform/closest_point_geodesic.cc
-///
-/// Test on mln::transform::closest_point_geodesic.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/data/fill.hh>
-#include <mln/debug/println.hh>
-#include <mln/opt/at.hh>
-
-#include <mln/transform/closest_point_geodesic.hh>
-
-
-int main()
-{
- using namespace mln;
- using value::int_u8;
-
- image2d<bool> input(9, 9);
- data::fill(input, false);
- opt::at(input, 2, 4) = true;
- opt::at(input, 4, 2) = true;
-
- image2d<point2d> output = transform::closest_point_geodesic(input, c4(), int_u8(4));
- debug::println(output);
-}
diff --git a/milena/tests/transform/distance_and_closest_point_geodesic.cc b/milena/tests/transform/distance_and_closest_point_geodesic.cc
new file mode 100644
index 0000000..d3544ab
--- /dev/null
+++ b/milena/tests/transform/distance_and_closest_point_geodesic.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 tests/transform/closest_point_geodesic.cc
+///
+/// Test on mln::transform::closest_point_geodesic.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/opt/at.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/transform/distance_and_closest_point_geodesic.hh>
+
+unsigned dmap_ref[] = { 4, 4, 4, 3, 2, 3, 4, 4, 4,
+ 4, 4, 3, 2, 1, 2, 3, 4, 4,
+ 4, 3, 2, 1, 0, 1, 2, 3, 4,
+ 3, 2, 1, 2, 1, 2, 3, 4, 4,
+ 2, 1, 0, 1, 2, 3, 4, 4, 4,
+ 3, 2, 1, 2, 3, 4, 4, 4, 4,
+ 4, 3, 2, 3, 4, 4, 4, 4, 4,
+ 4, 4, 3, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4 };
+
+
+unsigned cp_idx_ref[] = { 0 , 0 , 82 , 82 , 82 , 82, 82, 0 , 0 ,
+ 0 , 82 , 82 , 82 , 82 , 82, 82, 82, 0 ,
+ 110, 82 , 82 , 82 , 82 , 82, 82, 82, 82,
+ 110, 110, 110, 82 , 82 , 82, 82, 82, 0 ,
+ 110, 110, 110, 110, 82 , 82, 82, 0 , 0 ,
+ 110, 110, 110, 110, 82 , 82, 0 , 0 , 0 ,
+ 110, 110, 110, 110, 110, 0 , 0 , 0 , 0 ,
+ 0 , 110, 110, 110, 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 110, 0 , 0 , 0 , 0 , 0 , 0 };
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input(9, 9);
+ data::fill(input, false);
+ opt::at(input, 2, 4) = true;
+ opt::at(input, 4, 2) = true;
+
+ {
+ typedef util::couple<image2d<int_u8>, image2d<point2d> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(input,
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ ///FIXME: test the closest point image here.
+ }
+
+ {
+ p_array<point2d> arr;
+ arr.insert(point2d(2, 4));
+ arr.insert(point2d(4, 2));
+ typedef util::couple<image2d<int_u8>, image2d<unsigned> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(arr,
+ input.domain(),
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ mln_assertion(output.second() == make::image2d(cp_idx_ref));
+ }
+}
--
1.5.6.5
1
0
* mln/util/couple.hh: New. behaves like a std::pair.
* mln/util/all.hh,
* mln/util/essential.hh: include new header.
---
milena/ChangeLog | 9 ++
milena/mln/util/all.hh | 3 +-
milena/mln/util/couple.hh | 253 ++++++++++++++++++++++++++++++++++++++++++
milena/mln/util/essential.hh | 10 +-
4 files changed, 269 insertions(+), 6 deletions(-)
create mode 100644 milena/mln/util/couple.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1bd69d2..c8b7f2c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add util::couple.
+
+ * mln/util/couple.hh: New. behaves like a std::pair.
+
+ * mln/util/all.hh,
+ * mln/util/essential.hh: include new header.
+
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
configure.ac: configure milena/tests/transform.
2009-03-03 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
diff --git a/milena/mln/util/all.hh b/milena/mln/util/all.hh
index 4eb7f2f..180b8a1 100644
--- a/milena/mln/util/all.hh
+++ b/milena/mln/util/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -50,6 +50,7 @@ namespace mln
# include <mln/util/array.hh>
# include <mln/util/branch_iter.hh>
# include <mln/util/branch_iter_ind.hh>
+# include <mln/util/couple.hh>
# include <mln/util/dindex.hh>
# include <mln/util/eat.hh>
# include <mln/util/edge.hh>
diff --git a/milena/mln/util/couple.hh b/milena/mln/util/couple.hh
new file mode 100644
index 0000000..00b69d4
--- /dev/null
+++ b/milena/mln/util/couple.hh
@@ -0,0 +1,253 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_UTIL_COUPLE_HH
+# define MLN_UTIL_COUPLE_HH
+
+/// \file mln/util/couple.hh
+///
+/// Definition of a couple.
+///
+/// \todo revamp and refactor with util::site_pair or ord_pair.
+
+# include <mln/core/concept/object.hh>
+# include <mln/util/ord.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ template <typename T, typename U>
+ struct couple : public mln::Object< couple<T,U> >
+ {
+ public:
+ couple();
+ couple(const T& val1, const U& val2);
+
+ public:
+ /// Get the first member of the couple.
+ /// \{
+ const T& first() const;
+ T& first();
+ /// \}
+
+ /// Get the second member of the couple.
+ /// \{
+ const U& second() const;
+ U& second();
+ /// \}
+
+ /// Replace the first member of the couple by \a val.
+ void change_first(const T& val);
+
+ /// Replace the second member of the couple by \a val.
+ void change_second(const U& val);
+
+ /// Replace both members of the couple by \a val.
+ void change_both(const T& first, const U& second);
+
+ private:
+ T first_;
+ U second_;
+ };
+
+
+ template <typename T, typename U>
+ bool operator==(const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+ template <typename T, typename U>
+ bool operator< (const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+ template <typename T, typename U>
+ bool operator<=(const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+
+ template <typename T, typename U>
+ std::ostream& operator<<(std::ostream& ostr, const couple<T,U>& op);
+
+ } // end of namespace mln::util
+
+
+ namespace make
+ {
+ /// Construct an mln::util::couple on-the-fly.
+ template <typename T, typename U>
+ util::couple<T,U> couple(const T& val1, const T& val2);
+ }
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace util
+ {
+
+ /*---------------.
+ | Construction. |
+ `---------------*/
+
+ template <typename T, typename U>
+ inline
+ couple<T,U>::couple()
+ {
+ }
+
+ template <typename T, typename U>
+ inline
+ couple<T,U>::couple(const T& val1, const U& val2)
+ {
+ change_both(val1, val2);
+ }
+
+ /*---------.
+ | Access. |
+ `---------*/
+
+ template <typename T, typename U>
+ inline
+ const T&
+ couple<T,U>::first() const
+ {
+ return first_;
+ }
+
+ template <typename T, typename U>
+ inline
+ T&
+ couple<T,U>::first()
+ {
+ return first_;
+ }
+
+ template <typename T, typename U>
+ inline
+ const U&
+ couple<T,U>::second() const
+ {
+ return second_;
+ }
+
+ template <typename T, typename U>
+ inline
+ U&
+ couple<T,U>::second()
+ {
+ return second_;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_first(const T& val)
+ {
+ first_ = val;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_second(const U& val)
+ {
+ second_ = val;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_both(const T& val1, const U& val2)
+ {
+ first_ = val1;
+ second_ = val2;
+ }
+
+ /*-------------.
+ | Comparison. |
+ `-------------*/
+
+ template <typename T, typename U>
+ inline
+ bool operator==(const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return lhs.first() == rhs.first() && lhs.second() == rhs.second();
+ }
+
+ template <typename T, typename U>
+ inline
+ bool operator< (const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return
+ util::ord_strict(lhs.first(), rhs.first()) ||
+ (lhs.first() == rhs.first() &&
+ util::ord_strict(lhs.second(), rhs.second()));
+ }
+
+ template <typename T, typename U>
+ inline
+ bool operator<=(const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return
+ util::ord_strict(lhs.first(), rhs.first()) ||
+ (lhs.first() == rhs.first() &&
+ util::ord_weak(lhs.second(), rhs.second()));
+ }
+
+ /*------------------.
+ | Pretty-printing. |
+ `------------------*/
+
+ template <typename T, typename U>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const couple<T,U>& op)
+ {
+ return ostr << '(' << op.first() << ',' << op.second() << ')';
+ }
+
+ } // end of namespace mln::util
+
+
+ namespace make
+ {
+
+ template <typename T, typename U>
+ inline
+ util::couple<T,U>
+ couple(const T& val1, const U& val2)
+ {
+ util::couple<T,U> tmp(val1, val2);
+ return tmp;
+ }
+
+ } // end of namespace mln::make
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_COUPLE_HH
diff --git a/milena/mln/util/essential.hh b/milena/mln/util/essential.hh
index b041f2a..3c9b74f 100644
--- a/milena/mln/util/essential.hh
+++ b/milena/mln/util/essential.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,12 @@
#ifndef MLN_UTIL_ESSENTIAL_HH
# define MLN_UTIL_ESSENTIAL_HH
-/*! \file mln/util/essential.hh
- *
- * \brief File that includes essential util-related routines.
- */
+/// \file mln/util/essential.hh
+///
+/// File that includes essential util-related routines.
# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
# include <mln/util/lazy_set.hh>
# include <mln/util/lemmings.hh>
# include <mln/util/ord.hh>
--
1.5.6.5
1
0
---
configure.ac | 1 +
milena/ChangeLog | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index f65fe88..018fec3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -260,6 +260,7 @@ AC_CONFIG_FILES([
milena/tests/trait/image/Makefile
milena/tests/trait/op/Makefile
milena/tests/trait/value/Makefile
+ milena/tests/transform/Makefile
milena/tests/util/Makefile
milena/tests/unit_test/Makefile
milena/tests/value/Makefile
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0540c31..1bd69d2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ configure.ac: configure milena/tests/transform.
+
2009-03-03 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing tests in morpho.
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing tests in morpho.
* tests/morpho/top_hat.cc: New.
* tests/morpho/Makefile.am: Update.
* tests/morpho/closing/area.cc,
* tests/morpho/closing/height.cc (Copyright): Fix.
* tests/morpho/closing/structural.cc: New.
* tests/morpho/closing/Makefile.am: Update.
* tests/morpho/opening/volume.cc,
* tests/morpho/opening/area.cc,
* tests/morpho/opening/height.cc (Copyright): Fix.
* tests/morpho/opening/structural.cc: New.
* tests/morpho/opening/Makefile.am: Update.
Makefile.am | 12 ++++------
closing/Makefile.am | 2 +
closing/area.cc | 4 +--
closing/height.cc | 5 ++--
closing/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/Makefile.am | 2 +
opening/area.cc | 4 +--
opening/height.cc | 4 ++-
opening/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/volume.cc | 4 ++-
top_hat.cc | 24 ++++++++++----------
11 files changed, 152 insertions(+), 27 deletions(-)
Index: tests/morpho/top_hat.cc
--- tests/morpho/top_hat.cc (revision 3462)
+++ tests/morpho/top_hat.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/top_hat.cc
- *
- * \brief Test on mln::morpho::elementary::top_hat's.
- */
+/// \file tests/morpho/elementary/top_hat.cc
+///
+/// Test on mln::morpho::top_hat.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/top_hat.hh>
+#include <mln/morpho/top_hat.hh>
int main()
@@ -51,15 +51,15 @@
debug::iota(ima);
debug::println(ima);
- debug::println( morpho::elementary::top_hat_white(ima, c4()) );
- debug::println( morpho::elementary::top_hat_black(ima, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
+ debug::println( morpho::top_hat_white(ima, c4().win()) );
+ debug::println( morpho::top_hat_black(ima, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(ima, c4().win()) );
image2d<bool> msk(3, 3, 0);
data::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
- debug::println( morpho::elementary::top_hat_white(msk, c4()) );
- debug::println( morpho::elementary::top_hat_black(msk, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(msk, c4()) );
+ debug::println( morpho::top_hat_white(msk, c4().win()) );
+ debug::println( morpho::top_hat_black(msk, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(msk, c4().win()) );
}
Property changes on: tests/morpho/top_hat.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/morpho/closing/Makefile.am
--- tests/morpho/closing/Makefile.am (revision 3463)
+++ tests/morpho/closing/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/closing/area.cc
--- tests/morpho/closing/area.cc (revision 3463)
+++ tests/morpho/closing/area.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: tests/morpho/closing/height.cc
--- tests/morpho/closing/height.cc (revision 3463)
+++ tests/morpho/closing/height.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -41,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/closing/structural.cc
--- tests/morpho/closing/structural.cc (revision 0)
+++ tests/morpho/closing/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 tests/morpho/closing/structural.cc
+///
+/// Test on mln::morpho::closing::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/closing/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::closing::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/opening/Makefile.am
--- tests/morpho/opening/Makefile.am (revision 3463)
+++ tests/morpho/opening/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/opening/volume.cc
--- tests/morpho/opening/volume.cc (revision 3463)
+++ tests/morpho/opening/volume.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/area.cc
--- tests/morpho/opening/area.cc (revision 3463)
+++ tests/morpho/opening/area.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -41,7 +42,6 @@
#include "tests/data.hh"
-
int main()
{
using namespace mln;
Index: tests/morpho/opening/height.cc
--- tests/morpho/opening/height.cc (revision 3463)
+++ tests/morpho/opening/height.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/structural.cc
--- tests/morpho/opening/structural.cc (revision 0)
+++ tests/morpho/opening/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 tests/morpho/opening/structural.cc
+///
+/// Test on mln::morpho::opening::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/opening/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::opening::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 3463)
+++ tests/morpho/Makefile.am (working copy)
@@ -30,7 +30,9 @@
meyer_wst_long \
rank_filter \
skeleton_constrained \
- thinning
+ thinning \
+ top_hat
+
# -------------- #
# Normal tests. #
@@ -38,7 +40,6 @@
# FIXME: Have erosion and dilation perform symmetric tests.
erosion_SOURCES = erosion.cc
-
contrast_SOURCES = contrast.cc
general_SOURCES = general.cc
gradient_SOURCES = gradient.cc
@@ -48,21 +49,18 @@
graph_image_morpho_SOURCES = graph_image_morpho.cc
graph_image_wst_SOURCES = graph_image_wst.cc
-
line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc
line_graph_image_wst_SOURCES = line_graph_image_wst.cc
-
complex_image_morpho_SOURCES = complex_image_morpho.cc
complex_image_wst_SOURCES = complex_image_wst.cc
meyer_wst_SOURCES = meyer_wst.cc
-
rank_filter_SOURCES = rank_filter.cc
-
skeleton_constrained_SOURCES = skeleton_constrained.cc
-
+top_hat_SOURCES = top_hat.cc
combined_SOURCES = combined.cc
+
# --------------- #
# Complex tests. #
# --------------- #
1
0
03 Mar '09
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update calls to morphological structural closing and opening.
* nivault/extract_score.cc,
* garrigues/factures/extract_array_highlight.cc,
* inim/nature/closing.cc,
* inim/nature/nature.cc,
* inim/nature/opening.cc,
* inim/nature/hom.cc,
* theo/exec/closing_isotropic.cc
(closing, opening): Update to...
(closing::structural, opening::structural): ...this.
* dalila/dematOld.hh,
* dalila/demat.hh: Remove; they are just copies of...
* scribo/demat.hh: ...this!
garrigues/factures/extract_array_highlight.cc | 12 ++++++++----
inim/nature/closing.cc | 8 +++++---
inim/nature/hom.cc | 10 ++++++----
inim/nature/nature.cc | 11 ++++++-----
inim/nature/opening.cc | 8 +++++---
nivault/extract_score.cc | 13 +++++++------
theo/exec/closing_isotropic.cc | 6 +++---
7 files changed, 40 insertions(+), 28 deletions(-)
Index: nivault/extract_score.cc
--- nivault/extract_score.cc (revision 3462)
+++ nivault/extract_score.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -40,8 +41,8 @@
# include <mln/morpho/erosion.hh>
# include <mln/morpho/dilation.hh>
# include <mln/morpho/complementation.hh>
-# include <mln/morpho/closing.hh>
-# include <mln/morpho/opening.hh>
+# include <mln/morpho/closing/structural.hh>
+# include <mln/morpho/opening/structural.hh>
# include <mln/make/w_window2d.hh>
# include <mln/win/rectangle2d.hh>
# include <mln/win/vline2d.hh>
@@ -209,8 +210,8 @@
// }
{ // fermeture avec un disk et un element vertial pour reperer les notes.
- IB closed1 = morpho::opening(score_b, win::vline2d(5));
- IB closed2 = morpho::opening(score_b, win::disk2d(5));
+ IB closed1 = morpho::opening::structural(score_b, win::vline2d(5));
+ IB closed2 = morpho::opening::structural(score_b, win::disk2d(5));
morpho::opening_area(closed1, c4(), 20, closed1);
morpho::opening_area(closed2, c4(), 15, closed2);
io::pbm::save(closed1, "closed1.pbm");
@@ -220,7 +221,7 @@
}
{ // Fermeture avec un element struturant en horizontale pour obtenir les lignes de port�e.
-// IB hclosed = morpho::closing(score_b, win::hline2d(73));
+// IB hclosed = morpho::closing::structural(score_b, win::hline2d(73));
// io::pbm::save(hclosed, "hclosed.pbm");
}
}
Index: garrigues/factures/extract_array_highlight.cc
--- garrigues/factures/extract_array_highlight.cc (revision 3462)
+++ garrigues/factures/extract_array_highlight.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,7 +32,7 @@
#include <mln/geom/resize.hh>
#include <mln/display/all.hh>
#include <mln/value/int_u8.hh>
-#include <mln/morpho/opening.hh>
+#include <mln/morpho/opening/structural.hh>
#include <mln/win/hline2d.hh>
#include <mln/win/vline2d.hh>
#include <mln/win/disk2d.hh>
@@ -51,10 +52,12 @@
#include <mln/draw/box.hh>
+
using namespace mln;
typedef image2d<bool> ima2d_bool;
typedef image2d<unsigned> ima2d_unsigned;
+
image2d<bool>
filter_arrays(image2d<bool> in)
{
@@ -98,6 +101,7 @@
return output;
}
+
image2d<value::rgb8>
highlight_vlines(image2d<bool> in)
{
@@ -106,7 +110,7 @@
tmp = filter_arrays(in);
// Opening.
- tmp = morpho::opening(tmp, win::vline2d(5));
+ tmp = morpho::opening::structural(tmp, win::vline2d(5));
image2d<value::rgb8> output(tmp.domain());
mln_fwd_piter_(ima2d_unsigned) p(tmp.domain());
@@ -127,7 +131,7 @@
image2d<bool> tmp;
tmp = filter_arrays(in);
// Opening.
- tmp = morpho::opening(tmp, win::hline2d(5));
+ tmp = morpho::opening::structural(tmp, win::hline2d(5));
image2d<value::rgb8> output(tmp.domain());
mln_fwd_piter_(ima2d_unsigned) p(tmp.domain());
Index: inim/nature/closing.cc
--- inim/nature/closing.cc (revision 3462)
+++ inim/nature/closing.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -32,7 +33,8 @@
#include <mln/io/pgm/save.hh>
#include <mln/value/int_u8.hh>
-#include <mln/morpho/closing.hh>
+#include <mln/morpho/closing/structural.hh>
+
int main(int argc, const char * argv[])
{
@@ -54,6 +56,6 @@
std::string name(argv[i]);
name.erase(name.length() - 4);
- io::pgm::save(morpho::closing(ima, rect), name.append("_closed.pgm"));
+ io::pgm::save(morpho::closing::structural(ima, rect), name.append("_closed.pgm"));
}
}
Index: inim/nature/nature.cc
--- inim/nature/nature.cc (revision 3462)
+++ inim/nature/nature.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -53,7 +54,7 @@
#include <mln/morpho/hit_or_miss.hh>
#include <mln/morpho/gradient.hh>
-#include <mln/morpho/opening.hh>
+#include <mln/morpho/opening/structural.hh>
#include <mln/binarization/threshold.hh>
@@ -367,8 +368,8 @@
image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
- image2d<bool> final = morpho::opening(inter, win::hline2d(20));
- final += morpho::opening(inter, win::vline2d(20));
+ image2d<bool> final = morpho::opening::structural(inter, win::hline2d(20));
+ final += morpho::opening::structural(inter, win::vline2d(20));
// Now we count blank points in our result
@@ -398,7 +399,7 @@
// Last but not least : text detection thanks to FFT
- transform::fft<double> fourier(morpho::opening(uinty, win::hline2d(20)));
+ transform::fft<double> fourier(morpho::opening::structural(uinty, win::hline2d(20)));
fourier.transform();
std::string name(argv[1]);
Index: inim/nature/opening.cc
--- inim/nature/opening.cc (revision 3462)
+++ inim/nature/opening.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -32,7 +33,8 @@
#include <mln/io/pgm/save.hh>
#include <mln/value/int_u8.hh>
-#include <mln/morpho/opening.hh>
+#include <mln/morpho/opening/structural.hh>
+
int main(int argc, const char * argv[])
{
@@ -54,6 +56,6 @@
std::string name(argv[i]);
name.erase(name.length() - 4);
- io::pgm::save(morpho::opening(ima, rect), name.append("_opened.pgm"));
+ io::pgm::save(morpho::opening::structural(ima, rect), name.append("_opened.pgm"));
}
}
Index: inim/nature/hom.cc
--- inim/nature/hom.cc (revision 3462)
+++ inim/nature/hom.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,11 +44,12 @@
#include <mln/estim/mean.hh>
#include <mln/morpho/hit_or_miss.hh>
#include <mln/morpho/dilation.hh>
-#include <mln/morpho/opening.hh>
+#include <mln/morpho/opening/structural.hh>
#include <mln/win/hline2d.hh>
#include <mln/win/vline2d.hh>
+
int main(int argc, const char * argv[])
{
using namespace mln;
@@ -305,8 +307,8 @@
convert::from_to(vert, winin);
convert::from_to(hori, winout);
- image2d<bool> final = morpho::opening(inter, win::hline2d(20));
- final += morpho::opening(inter, win::vline2d(20));
+ image2d<bool> final = morpho::opening::structural(inter, win::hline2d(20));
+ final += morpho::opening::structural(inter, win::vline2d(20));
io::pbm::save( final,
name.append("_hom.pbm"));
Index: theo/exec/closing_isotropic.cc
--- theo/exec/closing_isotropic.cc (revision 3462)
+++ theo/exec/closing_isotropic.cc (working copy)
@@ -1,6 +1,6 @@
#include "filetype.hh"
-#include <mln/morpho/closing.hh>
+#include <mln/morpho/closing/structural.hh>
#include <mln/win/disk2d.hh>
#include <mln/win/sphere3d.hh>
@@ -41,7 +41,7 @@
{
image2d<bool> ima, out;
io::pbm::load(ima, argv[1]);
- out = morpho::closing(ima, win::disk2d(2 * r + 1));
+ out = morpho::closing::structural(ima, win::disk2d(2 * r + 1));
io::pbm::save(out, argv[3]);
}
break;
@@ -50,7 +50,7 @@
{
image3d<bool> ima, out;
io::dump::load(ima, argv[1]);
- out = morpho::closing(ima, win::sphere3d(2 * r + 1));
+ out = morpho::closing::structural(ima, win::sphere3d(2 * r + 1));
io::dump::save(out, argv[3]);
}
break;
1
0
03 Mar '09
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Disambiguate morphological structural opening and closing.
* mln/morpho/closing.hh: Move and rename as...
* mln/morpho/closing/structural.hh: ...this.
(closing): Rename as...
(closing::structural): ...this.
Layout.
* mln/morpho/closing/all.hh: Update.
* mln/morpho/opening.hh: Move and rename as...
* mln/morpho/opening/structural.hh: ...this.
(opening): Rename as...
(opening::structural): ...this.
Layout.
* mln/morpho/opening/all.hh: Update.
* mln/morpho/all.hh: Update.
* mln/morpho/elementary/closing.hh,
* mln/morpho/elementary/opening.hh: Layout.
* mln/morpho/elementary/top_hat.hh: Update doc style.
Layout.
(top_hat_white, top_hat_black, top_hat_self_complementary):
Make calls to elementary closing (resp. opening) explicit.
* mln/morpho/top_hat.hh: Update doc style.
(top_hat_white, top_hat_black, top_hat_self_complementary):
Make calls to structural closing (resp. opening) explicit.
all.hh | 2 -
closing/all.hh | 14 +++++----
closing/structural.hh | 36 ++++++++++++++++---------
elementary/closing.hh | 2 +
elementary/opening.hh | 2 +
elementary/top_hat.hh | 56 +++++++++++++++++++++------------------
opening/all.hh | 14 +++++----
opening/structural.hh | 38 ++++++++++++++++----------
top_hat.hh | 71 +++++++++++++++++++++++++++++---------------------
9 files changed, 141 insertions(+), 94 deletions(-)
Index: mln/morpho/closing/all.hh
--- mln/morpho/closing/all.hh (revision 3461)
+++ mln/morpho/closing/all.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,14 +30,17 @@
/// \file mln/morpho/closing/all.hh
///
-/// File that includes all closing attributes.
+/// File that includes all closing operators.
+
#include <mln/morpho/closing/algebraic.hh>
-#include <mln/morpho/closing/leveling.hh>
-#include <mln/morpho/closing/area_on_vertices.hh>
#include <mln/morpho/closing/area.hh>
-#include <mln/morpho/closing/volume.hh>
+#include <mln/morpho/closing/area_on_vertices.hh>
#include <mln/morpho/closing/height.hh>
+#include <mln/morpho/closing/leveling.hh>
+#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/closing/volume.hh>
+
#endif // ! MLN_MORPHO_CLOSING_ALL_HH
Index: mln/morpho/closing/structural.hh
--- mln/morpho/closing/structural.hh (revision 3461)
+++ mln/morpho/closing/structural.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,12 +26,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_CLOSING_HH
-# define MLN_MORPHO_CLOSING_HH
+#ifndef MLN_MORPHO_CLOSING_STRUCTURAL_HH
+# define MLN_MORPHO_CLOSING_STRUCTURAL_HH
-/// \file mln/morpho/closing.hh
+/// \file mln/morpho/closing/structural.hh
///
-/// Morphological closing.
+/// Morphological structural closing.
# include <mln/morpho/includes.hh>
@@ -42,36 +42,48 @@
namespace morpho
{
- /// Morphological closing.
+ namespace closing
+ {
+
+ /// Morphological structural closing.
///
/// This operator is e_{-B} o d_B.
///
template <typename I, typename W>
- mln_concrete(I) closing(const Image<I>& input, const Window<W>& win);
+ mln_concrete(I)
+ structural(const Image<I>& input, const Window<W>& win);
+
# ifndef MLN_INCLUDE_ONLY
+
template <typename I, typename W>
inline
- mln_concrete(I) closing(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ structural(const Image<I>& input, const Window<W>& win)
{
- trace::entering("morpho::closing");
+ trace::entering("morpho::closing::structural");
+
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
mln_concrete(I) output = erosion(dilation(input, win), win::sym(win));
mln_postcondition(output >= input);
- trace::exiting("morpho::closing");
+
+ trace::exiting("morpho::closing::structural");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::closing
+
} // end of namespace mln::morpho
} // end of namespace mln
-#endif // ! MLN_MORPHO_CLOSING_HH
+#endif // ! MLN_MORPHO_CLOSING_STRUCTURAL_HH
Property changes on: mln/morpho/closing/structural.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/morpho/elementary/closing.hh
--- mln/morpho/elementary/closing.hh (revision 3461)
+++ mln/morpho/elementary/closing.hh (working copy)
@@ -49,6 +49,7 @@
/// Morphological elementary closing.
///
/// This operator is e o d.
+ //
template <typename I, typename N>
mln_concrete(I) closing(const Image<I>& input, const Neighborhood<N>& nbh);
@@ -67,6 +68,7 @@
mln_concrete(I) output = erosion(dilation(input, nbh), nbh);
mln_postcondition(output >= input);
+
trace::exiting("morpho::elementary::closing");
return output;
}
Index: mln/morpho/elementary/top_hat.hh
--- mln/morpho/elementary/top_hat.hh (revision 3461)
+++ mln/morpho/elementary/top_hat.hh (working copy)
@@ -49,31 +49,31 @@
namespace elementary
{
- /*! Morphological elementary white top-hat (for object / light objects).
- *
- * This operator is Id - ope.
- */
+ /// Morphological elementary white top-hat (for object / light objects).
+ ///
+ /// This operator is Id - ope.
+ //
template <typename I, typename N>
mln_concrete(I)
top_hat_white(const Image<I>& input, const Neighborhood<N>& nbh);
- /*! Morphological elementary black top-hat (for background / dark objects).
- *
- * This operator is clo - Id.
- */
+ /// Morphological elementary black top-hat (for background / dark objects).
+ ///
+ /// This operator is clo - Id.
+ //
template <typename I, typename N>
mln_concrete(I)
top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh);
- /*! Morphological elementary self-complementary top-hat.
- *
- * This operator is \n
- * = top_hat_white + top_hat_black \n
- * = (Id - opening) + (closing - Id) \n
- * = closing - opening. \n
- */
+ /// Morphological elementary self-complementary top-hat.
+ ///
+ /// This operator is \n
+ /// = top_hat_white + top_hat_black \n
+ /// = (Id - opening) + (closing - Id) \n
+ /// = closing - opening. \n
+ //
template <typename I, typename N>
mln_concrete(I)
top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh);
@@ -81,61 +81,67 @@
# ifndef MLN_INCLUDE_ONLY
+
template <typename I, typename N>
inline
mln_concrete(I)
- top_hat_white(const Image<I>& input,
- const Neighborhood<N>& nbh)
+ top_hat_white(const Image<I>& input, const Neighborhood<N>& nbh)
{
trace::entering("morpho::elementary::top_hat_white");
+
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
mln_concrete(I) output = morpho::minus(input,
- opening(input, nbh));
+ elementary::opening(input, nbh));
mln_postcondition(test::positive(output));
+
trace::exiting("morpho::elementary::top_hat_white");
return output;
}
+
template <typename I, typename N>
inline
mln_concrete(I)
- top_hat_black(const Image<I>& input,
- const Neighborhood<N>& nbh)
+ top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh)
{
trace::entering("morpho::elementary::top_hat_black");
+
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = morpho::minus(closing(input, nbh),
+ mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
input);
mln_postcondition(test::positive(output));
+
trace::exiting("morpho::elementary::top_hat_black");
return output;
}
+
template <typename I, typename N>
inline
mln_concrete(I)
- top_hat_self_complementary(const Image<I>& input,
- const Neighborhood<N>& nbh)
+ top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh)
{
trace::entering("morpho::elementary::top_hat_self_complementary");
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = morpho::minus(closing(input, nbh),
- opening(input, nbh));
+ mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
+ elementary::opening(input, nbh));
mln_postcondition(test::positive(output));
// mln_postcondition(output == white + black);
+
trace::exiting("morpho::elementary::top_hat_self_complementary");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho::elementary
Index: mln/morpho/elementary/opening.hh
--- mln/morpho/elementary/opening.hh (revision 3461)
+++ mln/morpho/elementary/opening.hh (working copy)
@@ -49,6 +49,7 @@
/// Morphological elementary opening.
///
/// This operator is d o e.
+ //
template <typename I, typename N>
mln_concrete(I) opening(const Image<I>& input, const Neighborhood<N>& nbh);
@@ -67,6 +68,7 @@
mln_concrete(I) output = dilation(erosion(input, nbh), nbh);
mln_postcondition(output <= input);
+
trace::exiting("morpho::elementary::opening");
return output;
}
Index: mln/morpho/all.hh
--- mln/morpho/all.hh (revision 3461)
+++ mln/morpho/all.hh (working copy)
@@ -56,7 +56,6 @@
}
-# include <mln/morpho/closing.hh>
# include <mln/morpho/complementation.hh>
# include <mln/morpho/contrast.hh>
# include <mln/morpho/dilation.hh>
@@ -69,7 +68,6 @@
# include <mln/morpho/meyer_wst.hh>
# include <mln/morpho/min.hh>
# include <mln/morpho/minus.hh>
-# include <mln/morpho/opening.hh>
# include <mln/morpho/plus.hh>
# include <mln/morpho/Rd.hh>
# include <mln/morpho/rank_filter.hh>
Index: mln/morpho/top_hat.hh
--- mln/morpho/top_hat.hh (revision 3461)
+++ mln/morpho/top_hat.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +29,14 @@
#ifndef MLN_MORPHO_TOP_HAT_HH
# define MLN_MORPHO_TOP_HAT_HH
-/*! \file mln/morpho/top_hat.hh
- *
- * \brief Morphological top-hats.
- *
- * \todo Save memory.
- */
+/// \file mln/morpho/top_hat.hh
+///
+/// Morphological top-hats.
+///
+/// \todo Save memory.
-# include <mln/morpho/opening.hh>
-# include <mln/morpho/closing.hh>
+# include <mln/morpho/opening/structural.hh>
+# include <mln/morpho/closing/structural.hh>
namespace mln
@@ -45,86 +45,99 @@
namespace morpho
{
- /*! Morphological white top-hat (for object / light objects).
- *
- * This operator is Id - ope_B.
- */
+
+ /// Morphological white top-hat (for object / light objects).
+ ///
+ /// This operator is Id - ope_B.
+ //
template <typename I, typename W>
mln_concrete(I)
top_hat_white(const Image<I>& input, const Window<W>& win);
- /*! Morphological black top-hat (for background / dark objects).
- *
- * This operator is clo_B - Id.
- */
+ /// Morphological black top-hat (for background / dark objects).
+ ///
+ /// This operator is clo_B - Id.
+ //
template <typename I, typename W>
mln_concrete(I)
top_hat_black(const Image<I>& input, const Window<W>& win);
- /*! Morphological self-complementary top-hat.
- *
- * This operator is \n
- * = top_hat_white + top_hat_black \n
- * = (input - opening) + (closing - input) \n
- * = closing - opening. \n
- */
+ /// Morphological self-complementary top-hat.
+ ///
+ /// This operator is \n
+ /// = top_hat_white + top_hat_black \n
+ /// = (input - opening) + (closing - input) \n
+ /// = closing - opening. \n
+ //
template <typename I, typename W>
mln_concrete(I)
top_hat_self_complementary(const Image<I>& input, const Window<W>& win);
+
# ifndef MLN_INCLUDE_ONLY
+
template <typename I, typename W>
inline
- mln_concrete(I) top_hat_white(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ top_hat_white(const Image<I>& input, const Window<W>& win)
{
trace::entering("morpho::top_hat_white");
+
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
mln_concrete(I) output = morpho::minus(input,
- opening(input, win));
+ opening::structural(input, win));
mln_postcondition(test::positive(output));
+
trace::exiting("morpho::top_hat_white");
return output;
}
+
template <typename I, typename W>
inline
mln_concrete(I) top_hat_black(const Image<I>& input, const Window<W>& win)
{
trace::entering("morpho::top_hat_black");
+
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
- mln_concrete(I) output = morpho::minus(closing(input, win),
+ mln_concrete(I) output = morpho::minus(closing::structural(input, win),
input);
mln_postcondition(test::positive(output));
+
trace::exiting("morpho::top_hat_black");
return output;
}
+
template <typename I, typename W>
inline
mln_concrete(I) top_hat_self_complementary(const Image<I>& input, const Window<W>& win)
{
trace::entering("morpho::top_hat_self_complementary");
+
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
- mln_concrete(I) output = morpho::minus(closing(input, win),
- opening(input, win));
+ mln_concrete(I) output = morpho::minus(closing::structural(input, win),
+ opening::structural(input, win));
mln_postcondition(test::positive(output));
+
trace::exiting("morpho::top_hat_self_complementary");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho
Index: mln/morpho/opening/all.hh
--- mln/morpho/opening/all.hh (revision 3461)
+++ mln/morpho/opening/all.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,14 +30,17 @@
/// \file mln/morpho/opening/all.hh
///
-/// File that includes all opening attributes.
+/// File that includes all opening operators.
+
#include <mln/morpho/opening/algebraic.hh>
-#include <mln/morpho/opening/leveling.hh>
-#include <mln/morpho/opening/area_on_vertices.hh>
#include <mln/morpho/opening/area.hh>
-#include <mln/morpho/opening/volume.hh>
+#include <mln/morpho/opening/area_on_vertices.hh>
#include <mln/morpho/opening/height.hh>
+#include <mln/morpho/opening/leveling.hh>
+#include <mln/morpho/opening/structural.hh>
+#include <mln/morpho/opening/volume.hh>
+
#endif // ! MLN_MORPHO_OPENING_ALL_HH
Index: mln/morpho/opening/structural.hh
--- mln/morpho/opening/structural.hh (revision 3461)
+++ mln/morpho/opening/structural.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,12 +26,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_HH
-# define MLN_MORPHO_OPENING_HH
+#ifndef MLN_MORPHO_OPENING_STRUCTURAL_HH
+# define MLN_MORPHO_OPENING_STRUCTURAL_HH
-/// \file mln/morpho/opening.hh
+/// \file mln/morpho/opening/structural.hh
///
-/// Morphological opening.
+/// Morphological structural opening.
# include <mln/morpho/includes.hh>
@@ -42,37 +42,47 @@
namespace morpho
{
- /// Morphological opening.
+ namespace opening
+ {
+
+ /// Morphological structural opening.
///
/// This operator is d_{-B} o e_B.
template <typename I, typename W>
- mln_concrete(I) opening(const Image<I>& input, const Window<W>& win);
+ mln_concrete(I)
+ structural(const Image<I>& input, const Window<W>& win);
+
# ifndef MLN_INCLUDE_ONLY
+
template <typename I, typename W>
inline
- mln_concrete(I) opening(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ structural(const Image<I>& input, const Window<W>& win)
{
- trace::entering("morpho::opening");
+ trace::entering("morpho::opening::structural");
+
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
mln_concrete(I) output = dilation(erosion(input, win), win::sym(win));
- // FIXME: Is this postcondition always true, even if the
- // structuring element is not centered?
mln_postcondition(output <= input);
- trace::exiting("morpho::opening");
+
+ trace::exiting("morpho::opening::structural");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::opening
+
} // end of namespace mln::morpho
} // end of namespace mln
-#endif // ! MLN_MORPHO_OPENING_HH
+#endif // ! MLN_MORPHO_OPENING_STRUCTURAL_HH
Property changes on: mln/morpho/opening/structural.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0