DCMTK에서 DICOM 데이터 세트에 사용자 정의 태그 추가
Howto: Add private data elements to a DICOM dataset
The following example shows how to add private data elements to a DICOM dataset (if not present yet):
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRV_PrivateCreator DcmTag(0x0029, 0x0010, EVR_LO)
#define PRV_PrivateElement1 DcmTag(0x0029, 0x1000, EVR_LO)
#define PRV_PrivateElement2 DcmTag(0x0029, 0x1010, EVR_US)
#define PRV_PrivateElement3 DcmTag(0x0029, 0x1020, EVR_OB)
void addPrivateElements(DcmItem &item)
{
if (!item.tagExists(PRV_PrivateCreator))
{
item.putAndInsertString(PRV_PrivateCreator, "Your Company Name");
item.putAndInsertString(PRV_PrivateElement1, "Some Text");
item.putAndInsertUint16(PRV_PrivateElement2, 12345);
item.putAndInsertUint8Array(PRV_PrivateElement3, NULL /*data*/, 0 /*length*/);
}
}
Please note that for private tags the value representation (VR) has to be specified explicitly to be complete.
It is also possible to register private tags to the data dictionary during runtime:
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRIVATE_CREATOR_NAME "Your Company Name"
#define PRIVATE_ELEMENT1_TAG 0x0029, 0x1000
#define PRIVATE_ELEMENT2_TAG 0x0029, 0x1010
#define PRIVATE_ELEMENT3_TAG 0x0029, 0x1020
void registerPrivateTags()
{
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT1_TAG, EVR_LO, "PrivateText", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT2_TAG, EVR_US, "PrivateInteger", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT3_TAG, EVR_OB, "PrivateBlob", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dcmDataDict.unlock();
}
This can be useful for reading datasets with implicit VR (otherwise the VR would be unknown) and e.g. for the textual output of the print() method.
However, this does not mean that you can omit the VR from the putAndInsertXXX()
calls. This will change with the next snapshot/release (see commit ), so the following will then be possible:
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRIVATE_CREATOR_NAME "Your Company Name"
#define PRIVATE_CREATOR_TAG 0x0029, 0x0010
#define PRIVATE_ELEMENT1_TAG 0x0029, 0x1000
#define PRIVATE_ELEMENT2_TAG 0x0029, 0x1010
#define PRIVATE_ELEMENT3_TAG 0x0029, 0x1020
#define PRV_PrivateCreator DcmTag(PRIVATE_CREATOR_TAG)
#define PRV_PrivateElement1 DcmTag(PRIVATE_ELEMENT1_TAG, PRIVATE_CREATOR_NAME)
#define PRV_PrivateElement2 DcmTag(PRIVATE_ELEMENT2_TAG, PRIVATE_CREATOR_NAME)
#define PRV_PrivateElement3 DcmTag(PRIVATE_ELEMENT3_TAG, PRIVATE_CREATOR_NAME)
void registerPrivateTags()
{
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT1_TAG, EVR_LO, "PrivateText", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT2_TAG, EVR_US, "PrivateInteger", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT3_TAG, EVR_OB, "PrivateBlob", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dcmDataDict.unlock();
}
void addPrivateElements(DcmItem &item)
{
if (!item.tagExists(PRV_PrivateCreator))
{
item.putAndInsertString(PRV_PrivateCreator, PRIVATE_CREATOR_NAME);
item.putAndInsertString(PRV_PrivateElement1, "Some Text");
item.putAndInsertUint16(PRV_PrivateElement2, 12345);
item.putAndInsertUint8Array(PRV_PrivateElement3, NULL /*data*/, 0 /*length*/);
}
}
int main()
{
DcmFileFormat fileformat;
fileformat.loadFile("test_in.dcm");
registerPrivateTags();
addPrivateElements(*fileformat.getDataset());
fileformat.saveFile("test_out.dcm", EXS_LittleEndianExplicit);
fileformat.print(COUT);
return 0;
}
전재:http://support.dcmtk.org/wiki/dcmtk/howto/addprivatedata
유북풍
개인 블로그:
http://qimo601.iteye.com
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
DCMTK에서 압축된 pixel 데이터 가져오기
If compressed DICOM images are loaded, DCMTK most of the time does the job of decompressing the image data itself, e.g. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRV_PrivateCreator DcmTag(0x0029, 0x0010, EVR_LO)
#define PRV_PrivateElement1 DcmTag(0x0029, 0x1000, EVR_LO)
#define PRV_PrivateElement2 DcmTag(0x0029, 0x1010, EVR_US)
#define PRV_PrivateElement3 DcmTag(0x0029, 0x1020, EVR_OB)
void addPrivateElements(DcmItem &item)
{
if (!item.tagExists(PRV_PrivateCreator))
{
item.putAndInsertString(PRV_PrivateCreator, "Your Company Name");
item.putAndInsertString(PRV_PrivateElement1, "Some Text");
item.putAndInsertUint16(PRV_PrivateElement2, 12345);
item.putAndInsertUint8Array(PRV_PrivateElement3, NULL /*data*/, 0 /*length*/);
}
}
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRIVATE_CREATOR_NAME "Your Company Name"
#define PRIVATE_ELEMENT1_TAG 0x0029, 0x1000
#define PRIVATE_ELEMENT2_TAG 0x0029, 0x1010
#define PRIVATE_ELEMENT3_TAG 0x0029, 0x1020
void registerPrivateTags()
{
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT1_TAG, EVR_LO, "PrivateText", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT2_TAG, EVR_US, "PrivateInteger", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT3_TAG, EVR_OB, "PrivateBlob", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dcmDataDict.unlock();
}
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRIVATE_CREATOR_NAME "Your Company Name"
#define PRIVATE_CREATOR_TAG 0x0029, 0x0010
#define PRIVATE_ELEMENT1_TAG 0x0029, 0x1000
#define PRIVATE_ELEMENT2_TAG 0x0029, 0x1010
#define PRIVATE_ELEMENT3_TAG 0x0029, 0x1020
#define PRV_PrivateCreator DcmTag(PRIVATE_CREATOR_TAG)
#define PRV_PrivateElement1 DcmTag(PRIVATE_ELEMENT1_TAG, PRIVATE_CREATOR_NAME)
#define PRV_PrivateElement2 DcmTag(PRIVATE_ELEMENT2_TAG, PRIVATE_CREATOR_NAME)
#define PRV_PrivateElement3 DcmTag(PRIVATE_ELEMENT3_TAG, PRIVATE_CREATOR_NAME)
void registerPrivateTags()
{
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT1_TAG, EVR_LO, "PrivateText", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT2_TAG, EVR_US, "PrivateInteger", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dict.addEntry(new DcmDictEntry(PRIVATE_ELEMENT3_TAG, EVR_OB, "PrivateBlob", 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dcmDataDict.unlock();
}
void addPrivateElements(DcmItem &item)
{
if (!item.tagExists(PRV_PrivateCreator))
{
item.putAndInsertString(PRV_PrivateCreator, PRIVATE_CREATOR_NAME);
item.putAndInsertString(PRV_PrivateElement1, "Some Text");
item.putAndInsertUint16(PRV_PrivateElement2, 12345);
item.putAndInsertUint8Array(PRV_PrivateElement3, NULL /*data*/, 0 /*length*/);
}
}
int main()
{
DcmFileFormat fileformat;
fileformat.loadFile("test_in.dcm");
registerPrivateTags();
addPrivateElements(*fileformat.getDataset());
fileformat.saveFile("test_out.dcm", EXS_LittleEndianExplicit);
fileformat.print(COUT);
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
DCMTK에서 압축된 pixel 데이터 가져오기If compressed DICOM images are loaded, DCMTK most of the time does the job of decompressing the image data itself, e.g. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.