URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-09-10 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix luminance value computation for RGB to HSL.
* mln/fun/v2v/rgb_to_hsl.hh: Fix luminance value computation
to fit in [0,1].
* mln/io/magick/load.hh: Minor update.
* mln/io/magick/save.hh: Minor update.
---
fun/v2v/rgb_to_hsl.hh | 4 ++--
io/magick/load.hh | 31 +++++++++++++++++++++++++++----
io/magick/save.hh | 21 +++++++++++++++++++++
3 files changed, 50 insertions(+), 6 deletions(-)
Index: trunk/milena/mln/fun/v2v/rgb_to_hsl.hh
===================================================================
--- trunk/milena/mln/fun/v2v/rgb_to_hsl.hh (revision 4456)
+++ trunk/milena/mln/fun/v2v/rgb_to_hsl.hh (revision 4457)
@@ -103,14 +103,14 @@
else
hsl.hue() = (60. * (rgb.red() - rgb.green()) / (rmax - rmin)) + 240;
- hsl.lum() = ((double) rmax + (double) rmin) / 2;
-
// We want min and max between 0 and 1
rmax -= mln_min(typename T_rgb::red_t);
rmin -= mln_min(typename T_rgb::red_t);
double nmax = (double) rmax / (mln_max(typename T_rgb::red_t) - mln_min(typename
T_rgb::red_t));
double nmin = (double) rmin / (mln_max(typename T_rgb::red_t) - mln_min(typename
T_rgb::red_t));
+ hsl.lum() = ((double) nmax + (double) nmin) / 2;
+
if (rmin == rmax)
hsl.sat() = 0;
else
Index: trunk/milena/mln/io/magick/save.hh
===================================================================
--- trunk/milena/mln/io/magick/save.hh (revision 4456)
+++ trunk/milena/mln/io/magick/save.hh (revision 4457)
@@ -58,6 +58,15 @@
void save(const Image<I>& ima,
const std::string& filename);
+ /*! Save a Milena tiled image in a magick image.
+ *
+ * \param[out] ima A reference to the image to save.
+ * \param[in] filename The output.
+ */
+ template <typename T>
+ void save(Image< tiled2d<T> >& ima,
+ const std::string& filename);
+
# ifndef MLN_INCLUDE_ONLY
@@ -117,6 +126,18 @@
trace::exiting("mln::io::magick::save");
}
+ template <typename T>
+ void save(Image< tiled2d<T> >& ima_, const std::string&
filename)
+ {
+ trace::entering("mln::io::magick::save");
+
+ tiled2d<T>& ima = exact(ima_);
+
+ ima.buffer().write(filename);
+
+ trace::exiting("mln::io::magick::save");
+ }
+
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/io/magick/load.hh
===================================================================
--- trunk/milena/mln/io/magick/load.hh (revision 4456)
+++ trunk/milena/mln/io/magick/load.hh (revision 4457)
@@ -53,8 +53,16 @@
* \param[in] filename The source.
*/
template <typename I>
- void load(Image<I>& ima,
- const std::string& filename);
+ void load(Image<I>& ima, const std::string& filename);
+
+ /*! Load a magick image in a tiled image.
+ *
+ * \param[out] ima A reference to the image which will receive
+ * data.
+ * \param[in] filename The source.
+ */
+ template <typename T>
+ void load(Image<tiled2d<T> >& ima, const std::string&
filename);
# ifndef MLN_INCLUDE_ONLY
@@ -102,8 +110,7 @@
template <typename I>
inline
- void load(Image<I>& ima_,
- const std::string& filename)
+ void load(Image<I>& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::load");
@@ -156,6 +163,22 @@
}
+ template<typename T>
+ inline
+ void load(Image<tiled2d<T> >& ima_, const std::string&
filename)
+ {
+ trace::entering("mln::io::magick::load");
+
+ tiled2d<T>& ima = exact(ima_);
+
+ tiled2d<T> result(filename);
+
+ ima = result;
+ trace::exiting("mln::io::magick::load");
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::io::magick