Hi Remco,

I am not familiar with the details of dcmtk, so I can only guess. If the
DcmDataset contains an array with the data vector of the image, then
it is possible to use this directly with an mitk::Image.

First, you have to initialize the mitk::Image with some header information
about the pixel type and the dimensions of the image using one of the
mitk::Image::Initialize methods. This should be somehow available from
the dcmtk object.

Secondly, you have to put the actual data vector into the image. There
are several methods in mitk::Image for doing this. In case you have a
3D image which is stored slice-by-slice (i.e., you need to combine
several DcmDataset objects, each containing one slice of an image,
into an image volume), you can use SetSlice or SetImportSlice.
If DcmDataset contains the complete image, use SetChannel or
SetImportChannel, or (alternatively, if the dimension is <=3)
SetVolume or SetImportVolume.

The SetImportXXX variants have one additional parameter compared
to the the SetXXX methods:
  ImportMemoryManagementType importMemoryManagement =
    CopyMemory,
see for example
http://www.mitk.org/documentation/doxygen/classmitk_1_1Image.html#a14

The default value CopyMemory means that the memory is copied (surprise ;-)).
The mitk::Image will manage the copied memory, and will not touch the
original data vector.
In case you can somehow tell the DcmDataset not to care about the
memory it has allocated for its data vector, you can use ManageMemory.
In this case, the mitk::Image will take over the control of the memory and
delete it when it is destroyed (using the c++ operator delete, so this only
works in case the memory is allocated using new and NOT in case it was
allocated by malloc!). The third possibility is ReferenceMemory or,
equivalently, DontManageMemory. This the mitk::Image will just reference
the data vector. Then it is your responsibility that the data vector 
exists at
least as long as the mitk::Image exists and that it is freed at some 
time (if
you do not want to have a memory leak).

If you want to implement all this as a file-based mitk reader take a look
at the page on the DataTreeNodeFactory:
http://www.mitk.org/documentation/doxygen/group__IO.html#DataTreeNodeFactory
(just this section, NOT the XML stuff). I am not sure whether this is
applicable for your case. Do you plan to run dcmtk as a DICOM server
or do you want to use it to read files from a disk?

Best regards,

Ivo

Remco Harmsen wrote:
> Hi all,
>
> I want to interface between dcmtk (see http://dicom.offis.de) and mitk.
> More specifically: I would like to read a list of DICOM images stored in
> memory as a dcmtk objects (whose type is DcmDataset) and display them
> using mitk. My question is: how can I do this? Do I need to store the
> images to file and then read them again using mitk? Or is it maybe also
> possible to read the images directly from memory?
>
> Thanks in advance,
>
> Remco Harmsen
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> mitk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mitk-users
>   

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to