Commit 18751119 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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.
parent f08ca6b0
2010-02-16 Guillaume Lazzara <z@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@lrde.epita.fr>
 
Add A new routine to draw plain boxes.
// 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
// 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_IO_DICOM_GET_HEADER_HH
# define MLN_IO_DICOM_GET_HEADER_HH
/// \file
///
/// Load a DICOM file header.
# include <iostream>
# include <fstream>
# include <mln/core/concept/image.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
{
namespace io
{
namespace dicom
{
/// Store dicom file header.
struct dicom_header
{
// The number of dimensions.
unsigned dim;
// The size in each dimension.
util::array<unsigned> size;
};
/// Retrieve header in a dicom file.
dicom_header get_header(const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
dicom_header get_header(const std::string& filename)
{
trace::entering("mln::io::dicom::get_header");
dicom_header header;
gdcm::ImageReader r;
r.SetFileName(filename.c_str());
if (!r.Read())
{
std::cerr << "error: cannot open file '" << filename << "'!";
abort();
}
gdcm::Image& image = r.GetImage();
header.dim = image.GetNumberOfDimensions();
const unsigned int* dims = image.GetDimensions();
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::dicom
} // end of namespace mln::io
} // end of namespace mln
#endif // ! MLN_IO_DICOM_GET_HEADER_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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment