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;
}
 
dcmtk/howto/addsequenceitem.txt · Last modified: 2010/06/07 15:10 by riesmeier
 
Except where otherwise noted, content on this wiki is licensed under the following license:Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Run by Debian Driven by DokuWiki