-->

Reading Dicom files in Dlang [closed]

2019-07-18 16:59发布

问题:

Is it possible to read Dicom images (which are widely used in medical field) using D language?

Dicom specifications are given here.

There is some discussion on this topic on this page but no details on this forum.

I do not think there are any specific d library for this purpose but there are many C libraries available, e.g. :

https://dicom.offis.de/dcmtk.php.en

and

https://github.com/dgobbi/vtk-dicom

There is some discussion here on using C for reading Dicom files on this forum.

Can one of these libraries be used to read Dicom images in D language?

PS: Sample Dicom images are available here.

回答1:

Imebra (C++ DICOM library) provides a SWIG idl that is used to generate Java & Python wrappers for the C++ library.

Some tweaks to the SWIG idl should allow also the generation of wrappers for D.

Disclaimer: I'm the author of Imebra

Edit: detailed instructions

  • download the Imebra Source Distribution
  • cd into the distribution root folder
  • mkdir build
  • cd build
  • cmake ..
  • make
  • libimebra.so will be in the build folder
  • cd ../wrappers
  • mkdir dlang
  • swig -d -d2 -c++ -I../library/include/ -outdir dlang -o dlang/dlang_wrapper.cxx swig.i
  • The option -d2 tells to create a wrapper for D2 (phobos), otherwise the wrappers will be for D1 (Tango)
  • g++ -shared -o ../build/libimebra_wrap.so -fPIC -I../library/include dlang/dlang_wrapper.cxx
  • now the build folder will contain libimebra.so (the standard Imebra library) and libimebra_wrap.so (the wrapper for D).
  • include both imebra.d and imebra_im.d in your D project (imebra_im.d is used by imebra.d)


标签: d dicom