Howto: Access multi-frame images without loading complete pixel data¶
Here's an example that shows how to access the individual frames of a large multi-frame image (for visualization purposes) without loading the complete pixel data into main memory.
The parameter fcount
in the DicomImage constructor specifies that initially only the first 10 frames are processed. Multiple calls of processNextFrames()
give access to the subsequent frames.
See API documentation for details.
Source Code¶
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmimgle/dcmimage.h"
int main(int argc, char *argv[])
{
OFLog::configure(OFLogger::INFO_LOG_LEVEL);
DicomImage *image = new DicomImage("mf_image.dcm", CIF_UsePartialAccessToPixelData, 0, 10 /* fcount */);
if (image->getStatus() == EIS_Normal)
{
do {
DCMIMGLE_INFO("processing frame " << image->getFirstFrame() + 1 << " to "
<< image->getFirstFrame() + image->getFrameCount());
} while (image->processNextFrames());
}
delete image;
return 0;
}
Note¶
This example requires DCMTK 3.5.5 (20091222) or newer.