* mln/detection/corner/moravec.hh: New.
* mln/detection/corner/moravec_criterion.hh: New.
---
milena/ChangeLog | 7 +
milena/mln/detection/corner/moravec.hh | 147 ++++++++++++++++++++++
milena/mln/detection/corner/moravec_criterion.hh | 114 +++++++++++++++++
3 files changed, 268 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/detection/corner/moravec.hh
create mode 100644 milena/mln/detection/corner/moravec_criterion.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9306422..4468140 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-03 Jonathan Fabrizio <jonathan(a)lrde.epita.fr>
+
+ Add Moravec corner detection.
+
+ * mln/detection/corner/moravec.hh: New.
+ * mln/detection/corner/moravec_criterion.hh: New.
+
2012-10-02 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/core/internal/site_relative_iterator_base.hh: Fix a
diff --git a/milena/mln/detection/corner/moravec.hh b/milena/mln/detection/corner/moravec.hh
new file mode 100644
index 0000000..b9af479
--- /dev/null
+++ b/milena/mln/detection/corner/moravec.hh
@@ -0,0 +1,147 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_DETECTION_CORNER_MORAVEC_HH
+# define MLN_DETECTION_CORNER_MORAVEC_HH
+
+#include <mln/core/site_set/p_array.hh>
+#include <mln/extension/adjust_duplicate.hh>
+#include <mln/metal/is.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/detection/corner/moravec_criterion.hh>
+
+/// \file
+///
+/// \brief Implementation of Moravec corner detection.
+
+
+namespace mln
+{
+ namespace detection
+ {
+ namespace corner
+ {
+ /**
+ Computes Moravec corner detection on \p in_image
+
+ \param image_in_ The input image
+ \param win The window of moravec algorithm
+ \param nbh All possible positions of the window
+ \return The list of points detected as corner
+
+ \author J. Fabrizio
+ */
+ template<typename I, typename W, typename N>
+ p_array<mln_site(I)>
+ moravec(const Image<I>& in_image_, const Window<W>& win, const Neighborhood<N>& nbh);
+
+ /**
+ Computes Moravec corner detection on \p in_image
+ with a default 3x3 window and a defaut 3x3 neighborhood.
+
+ \param image_in_ The input image
+ \return The list of points detected as corner
+
+ \author J. Fabrizio
+ */
+ template<typename I>
+ p_array<mln_site(I)>
+ moravec(const Image<I>& in_image_);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+ /**
+ \iternal Computes local min to find corner in an image
+
+ \param image_in_ The result of moravec_criterion
+ \return The list of local min
+
+ \author J. Fabrizio
+ */
+ template<typename I>
+ p_array<mln_site(I)>
+ moravec_local_min(const Image<I>& in_image_)
+ {
+ trace::entering("detection::corner::moravec_local_min");
+
+ const I& in_image = exact(in_image_);
+ p_array<mln_site(I)> result;
+ mln_piter(I) p(in_image.domain());
+ for_all(p)
+ {
+ bool max = true;
+ mln_niter(neighb2d) n(c8(), p);
+ for_all(n) {
+ if (in_image(p)<=in_image(n))
+ {
+ max = false;
+ break;
+ }
+ }
+ if (max) {
+ result.append(p);
+ }
+ }
+ trace::exiting("detection::corner::moravec_local_min");
+ return result;
+ }
+
+ } // end of namespace mln::detection::corner::internal
+
+ template<typename I, typename W, typename N>
+ p_array<mln_site(I)>
+ moravec(const Image<I>& in_image_, const Window<W>& win, const Neighborhood<N>& nbh) {
+ trace::entering("detection::corner::moravec");
+ mln_ch_value(I, unsigned short) criterion_image;
+ criterion_image = moravec_criterion(in_image_, win, nbh);
+ trace::exiting("detection::corner::moravec");
+ return internal::moravec_local_min(criterion_image);
+ }
+
+ template<typename I>
+ p_array<mln_site(I)>
+ moravec(const Image<I>& in_image_) {
+ return moravec(in_image_, win_c8p(), c8());
+ }
+
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::detection::corner
+ } // end of namespace mln::detection
+
+
+} // end of namespace mln
+
+#endif // ! MLN_DETECTION_CORNER_MORAVEC_HH
diff --git a/milena/mln/detection/corner/moravec_criterion.hh b/milena/mln/detection/corner/moravec_criterion.hh
new file mode 100644
index 0000000..86c834f
--- /dev/null
+++ b/milena/mln/detection/corner/moravec_criterion.hh
@@ -0,0 +1,114 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_DETECTION_CORNER_MORAVEC_CRITERION_HH
+# define MLN_DETECTION_CORNER_MORAVEC_CRITERION_HH
+
+#include <mln/extension/adjust_duplicate.hh>
+//#include <mln/metal/is.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/window2d.hh>
+
+/// \file
+///
+/// \brief Implementation of Moravec corner detection.
+
+
+namespace mln
+{
+ namespace detection
+ {
+ namespace corner
+ {
+ /**
+ Computes the criterion necessary to Moravec corner detection.
+
+ \param in_image_ the orginal image
+
+ \param win_ The window
+
+ \param nbh_ All possible positions of the window
+
+ \return Scores computed by Moravec criterion
+
+ \author J. Fabrizio
+ */
+ template<typename I, typename W, typename N>
+ mln_ch_value(I, unsigned short)
+ moravec_criterion(const Image<I>& in_image_, const Window<W>& win_, const Neighborhood<N>& nbh_);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename I, typename W, typename N>
+ mln_ch_value(I, unsigned short)
+ moravec_criterion(const Image<I>& in_image_, const Window<W>& win_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("detection::corner::moravec_criterion");
+
+ //mlc_is(W, mln::win::rectangle2d)::check();
+ //mlc_is(nbh, win::rectangle2d)::check();
+
+ const I& in_image = exact(in_image_);
+ const W& win = exact(win_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(in_image.is_valid());
+ // ...
+
+ mln_ch_value(I, unsigned short) out_image(in_image.domain());
+
+ extension::adjust_duplicate(in_image, mln::geom::delta(win)+mln::geom::delta(nbh));
+
+ mln_piter(I) p(in_image.domain());
+ mln_qiter(W) q(win, p);
+ mln_niter(N) n(nbh, p);
+ mln_qiter(W) q2(win, n);
+ for_all(p)
+ {
+ unsigned short result=mln_max( unsigned short );
+ for_all(n)
+ {
+ unsigned short r=0;
+ for_all_2(q, q2)
+ r+=(in_image(q)-in_image(q2))*(in_image(q)-in_image(q2));
+ if (r<result) result = r;
+ }
+ out_image(p) = result;
+ }
+
+ trace::exiting("detection::corner::moravec_criterion");
+ return out_image;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::detection::corner
+ } // end of namespace mln::detetection
+
+
+} // end of namespace mln
+
+#endif // ! MLN_DETECTION_CORNER_MORAVEC_CRITERION_HH
--
1.7.2.5
* mln/fun/v2v/vec2d_f_to_rgb.hh: New.
---
milena/ChangeLog | 6 ++
milena/mln/fun/v2v/vec2d_f_to_rgb.hh | 165 ++++++++++++++++++++++++++++++++++
2 files changed, 171 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/fun/v2v/vec2d_f_to_rgb.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0a975df..6a8245b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2012-05-03 Sylvain Lobry <lobry(a)lrde.epita.fr>
+ Added algorithm to convert a vec2d_f to rgb.
+
+ * mln/fun/v2v/vec2d_f_to_rgb.hh: New.
+
+2012-05-03 Sylvain Lobry <lobry(a)lrde.epita.fr>
+
Added flo routines in all.hh.
* mln/io/all.hh: Here.
diff --git a/milena/mln/fun/v2v/vec2d_f_to_rgb.hh b/milena/mln/fun/v2v/vec2d_f_to_rgb.hh
new file mode 100644
index 0000000..99a46e8
--- /dev/null
+++ b/milena/mln/fun/v2v/vec2d_f_to_rgb.hh
@@ -0,0 +1,165 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_FUN_V2V_VEC2D_F_TO_RGB_HH
+# define MLN_FUN_V2V_VEC2D_F_TO_RGB_HH
+
+/// \file
+///
+/// \brief Convert vec2d_f values to RGB.
+
+# include <math.h>
+# include <mln/value/rgb.hh>
+# include <mln/core/alias/vec2d.hh>
+# include <mln/math/round.hh>
+
+# define setvals(r, g, b, k) {color_wheel[k][0] = r;\
+ color_wheel[k][1] = g;\
+ color_wheel[k++][2] = b;}
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert vec2d_f values to rgb.
+ ///
+ /// \ingroup modfunv2v
+ //
+ template <typename T_rgb>
+ struct f_vec2d_f_to_rgb_ : public Function_v2v< f_vec2d_f_to_rgb_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ T_rgb operator()(const mln::vec2d_f& vec) const;
+
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename T_rgb>
+ inline
+ T_rgb
+ f_vec2d_f_to_rgb_<T_rgb>::operator()(const mln::vec2d_f& vec) const
+ {
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ red_t r;
+ green_t g;
+ blue_t b;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ int RY = 15;
+ int YG = 6;
+ int GC = 4;
+ int CB = 11;
+ int BM = 13;
+ int MR = 6;
+
+ int color_wheel[55][3];
+
+ int k = 0;
+ for (int i = 0; i < RY; ++i)
+ setvals(255, 255 * i / RY, 0, k);
+ for (int i = 0; i < YG; ++i)
+ setvals(255 - 255 * i / YG, 255, 0, k);
+ for (int i = 0; i < GC; ++i)
+ setvals(0, 255, 255 * i / GC, k);
+ for (int i = 0; i < CB; ++i)
+ setvals(0, 255 - 255 * i / CB, 255, k);
+ for (int i = 0; i < BM; ++i)
+ setvals(255 * i / BM, 0, 255, k);
+ for (int i = 0; i < MR; ++i)
+ setvals(255, 0, 255 - 255 * i / MR, k);
+
+ float u = vec[0];
+ float v = vec[1];
+
+ float rad = sqrt (u * u + v * v);
+ float a = atan2 (-v, -u) / 3.14159265;
+ float fk = (a + 1.0) / 2.0 * (54);
+ int k0 = (int)fk;
+ int k1 = (k0 + 1) % 55;
+ float f = fk - k0;
+
+ //Red.
+ float col0 = color_wheel[k0][0] / 255.0;
+ float col1 = color_wheel[k1][0] / 255.0;
+ float col = (1 - f) * col0 + f * col1;
+ if (rad <= 1)
+ col = 1 - rad * (1 - col);
+ else
+ col *= 0.75;
+
+ r = to_r(255 * col);
+
+ //Green.
+ col0 = color_wheel[k0][1] / 255.0;
+ col1 = color_wheel[k1][1] / 255.0;
+ col = (1 - f) * col0 + f * col1;
+ if (rad <= 1)
+ col = 1 - rad * (1 - col);
+ else
+ col *= 0.75;
+
+ g = to_g(255 * col);
+
+ //Blue.
+ col0 = color_wheel[k0][2] / 255.0;
+ col1 = color_wheel[k1][2] / 255.0;
+ col = (1 - f) * col0 + f * col1;
+ if (rad <= 1)
+ col = 1 - rad * (1 - col);
+ else
+ col *= 0.75;
+
+ b = to_b(255 * col);
+
+ T_rgb rgb_result (r, g, b);
+
+ return (rgb_result);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_VEC2D_F_TO_RGB_HH
--
1.7.2.5
* mln/io/flo/load.hh,
* mln/io/flo/save.hh,
* mln/io/flo/all.hh: New.
---
milena/ChangeLog | 8 ++
milena/mln/io/{pgms => flo}/all.hh | 19 +++--
milena/mln/io/flo/load.hh | 129 ++++++++++++++++++++++++++++++++++++
milena/mln/io/flo/save.hh | 118 ++++++++++++++++++++++++++++++++
4 files changed, 266 insertions(+), 8 deletions(-)
copy milena/mln/io/{pgms => flo}/all.hh (78%)
create mode 100644 milena/mln/io/flo/load.hh
create mode 100644 milena/mln/io/flo/save.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 360e77e..3fde486 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-03 Sylvain Lobry <lobry(a)lrde.epita.fr>
+
+ Added .flo i/o routines.
+
+ * mln/io/flo/load.hh,
+ * mln/io/flo/save.hh,
+ * mln/io/flo/all.hh: New.
+
2011-03-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Regen generated files.
diff --git a/milena/mln/io/pgms/all.hh b/milena/mln/io/flo/all.hh
similarity index 78%
copy from milena/mln/io/pgms/all.hh
copy to milena/mln/io/flo/all.hh
index 3525744..918add7 100644
--- a/milena/mln/io/pgms/all.hh
+++ b/milena/mln/io/flo/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,11 +23,11 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_IO_PGMS_ALL_HH
-# define MLN_IO_PGMS_ALL_HH
+#ifndef MLN_IO_FLO_ALL_HH
+# define MLN_IO_FLO_ALL_HH
/// \file
-/// \brief Inclusion of all PGMS I/O routines.
+/// \brief Inclusion of all FLO I/O routines.
namespace mln
@@ -35,12 +35,15 @@ namespace mln
namespace io
{
- /// Namespace of pgms input/output handling.
- namespace pgms {}
+ /// Namespace of pbm input/output handling.
+ namespace flo
+ {
+ }
}
}
-# include <mln/io/pgms/load.hh>
+# include <mln/io/flo/load.hh>
+# include <mln/io/flo/save.hh>
-#endif // ! MLN_IO_PGMS_ALL_HH
+#endif // ! MLN_IO_FLO_ALL_HH
diff --git a/milena/mln/io/flo/load.hh b/milena/mln/io/flo/load.hh
new file mode 100644
index 0000000..d29f6f6
--- /dev/null
+++ b/milena/mln/io/flo/load.hh
@@ -0,0 +1,129 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_IO_FLO_LOAD_HH
+# define MLN_IO_FLO_LOAD_HH
+
+/// \file
+///
+/// Define a function which loads an image of kind .flo with given path.
+/// Information about .flo can be found there :
+/// http://vision.middlebury.edu/flow/data/
+
+# include <stdio.h>
+# include <stdlib.h>
+# include <string>
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/vec2d.hh>
+# include <mln/make/box2d.hh>
+
+# define TAG_FLOAT 202021.25
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace flo
+ {
+
+ /// Load a .flo vector field in a Milena structure.
+ ///
+ /// \param[out] optical_flow A refernce to the image which will receive
+ /// the data.
+ /// \param[in] filename The source.
+ ///
+ void
+ load (mln::image2d <mln::vec2d_f>& optical_flow,
+ const std::string &filename);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ void
+ load (mln::image2d <mln::vec2d_f>& optical_flow,
+ const std::string &filename)
+ {
+ trace::entering("mln::io::flo::load");
+
+ FILE *stream = fopen (filename.c_str (), "rb");
+ if (stream == NULL)
+ {
+ std::cerr << "error: file '" << filename
+ << "' not found!";
+ abort();
+ }
+
+ int width, height;
+ float tag;
+
+ if ((fread (&tag, sizeof(float), 1, stream) != 1)
+ || (fread (&width, sizeof(int), 1, stream) != 1)
+ || (fread (&height, sizeof(int), 1, stream) != 1))
+ {
+ std::cerr << "error while reading header of " << filename;
+ abort();
+ }
+
+ if (tag != TAG_FLOAT)
+ {
+ std::cerr << "error: Wrong magic-number in " << filename;
+ abort();
+ }
+
+ optical_flow.init_ (mln::make::box2d (height, width));
+
+ mln::point2d p;
+ for (p.row () = 0; p.row () < height; ++p.row ())
+ for (p.col () = 0; p.col () < width; ++p.col ())
+ {
+ float u, v;
+ if ((fread (&u, sizeof(float), 1, stream) != 1)
+ || (fread (&v, sizeof(float), 1, stream) != 1))
+ {
+ std::cerr << "error while reading the " << p << "th point.";
+ abort ();
+ }
+ optical_flow (p)[0] = u;
+ optical_flow (p)[1] = v;
+ }
+
+ fclose (stream);
+
+ trace::exiting("mln::io::flo::load");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::flo
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+#endif // ! MLN_IO_FLO_LOAD_HH
diff --git a/milena/mln/io/flo/save.hh b/milena/mln/io/flo/save.hh
new file mode 100644
index 0000000..651313a
--- /dev/null
+++ b/milena/mln/io/flo/save.hh
@@ -0,0 +1,118 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_IO_FLO_SAVE_HH
+# define MLN_IO_FLO_SAVE_HH
+
+/// \file
+///
+/// Define a function which saves an image of kind flo with given path.
+/// Information about .flo can be found there :
+/// http://vision.middlebury.edu/flow/data/
+
+# define TAG_STRING "PIEH"
+
+# include <stdio.h>
+# include <stdlib.h>
+# include <string>
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/vec2d.hh>
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace flo
+ {
+
+ /// Save vector field in a .flo file.
+ ///
+ /// \param[in] optical_flow A refernce to the image which contains the
+ /// vector field
+ /// \param[in] filename The destination.
+ ///
+ void
+ save (const mln::image2d <mln::vec2d_f>& optical_flow,
+ const std::string& filename);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ void
+ save (const mln::image2d <mln::vec2d_f>& optical_flow,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::flo::save");
+
+ int width = optical_flow.ncols ();
+ int height = optical_flow.nrows ();
+
+ FILE *stream = fopen (filename.c_str (), "wb");
+ if (!stream)
+ {
+ std::cerr << "error: can not write into '" << filename << "'.";
+ abort ();
+ }
+
+ fprintf (stream, TAG_STRING);
+ if ((fwrite (&width, sizeof(int), 1, stream) != 1)
+ || (fwrite (&height, sizeof(int), 1, stream) != 1))
+ {
+ std::cerr << "error: could not write header.";
+ abort ();
+ }
+
+ mln::point2d p;
+ for (p.row () = 0; p.row () < height; ++p.row ())
+ for (p.col () = 0; p.col () < width; ++p.col ())
+ {
+ float u = optical_flow (p)[0];
+ float v = optical_flow (p)[1];
+
+ if ((fwrite (&u, sizeof(float), 1, stream) != 1)
+ || (fwrite (&v, sizeof(float), 1, stream) != 1))
+ {
+ std::cerr << "error while writing the " << p << "th point.";
+ abort ();
+ }
+ }
+
+ fclose (stream);
+
+ trace::exiting("mln::io::flo::save");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::flo
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+#endif // ! MLN_IO_FLO_SAVE_HH
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch Sylvain has been updated
via 161d9e36b73cf9a42837c60fda6e8005ec2c1b43 (commit)
via 5746d8155885f82b642abf5bb6177a74418eee27 (commit)
via 49c6f9588ccf15170f554f73e7183e4445a7617f (commit)
via 87842982c86e75a5b89c8e0bc13887b09c8f344b (commit)
from a794c88fd084cd17f09ce4228c6b80f138f42f47 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
161d9e3 Updated all.hh. * mln/fun/v2v/all.hh: Here.
5746d81 Added algorithm to convert a vec2d_f to rgb.
49c6f95 Added flo routines in all.hh.
8784298 Added .flo i/o routines.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 26 ++++++
milena/mln/fun/v2v/all.hh | 1 +
milena/mln/fun/v2v/vec2d_f_to_rgb.hh | 165 ++++++++++++++++++++++++++++++++++
milena/mln/io/all.hh | 1 +
milena/mln/io/{pgms => flo}/all.hh | 19 +++--
milena/mln/io/flo/load.hh | 129 ++++++++++++++++++++++++++
milena/mln/io/flo/save.hh | 118 ++++++++++++++++++++++++
7 files changed, 451 insertions(+), 8 deletions(-)
create mode 100644 milena/mln/fun/v2v/vec2d_f_to_rgb.hh
copy milena/mln/io/{pgms => flo}/all.hh (78%)
create mode 100644 milena/mln/io/flo/load.hh
create mode 100644 milena/mln/io/flo/save.hh
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch fix/iterator-preconditions-t256 has been created
at 6ecbb609746a9cb32c95a017afc4f2dc1a8bbf22 (commit)
- Log -----------------------------------------------------------------
6ecbb60 mln/core/internal/site_relative_iterator_base.hh: Fix a precondition (ticket #256).
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform