Fast Dicom load
Moderator: Moderator Team
Fast Dicom load
Hi,
DcmFileFormat::loadFile() seems to be a common way in loading Dicom files from disk. I wonder where might be the bound of speed for this method: reading or parsing or? Would stdio::fread() + DcmInputBufferStream::setBuffer() + DcmFileFormat::read(DcmInputBufferStream &) be faster? Suppose in some cases we have prior knowledge that the parsing is most likely to be successful, would there be a faster way?
Thanks!
DcmFileFormat::loadFile() seems to be a common way in loading Dicom files from disk. I wonder where might be the bound of speed for this method: reading or parsing or? Would stdio::fread() + DcmInputBufferStream::setBuffer() + DcmFileFormat::read(DcmInputBufferStream &) be faster? Suppose in some cases we have prior knowledge that the parsing is most likely to be successful, would there be a faster way?
Thanks!
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Fast Dicom load
Without knowing any details on the background of your question, I think there is no (real) answer to it.
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Fast Dicom load
Hi, sorry for the vagueness earlier..
I have a series of single-framed Dicom files to load and display. What I usually did was loading them in a loop:
DcmFileFormat ** fileFormats = new DcmFileFormat * [N];
for(int n = 0; n < N; n++) {
fileFormats[n] = new DcmFileFormat;
fileFormats[n]->loadFile(filePath);
}
In most cases, I knew in advance that the files exist and are in correct format, so the loading was always going to be successful. Then I have 2 questions:
1) If I do not create any "DicomImage" object in the loop, the files are not going to be read into the RAM, but only read in later at the time when I am about to show the image, which is rather slow if I scroll across the series.
2) If I do create the "DicomImage" objects in the loop, like preparing them in advance, they are all read into the RAM within the loop and the scrolling becomes fluent, but this loading loop becomes rather slow.
So, I wonder how to get an optimal trade-off? Is there a faster way to force loading? Apart from disk limitations.
I have a series of single-framed Dicom files to load and display. What I usually did was loading them in a loop:
DcmFileFormat ** fileFormats = new DcmFileFormat * [N];
for(int n = 0; n < N; n++) {
fileFormats[n] = new DcmFileFormat;
fileFormats[n]->loadFile(filePath);
}
In most cases, I knew in advance that the files exist and are in correct format, so the loading was always going to be successful. Then I have 2 questions:
1) If I do not create any "DicomImage" object in the loop, the files are not going to be read into the RAM, but only read in later at the time when I am about to show the image, which is rather slow if I scroll across the series.
2) If I do create the "DicomImage" objects in the loop, like preparing them in advance, they are all read into the RAM within the loop and the scrolling becomes fluent, but this loading loop becomes rather slow.
So, I wonder how to get an optimal trade-off? Is there a faster way to force loading? Apart from disk limitations.
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Fast Dicom load
How about putting the load loop in a different thread and only wait for an image to finnish loading when it is finally needed?
Re: Fast Dicom load
yes, the loop is always put in a separate thread. If I understand right, waiting for only one image load when it is finally needed is like scenario (1), which becomes slow when I start to scroll among images. Probably the ideal would be "load when it is idle" instead of "load when it is finally needed", or may it be too "ideal"
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Fast Dicom load
In order to make sure that the file actually is in DICOM format and contains a particular Storage SOP Class, you could also load the file meta information header first: see this Howto.In most cases, I knew in advance that the files exist and are in correct format, so the loading was always going to be successful.
Of course, the DICOM dataset is read from file when calling DcmFileFormat::loadFile(). Only large element values (by default, > 4 Kbytes) like e.g. Pixel Data are only loaded on demand, i.e. when they are accessed.If I do not create any "DicomImage" object in the loop, the files are not going to be read into the RAM, [...]
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest