Extracting frame Image from Multiframe DICOM is not thread safe?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
artemmikheev
Posts: 32
Joined: Mon, 2018-11-12, 20:01

Extracting frame Image from Multiframe DICOM is not thread safe?

#1 Post by artemmikheev »

I have this simple code to extract individual frame images from Multiframe DICOM file


DcmDataset* DS;
DicomImage** ImgArr;
......
.........

for ( int fi=0; fi<NumFrames; fi++ ) {
ImgArr[fi] = new DicomImage((DcmObject*)DS,Tsynx,0,unsigned long(fi),unsigned long(1)));
}

So in Serial mode it works fine.

But if I try to execute the loop in parallel (f.e. parallel_for construct in VC++ ) this immediately fails
with the "read access violation" deep down the call stack.

Is this is supposed to be like this? Is there a workaround?
Problem is that I need to accelerate the operation because the file contains 4000 frames

Thank you so much
-Artem

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1435
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: Extracting frame Image from Multiframe DICOM is not thread safe?

#2 Post by Marco Eichelberg »

I don't think that this operation supports parallel calls, because they would all modify the status of the underlying DICOM dataset.

You might try to create clones of the DcmFileFormat/DcmDataset instance using the clone() method right after loading the file (at which point in time larger attributes have not been loaded yet, so that cloning the object does not hurt too much memory-wise). Then you could try creating the DicomImage instances in parallel. Perhaps that might work, but nobody will be able to guarantee that.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Baidu [Spider] and 1 guest