* mln/io/dicom/all.hh: Include a new file.
* mln/io/dicom/get_header.hh: New.
* mln/io/dicom/load.hh: Add more doc.
---
milena/ChangeLog | 10 +++
milena/mln/io/dicom/all.hh | 4 +-
.../mln/io/{cloud/save.hh => dicom/get_header.hh} | 83 ++++++++++----------
milena/mln/io/dicom/load.hh | 17 +++-
4 files changed, 66 insertions(+), 48 deletions(-)
copy milena/mln/io/{cloud/save.hh => dicom/get_header.hh} (54%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b0cc268..05234c0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2010-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a routine to read DICOM files header.
+
+ * mln/io/dicom/all.hh: Include a new file.
+
+ * mln/io/dicom/get_header.hh: New.
+
+ * mln/io/dicom/load.hh: Add more doc.
+
+2010-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add A new routine to draw plain boxes.
* mln/draw/all.hh: Include new file.
diff --git a/milena/mln/io/dicom/all.hh b/milena/mln/io/dicom/all.hh
index c6d9256..1aa3d8c 100644
--- a/milena/mln/io/dicom/all.hh
+++ b/milena/mln/io/dicom/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -41,6 +42,7 @@ namespace mln
}
+# include <mln/io/dicom/get_header.hh>
# include <mln/io/dicom/load.hh>
#endif // ! MLN_IO_DICOM_ALL_HH
diff --git a/milena/mln/io/cloud/save.hh b/milena/mln/io/dicom/get_header.hh
similarity index 54%
copy from milena/mln/io/cloud/save.hh
copy to milena/mln/io/dicom/get_header.hh
index 7d0ef7b..6d85850 100644
--- a/milena/mln/io/cloud/save.hh
+++ b/milena/mln/io/dicom/get_header.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,18 +23,21 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_IO_CLOUD_SAVE_HH
-# define MLN_IO_CLOUD_SAVE_HH
+#ifndef MLN_IO_DICOM_GET_HEADER_HH
+# define MLN_IO_DICOM_GET_HEADER_HH
/// \file
///
-/// Save an image as a cloud of points.
+/// Load a DICOM file header.
# include <iostream>
# include <fstream>
# include <mln/core/concept/image.hh>
-# include <mln/core/site_set/p_array.hh>
+# include <mln/core/routine/initialize.hh>
+# include <mln/core/box_runstart_piter.hh>
+# include <mln/core/pixel.hh>
+# include <mln/data/memcpy_.hh>
namespace mln
{
@@ -42,67 +45,63 @@ namespace mln
namespace io
{
- namespace cloud
+ namespace dicom
{
- /// Load a cloud of points
- ///
- /// \param[in] arr the cloud of points to save.
- /// \param[in] filename the destination.
- template <typename P>
- void save(const p_array<P>& arr, const std::string& filename);
-
+ /// Store dicom file header.
+ struct dicom_header
+ {
+ // The number of dimensions.
+ unsigned dim;
-# ifndef MLN_INCLUDE_ONLY
+ // The size in each dimension.
+ util::array<unsigned> size;
+ };
- namespace internal
- {
- template <typename P>
- inline
- void save_data(const p_array<P>& arr, std::ofstream& file)
- {
- mln_piter(p_array<P>) p(arr);
- for_all(p)
- {
- std::ostringstream sline;
- algebra::vec<P::dim,float> v = p.to_site().to_vec();
- sline << v[0];
- for (unsigned i = 1; i < P::dim; ++i)
- sline << ' ' << v[i];
- sline << std::endl;
- file << sline.str();
- }
- }
+ /// Retrieve header in a dicom file.
+ dicom_header get_header(const std::string& filename);
- } // end of namespace mln::io::cloud::internal
+# ifndef MLN_INCLUDE_ONLY
- template <typename P>
- void save(const p_array<P>& arr, const std::string& filename)
+ dicom_header get_header(const std::string& filename)
{
- trace::entering("mln::io::cloud::save");
+ trace::entering("mln::io::dicom::get_header");
+
+ dicom_header header;
- std::ofstream file(filename.c_str());
- if (! file)
+ gdcm::ImageReader r;
+ r.SetFileName(filename.c_str());
+ if (!r.Read())
{
std::cerr << "error: cannot open file '" << filename
<< "'!";
abort();
}
- internal::save_data(arr, file);
+ gdcm::Image& image = r.GetImage();
+
+ header.dim = image.GetNumberOfDimensions();
+ const unsigned int* dims = image.GetDimensions();
- trace::exiting("mln::io::cloud::save");
+ for (unsigned i = 2; i < header.dim; ++i)
+ header.size.append(dims[i]); // sli, ...
+ for (unsigned i = 0; i < 2; ++i)
+ header.size.append(dims[i]); // row, col
+
+ trace::exiting("mln::io::dicom::get_header");
+ return header;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::io::cloud
+ } // end of namespace mln::io::dicom
} // end of namespace mln::io
} // end of namespace mln
-#endif // ! MLN_IO_CLOUD_SAVE_HH
+#endif // ! MLN_IO_DICOM_GET_HEADER_HH
+
diff --git a/milena/mln/io/dicom/load.hh b/milena/mln/io/dicom/load.hh
index 360c87f..f250a16 100644
--- a/milena/mln/io/dicom/load.hh
+++ b/milena/mln/io/dicom/load.hh
@@ -50,11 +50,18 @@ namespace mln
namespace dicom
{
- /// Load a DICOM file in a Milena image.
- ///
- /// \param[out] ima A reference to the image which will receive
- /// data.
- /// \param[in] filename The source.
+ /*! Load a DICOM file in a Milena image.
+
+ \param[out] ima A reference to the image which will receive
+ data.
+ \param[in] filename The source.
+
+
+ Common compilation flags to link to gdcm if this file is used:
+
+ -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12
-lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib
+
+ */
template <typename I>
void load(Image<I>& ima,
const std::string& filename);
--
1.5.6.5