DCMTK在一个序列图像中插入一项

 

Howto: Add an item to a sequence

The following example shows, how to add a new item and the required UIDs to the Referenced Image Sequence.

This also works if there was previously no Referenced Image Sequence in the image file test.dcm.

#include "dcmtk/config/osconfig.h" 
#include "dcmtk/dcmdata/dctk.h"
 
int main(int argc, char *argv[]) 
{
    DcmFileFormat fileformat;
    if (fileformat.loadFile("test.dcm").good())
    {
        DcmItem *item = NULL;
        DcmDataset *dataset = fileformat.getDataset();
        if (dataset->findOrCreateSequenceItem(DCM_ReferencedImageSequence, item, -2 /* append */).good())
        {
            item->putAndInsertString(DCM_ReferencedSOPClassUID, UID_SecondaryCaptureImageStorage);
            item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "1.2.276.0.7230010.3.1.4.1787205428.14833.1256718852.966062");
            fileformat.saveFile("test_out.dcm");
        }
    }
    return 0;
}
 
转载:http://support.dcmtk.org/wiki/dcmtk/howto/addsequenceitem

你可能感兴趣的:(DCMTK,DICOM,插入项)