Splitting Multiframe DICOM into single slice DICOM files

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Posts: 24
Joined: Mon, 2018-11-12, 20:01

Splitting Multiframe DICOM into single slice DICOM files

#1 Post by artemmikheev » Wed, 2020-08-19, 14:58

I am trying to split Multiframe DICOM into single-slice DICOM files.
Seems like all is working well in my code, but it is very slow for very large
files (3680 frames).
Bottleneck seems to be in extracting and copying Pixel data:

I use the following code:

// Getting pixel data....
DicomImage** ImgArr;

for ( int fi=0; fi<NF; fi++ )
ImgArr[fi] = new DicomImage((DcmObject*)SourceDataset,Tsyntax,0,unsigned long(fi),unsigned long(1)));


// Setting pixel data...
for ( int fi=0; fi<NF; fi++ ) {
const DiPixel *obp = ImgArr[fi]->getInterData();
int Nbypp = GetBytesPerPix( obp->getRepresentation());
PBYTE pixdata = PBYTE(obp->getData());
int pixlng = obp->getCount();
TargetDataSetArr[fi]->putAndInsertUint8Array(DCM_PixelData,pixdata,pixlng*Nbypp );

Is there a more efficient way in terms of speed (memory is less important)?
Also, "Getting data" part is NOT thread safe, while "Setting data" IS thread-safe.

Thank you for any advice.


J. Riesmeier
DCMTK Developer
Posts: 2284
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany

Re: Splitting Multiframe DICOM into single slice DICOM files

#2 Post by J. Riesmeier » Mon, 2020-08-24, 20:14

The purpose of the DicomImage class is rendering/visualization of DICOM images. If I were you, I would use a lower level API for extracting the pixel data from the DcmDataset instance, depending on whether the pixel data is compressed or uncompressed.

Post Reply

Who is online

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