URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-07-17 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update post-release after code freeze.
* mln/core/alias/neighb3d.hh: Add preprocessor command #ifndef.
* mln/io/dicom/load.hh: Remove dead code.
* mln/io/plot/save.hh: Update save() method for 1D image.
* mln/labeling/n_max.hh: Fix algorithm.
* mln/world/inter_pixel/display_edge.hh: Add documentation
and fix image dimensions.
* mln/world/inter_pixel/immerse.hh: Minor update.
---
core/alias/neighb3d.hh | 2 ++
io/dicom/load.hh | 6 +++---
io/plot/save.hh | 37 +++++++++++++++----------------------
labeling/n_max.hh | 29 ++++++++++++++++++++++-------
world/inter_pixel/display_edge.hh | 37 ++++++++++++++++++++++++++++++-------
world/inter_pixel/immerse.hh | 4 ++--
6 files changed, 74 insertions(+), 41 deletions(-)
Index: trunk/milena/mln/world/inter_pixel/immerse.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/immerse.hh (revision 4309)
+++ trunk/milena/mln/world/inter_pixel/immerse.hh (revision 4310)
@@ -70,8 +70,8 @@
const I& input = exact(input_);
mln_precondition(input.is_valid());
- mln_domain(I) b(2 * input.domain().pmin(),
- 2 * input.domain().pmax());
+ mln_domain(I) b((2 * input.domain().pmin()),
+ (2 * input.domain().pmax()));
mln_concrete(I) output(b);
mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
Index: trunk/milena/mln/world/inter_pixel/display_edge.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 4309)
+++ trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 4310)
@@ -28,12 +28,13 @@
/// \file
///
-/// FIXME: insert comment.
+/// Create an image for visualizing the values on edges of an
+/// inter_pixel image.
# include <mln/core/image/image2d.hh>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/data/fill.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
# include <mln/opt/at.hh>
namespace mln
@@ -45,17 +46,36 @@
namespace inter_pixel
{
+ /// \brief Create an image which is a copy of the input image with
+ /// a solid background color and highlighted edges. The image is
+ /// stretched according to the zoom ratio.
+ ///
+ /// \param[in] ima The input image providing edge values.
+ /// \param[in] bg The background color.
+ /// \param[in] zoom The zoom ratio.
+ /// \return A copy of the input image with highlighted edges.
+ ///
+ /// \pre \p ima has to be an unmorphed image.
+ ///
+ template <typename I>
+ inline
+ I display_edge(const I& ima, mln_value(I) bg, unsigned zoom);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
template <typename I>
inline
I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
{
box2d b = ima.bbox();
- // FIXME: Create a empty box of size 'zoom*zoom' is ima is null.
- I output(make::box2d((b.pmin()[0] / 2) * (zoom + 1), (b.pmin()[1] / 2) * (zoom + 1),
- (b.pmax()[0] / 2 + 1) * (zoom + 1) - 2, (b.pmax()[1] / 2 + 1) * (zoom + 1) -
2));
+ I output(make::box2d(((b.pmin()[0] + 1) / 2) * (zoom + 1),
+ ((b.pmin()[1] + 1) / 2) * (zoom + 1),
+ ((b.pmax()[0] + 1) / 2 + 1) * (zoom + 1) - 2,
+ ((b.pmax()[1] + 1) / 2 + 1) * (zoom + 1) - 2));
data::fill(output, bg);
- typedef image_if<const I, dim2::is_edge> edge_t;
- edge_t edge = ima | dim2::is_edge();
+ typedef image_if<const I, is_separator> edge_t;
+ edge_t edge = ima | is_separator();
mln_piter(edge_t) p(edge.domain());
for_all(p)
if (p.row() % 2) // horizontal edge
@@ -75,6 +95,9 @@
return output;
}
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
Index: trunk/milena/mln/core/alias/neighb3d.hh
===================================================================
--- trunk/milena/mln/core/alias/neighb3d.hh (revision 4309)
+++ trunk/milena/mln/core/alias/neighb3d.hh (revision 4310)
@@ -293,8 +293,10 @@
void
from_to_(const bool (&values)[S], neighb3d& nbh)
{
+# ifndef NDEBUG
const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
+# endif // ! NDEBUG
window3d win;
from_to_(values, win);
mln_precondition(win.is_neighbable_());
Index: trunk/milena/mln/io/dicom/load.hh
===================================================================
--- trunk/milena/mln/io/dicom/load.hh (revision 4309)
+++ trunk/milena/mln/io/dicom/load.hh (revision 4310)
@@ -100,8 +100,8 @@
abort();
}
- gdcm::File &file = r.GetFile();
- gdcm::DataSet& ds = file.GetDataSet();
+ //gdcm::File &file = r.GetFile();
+ //gdcm::DataSet& ds = file.GetDataSet();
gdcm::Image& image = r.GetImage();
@@ -118,7 +118,7 @@
unsigned int offset = 8 - (bits_allocated - bits_stored);
unsigned int off_pow = 1;
- for (int i = 0; i < offset; ++i)
+ for (unsigned int i = 0; i < offset; ++i)
{
off_pow *= 2;
}
Index: trunk/milena/mln/io/plot/save.hh
===================================================================
--- trunk/milena/mln/io/plot/save.hh (revision 4309)
+++ trunk/milena/mln/io/plot/save.hh (revision 4310)
@@ -45,25 +45,18 @@
namespace plot
{
- /*! Save a Milena 1D image in a plot file.
- *
- * \param[in] ima A reference to the image to save.
- * \param[out] filename The output file.
- * \param[in] start_value The start index value of the plot
- * (optional).
- */
+ /*! \brief Save a Milena 1D image in a plot file.
+ \param[in] ima A reference to the image to save.
+ \param[out] filename The output file. */
template <typename I>
- void save(image1d<I>& ima,
- const std::string& filename,
- int start_value = 0);
+ void save(const image1d<I>& ima,
+ const std::string& filename);
- /*! Save a Milena array in a plot file.
- *
- * \param[in] arr A reference to the array to save.
- * \param[out] filename The output file.
- * \param[in] start_value The start index value of the plot
- * (optional).
- */
+ /*! \brief Save a Milena array in a plot file.
+ \param[in] arr A reference to the array to save.
+ \param[out] filename The output file.
+ \param[in] start_value The start index value of the plot
+ (optional). */
template <typename I>
void save(util::array<I>& arr,
const std::string& filename,
@@ -75,21 +68,21 @@
template <typename I>
inline
- void save(image1d<I>& ima, const std::string& filename,
- int start_value = 0)
+ void save(const image1d<I>& ima, const std::string& filename)
{
trace::entering("mln::io::plot::save");
std::ofstream file_out(filename.c_str());
- for (unsigned i = 0; i < ima.ninds(); ++i)
- file_out << start_value + i << " " << ima.at_(i) <<
std::endl;
+ unsigned end = ima.bbox().pmax().ind();
+ for (unsigned i = ima.bbox().pmin().ind(); i <= end; ++i)
+ file_out << i << " " << ima.at_(i) << std::endl;
trace::exiting("mln::io::plot::save");
}
template <typename I>
inline
- void save(util::array<I>& arr, const std::string& filename,
+ void save(const util::array<I>& arr, const std::string& filename,
int start_value = 0)
{
trace::entering("mln::io::plot::save");
Index: trunk/milena/mln/labeling/n_max.hh
===================================================================
--- trunk/milena/mln/labeling/n_max.hh (revision 4309)
+++ trunk/milena/mln/labeling/n_max.hh (revision 4310)
@@ -34,9 +34,13 @@
/// \file
///
/// Construct from a count accumulator of a labeled image an array with
-/// the ordered n biggest labels
+/// the ordered n biggest labels.
///
/// \return an array starting at index 1
+///
+/// \warning The biggest value is stocked at index 0. It generally represents
+/// the background and should be ignored. However, it is still accessible
+/// if necessary.
namespace mln
@@ -63,22 +67,33 @@
{
trace::entering("mln::labeling::n_max");
- util::array<L> output(n + 1, 0);
+ mln_precondition(n < in_arr.nelements());
+ util::array<L> output(n + 1, 0);
+ for (unsigned i = 0; i < n + 1; ++i)
+ output[i] = i;
int swap = 0;
- for (unsigned i = 0; i < in_arr.nelements(); ++i)
+ for (int j = n - 1; j > 0; --j)
+ {
+ if (in_arr[output[j]] < in_arr[output[j + 1]])
+ {
+ swap = output[j];
+ output[j] = output[j + 1];
+ output[j + 1] = swap;
+ }
+ }
+
+ for (unsigned i = n; i < in_arr.nelements(); ++i)
{
if (in_arr[i] > in_arr[output[n]])
{
output[n] = i;
- }
- int j = n - 1;
- while (j > 0 && in_arr[output[j]] < in_arr[output[j + 1]])
+ for (unsigned j = n - 1; j > 0 && in_arr[output[j]] < in_arr[output[j +
1]]; --j)
{
swap = output[j];
output[j] = output[j + 1];
output[j + 1] = swap;
- --j;
+ }
}
}