Newbie questions on DcmFileFormat and DcmInputStream

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
DrManette
Posts: 1
Joined: Fri, 2019-10-18, 09:56

Newbie questions on DcmFileFormat and DcmInputStream

#1 Post by DrManette » Sun, 2019-10-20, 22:17

Hi,

I've just started to use DCMTK and have a few questions regarding the first step: reading a file.

1. Is there a way to read a file really lazy? It seems DcmFileFormat::read and DcmFileFormat::loadFile reads more than just the header.

2. When you copy a DcmFileFormat object, is it a shallow copy? Is it only stream state information that is copied or should I be careful and pass them around as references?

3. Is there anyway to use a std::istream instead of DcmInputStream? Or is it possible to implement the DcmInputStream interface or perhaps use the DcmProducer interface?

Thank you
Daniel

Michael Onken
DCMTK Developer
Posts: 1813
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Newbie questions on DcmFileFormat and DcmInputStream

#2 Post by Michael Onken » Wed, 2019-10-23, 12:55

Hi Daniel,
1. Is there a way to read a file really lazy? It seems DcmFileFormat::read and DcmFileFormat::loadFile reads more than just the header.
DCMTK automatically does lazy loading in terms of not loading all data (element values) into memory. The decision whether to load an element's value into memory is based on a threshold. This is the maxReadLength parameter in DcmFileformat::loadFile() which defaults to 4 kiloybte. Once an element's value is accessed on later occassion, it's automatically loaded into memory. It's also possible to explicitly unload it again, calling compact() on that element (or compacElements() on the whole dataset/item).

If you want more control over huge values (ie. you dont want them to be loaded complety into memory on access), you can use DcmElement's getPartialValue() on each DICOM element, e.g. Pixel Data.
2. When you copy a DcmFileFormat object, is it a shallow copy? Is it only stream state information that is copied or should I be careful and pass them around as references?
The assignment operator performs a deep copy.
3. Is there anyway to use a std::istream instead of DcmInputStream? Or is it possible to implement the DcmInputStream interface or perhaps use the DcmProducer interface?
I don't think it's possible, but maybe one of my DCMTK colleagues knows better.

Best regards,
Michael

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Newbie questions on DcmFileFormat and DcmInputStream

#3 Post by Jan Schlamelcher » Wed, 2019-10-23, 13:44

Nothing is impossible. You are on the right track: just derive your own class from DcmInputStream and map tell() etc. to std::istream::tellg() etc. I have some corrupted memory of having done that before myself for some reason, but I don't think anything is readily available for the general public. So, just go for it!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], jiangyu and 1 guest