I am tryig to writ a function to splitt and rewrite multiframe dicoms into a set of single frame dicom files.
I relied on the code in this "howto":
http://support.dcmtk.org/redmine/projec ... Multiframe
Code: Select all
DicomImage *image = new DicomImage(mfFileName.toAscii().data(), CIF_UsePartialAccessToPixelData, 0, 1 /* fcount */);
if (image->getStatus() == EIS_Normal)
{
int i = 0;
QString path = "c:/temp_slices/slice_";
do {
QString currentFileName = path + QString::number(i) + ".dcm";
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
image->writeImageToDataset(*dataset);
OFCondition status = fileformat.saveFile(currentFileName.toAscii().data(), EXS_LittleEndianExplicit);
if (status.bad())
printf("Error: cannot write DICOM file (%s)\n", status.text());
++i;
} while (image->processNextFrames());
}
delete image;
1. would this also work if the input file is compressed? Also regarding this, if the inut image is compressed, would it be possible to access and extract the pixel data of a frame in the middle (e.g. to generate a thumbnail of the image) without loading the whole image?
2. the generated single frame dicoms do not include and information from the input Tags (patient name, spacing, position, orientation ,...., ), practically nothing. Should these tags be explicitely set?
I would also appreciate if somebody has a better (simpler, faster, ...!) idea to do the splitting, especially if tags are automatically set .
Much thansk,
Zein