DCMTK从DICOM数据集中删除私有数据
?
Howto: Remove private data from a DICOM dataset#include "dcmtk/config/osconfig.h"#include "dcmtk/dcmdata/dctk.h" void removeAllPrivateTags(DcmItem& dset){ DcmStack stack; DcmObject *dobj = NULL; DcmTagKey tag; OFCondition status = dset.nextObject(stack, OFTrue); while (status.good()) { dobj = stack.top(); tag = dobj->getTag(); if (tag.getGroup() & 1) // private tag ? { stack.pop(); delete ((DcmItem *)(stack.top()))->remove(dobj); } status = dset.nextObject(stack, OFTrue); }}?
See documentation of DcmFileFormat and example in?dcmdata documentation?how to get a DcmDataset (which is also an DcmItem object) from an existing?DICOM?file.
Note1:?In the current DCMTK release, there is also an?isPrivate()?method which can be used with the above sample code.
Note2:DCMStack类:
this class manages a stack of pointers to DcmObject instances.
The objects pointed to are never touched, e.g. deleted.