URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-20 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update DICOM loader.
* fabien/gdcm/Makefile: Update.
* fabien/gdcm/dump2pgm.cc: New tool to convert dump volume
to a pgm flat image.
* fabien/gdcm/gdcm.cc: Update.
* fabien/gdcm/load.hh: Update.
---
Makefile | 2 +-
dump2pgm.cc | 35 +++++++++++++++++++++++++++++++++++
gdcm.cc | 4 ++--
load.hh | 16 ++++++++++------
4 files changed, 48 insertions(+), 9 deletions(-)
Index: trunk/milena/sandbox/fabien/gdcm/dump2pgm.cc
===================================================================
--- trunk/milena/sandbox/fabien/gdcm/dump2pgm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/gdcm/dump2pgm.cc (revision 3402)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/int_u16.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump
output.pgm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u16;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<int_u16> vol;
+ io::dump::load(vol, argv[1]);
+
+ int_u16 bg = 0;
+ image2d<int_u16> ima = debug::slices_2d(vol, 1.f, bg);
+ io::pgm::save(ima, argv[2]);
+}
Index: trunk/milena/sandbox/fabien/gdcm/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/gdcm/Makefile (revision 3401)
+++ trunk/milena/sandbox/fabien/gdcm/Makefile (revision 3402)
@@ -8,5 +8,5 @@
-L/Users/HiSoKa/Downloads/gdcmbin/bin \
-lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12
-lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
-framework CoreFoundation \
- -DNDEBUG \
+ -DNDEBUG -O1 \
gdcm.cc -o mln_gdcm
Index: trunk/milena/sandbox/fabien/gdcm/load.hh
===================================================================
--- trunk/milena/sandbox/fabien/gdcm/load.hh (revision 3401)
+++ trunk/milena/sandbox/fabien/gdcm/load.hh (revision 3402)
@@ -143,10 +143,7 @@
<< "=================" << std::endl;
std::cout << "Buffer length: " << image.GetBufferLength() <<
std::endl;
char* dataBuffer = new char[image.GetBufferLength()];
- if (image.GetBuffer(dataBuffer))
- std::cout << "GetBuffer success" << std::endl;
- else
- std::cout << "GetBuffer failure" << std::endl;
+ image.GetBuffer(dataBuffer);
int ndims = image.GetNumberOfDimensions();
const unsigned int* dims = image.GetDimensions();
@@ -170,17 +167,24 @@
{
//image3d<int_u16> ima(dims[2], dims[1], dims[0]);
mln_site(I) pmin(0, 0, 0);
- mln_site(I) pmax(dims[2], dims[1], dims[0]);
+ mln_site(I) pmax(dims[2] - 1, dims[1] - 1, dims[0] - 1);
mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
initialize(ima, result);
- mln_piter(image3d<int_u16>) p(ima.domain());
+ mln_piter(I) p(ima.domain());
for_all(p)
{
ima(p) = dataBuffer[(p.col() + p.row() * dims[0] + p.sli() * dims[0] * dims[1]) * 2]
* 256+
dataBuffer[(p.col() + p.row() * dims[0] + p.sli() * dims[0] * dims[1]) * 2 + 1];
+ std::cout << (p.col() + p.row() * dims[0] + p.sli() * dims[0] * dims[1]) * 2
<< " ["
+ << "p.col = " << p.col() << "] ["
+ << "p.row = " << p.row() << "] ["
+ << "p.sli = " << p.sli() << "]"
+ << std::endl;
}
}
+ delete(dataBuffer);
+
trace::exiting("mln::io::dicom::load");
}
Index: trunk/milena/sandbox/fabien/gdcm/gdcm.cc
===================================================================
--- trunk/milena/sandbox/fabien/gdcm/gdcm.cc (revision 3401)
+++ trunk/milena/sandbox/fabien/gdcm/gdcm.cc (revision 3402)
@@ -13,6 +13,6 @@
image3d<int_u16> lena;
- io::dicom::load(lena, "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm");
- io::dump::save(lena, "IM_0052.dump");
+ io::dicom::load(lena, "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm");
+ io::dump::save(lena, "IM_0061.dump");
}