dcmtk程序包簡介

***該文簡單列出了dcmtk程序包的簡介,包括主要接口類的簡單說明,可用工具以及一些例子。下一步工作準備詳細分析每個程序包中的接口類功能,並結合源碼和dicom文檔分析其實現過程。

Dcmtk程序包簡介

一、Config程序包

-config目錄下的文檔:

--config.txt:

指出你編輯的任何.h .c .cc文件首先必須包含該目錄下的頭文件#include "osconfig.h"

 

--dirstruc.txt:

給出了dcmtk項目的項目目錄結構,這個用cmake會自動生成

 

--envvars.txt:

這個文件比較重要,它指出了一些運行時環境變量,這些變量可能會影響dcmtk的工具和庫的使用,這些變量包括:

---DCMDICTPATH:影響dcmdata

    On Win32 platforms, a built-in dictionary is used by default. If

    the DCMDICTPATH environment variable is set, the applications will

    attempt to load _additional_ DICOM data dictionaries specified in

    the DCMDICTPATH environment variable instead. The DCMDICTPATH

    environment variable has the same format as the shell PATH variable

    in that a semicolon (";") separates entries. The data dictionary

    code will attempt to load each file specified in the DCMDICTPATH

    environment variable.

 

    See also: documentation in dcmdata/docs/datadict.txt

---TCP_BUFFER_LENGTH:影響dcmnet

    By default, DCMTK uses a TCP send and receive buffer

    length of 32K. If the environment variable TCP_BUFFER_LENGTH is set,

    it specified an override for the TCP buffer length. The value is

    specified in bytes, not in Kbytes.

---TCP_NODELAY:影響dcmnet

    If this environment variable contains a non-zero number,

    the Nagle algorithm will not be disabled for TCP transport

    connections. Also see documentation for macro

    DONT_DISABLE_NAGLE_ALGORITHM in config/docs/macros.txt

---TMPDIR:影響dcmnet

    Affects the implementation of the tempnam() emulation on

    platforms where tempnam() is not defined. See tempnam(3S) main page

    for a description.

--macros.txt:

這個文件也特別重要,它給出了很多編譯時的宏,這些宏可能會影響dcmtk的工具和庫的使用。大部分的宏可以用來激活一些實驗性的或很少需要的特性,另外有一些是用來取消某些功能。要儘量謹慎使用。詳細見文檔。

--modules.txt:

這個文件講述如何自己配置各個模塊,不需要掌握。

-config的include目錄下的文件

--osconfig.h:這個文件是必須包含在所有.h .c文件中的

其中指出在win32環境下包含"dcmtk/config/cfwin32.h"文件

--cfwin32.h:包含了大量的宏定義。***如果需要查找某個宏的定義,可到這個文件中查找***

二、ofstd程序包

-ofstd:作爲一般目的的類庫。

這個模塊包含了一般目的的類庫,這些類所描述的對象概念並非在Dicom標準中特有。它們廣泛的在toolkit中使用。主要包含下面的類

--OFCommandLine:處理命令行參數,頭文件在ofcmdln.h。***詳情需要結合具體的代碼來理解***

--OFCondition:描述條件碼的一般類。頭文件在ofcond.h。***詳情需要結合具體的代碼來理解***


--OFConsole:是一個singleton(孤立)類***不明白***。提供線程安全的對標準輸出流和錯誤流的訪問。允許以多線程的方式同時創建輸出。***多線程的東西不太明白,它的作用應該是在多線程中實現指定線程的輸出流進行輸出操作***

--OFList:是一個雙向鏈表模板類,接口是STL list類中的一個子集。頭文件在oflist.h。***不明白爲什麼不直接用標準庫中的list,兼容性應該更好啊***

--OFStack:是一個堆棧模板類,接口是STL stack類中的一個子集。頭文件在ofstack.h。***不明白爲什麼不直接用標準庫中的stack,兼容性應該更好啊***

--OFStandard:包含大量幫助函數組成的類,用來包含大量“全局”幫助函數。注意全部都是靜態函數。其中的一些函數實現調用了windows API函數,如fileexists()。頭文件在ofstd.h。***如果需要一些全局函數,可以到這裏了找一找。***


--OFString:一個簡單的string類,實現了std::string的一個子集,沒有iterator或trait,在速度上也沒有優化。頭文件在ofstring.h。***不明白爲什麼不直接用標準庫中的string,兼容性應該更好啊***

 

--除了上述的主要類以外,還包含了大量輔助類,用來支撐上述類的功能。***詳情需要結合具體的代碼來理解***

三、dcmdata程序包

-dcmdata:一個數據編碼/解碼庫和可用的工具

這個模塊包含了一些類來管理Dicom數據結構和文件。同時它也提供了對DICOMDIR文件的支持以滿足Dicom storage media(存儲介質)的需要。

----------------------------------------------------

主要的接口類有:

 

--DcmFileFormat:a class handling the DICOM file format (with meta header) 。頭文件在dcfilefo.h。***詳情在單獨的文檔中分析***

 

--DcmDataset:a class handling the DICOM dataset format (files without meta header) 。頭文件在dcdatset.h。***詳情在單獨的文檔中分析***

 

--DcmItem:a class representing a collection of DICOM elements。頭文件在dcitem.h。***詳情在單獨的文檔中分析***

 

--DcmElement:abstract base class for all DICOM elements。頭文件在dcelem.h。***詳情在單獨的文檔中分析***。它的派生類包括:DcmAttributeTag/DcmByteString/DcmFloatingPointDouble/DcmFloatingPointSingle/DcmOtherByteOtherWord/DcmSequenceOfItems/DcmSignedLong/DcmSignedShort/DcmUnsignedLong/DcmUnsignedShort

----------------------------------------------------

----------------------------------------------------

工具:這個模塊包含了下面的命令行工具:

dcm2xml: Convert DICOM file and data set to XML

dcmconv: Convert DICOM file encoding

dcmcrle: Encode DICOM file to RLE transfer syntax

dcmdrle: Decode RLE-compressed DICOM file

dcmdump: Dump DICOM file and data set

dcmftest: Test if file uses DICOM part 10 format

dcmgpdir: Create a general purpose DICOMDIR

dcmodify: Modify DICOM files

dump2dcm: Convert ASCII dump to DICOM file

xml2dcm: Convert XML document to DICOM file or data set

***暫時不對命令行工具進行詳細的分析***

----------------------------------------------------

---------------------------------------------------

舉例:

--調入一個DICOM文件,輸出病人姓名

DcmFileFormat fileformat;

OFCondition status = fileformat.loadFile("test.dcm");

if (status.good())

{

OFString patientsName;

if (fileformat.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good())

{

    cout << "Patient's Name: " << patientsName << endl;

} else

    cerr << "Error: cannot access Patient's Name!" << endl;

} else

cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;

--創建一個DICOM dataset數據集,並保存爲文件

char uid[100];

DcmFileFormat fileformat;

DcmDataset *dataset = fileformat.getDataset();

dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);

dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));

dataset->putAndInsertString(DCM_PatientsName, "Doe^John");

 

dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);

OFCondition status = fileformat.saveFile("test.dcm", EXS_LittleEndianExplicit);

if (status.bad())

cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;

--如何爲多個文件創建一般目的的DICOMDIR

DicomDirInterface dicomdir;

OFCondition status = dicomdir.createNewDicomDir();

if (status.good())

{

while ( )

    dicomdir.addDicomFile( );

status = dicomdir.writeDicomDir();

if (status.bad())

    cerr << "Error: cannot write DICOMDIR (" << status.text() << ")" << endl;

} else

cerr << "Error: cannot create DICOMDIR (" << status.text() << ")" << endl;

------------------------------------------------------------

四、dcmimgle程序包

dcmimgle是一個圖像處理庫和可用的工具模塊,它包括了對DICOM單色圖像的訪問和顯示。對顏色圖像的支持由dcmimage模塊提供,對JPEG壓縮圖像的支持由dcmjpeg模塊支持。

主要接口類:

--DicomImage: 爲dcmimgle/dcmimage模塊提供接口類。主要目的是圖像顯示。在dcmimage.h中定義。

--DiDisplayFunction: Class to handle hardcopy and softcopy device characteristics file and manage display LUTs (for calibration). 在didispfn.h中定義。

可用工具:

--dcmdspfn: Export standard display curves to a text file

--dcod2lum: Convert hardcopy characteristic curve file to softcopy format

--dconvlum: Convert VeriLUM files to DCMTK display files

舉例:

 

--載入一幅DICOM單幀單色圖像,並顯示其像素數據。

DicomImage *image = new DicomImage("test.dcm");

if (image != NULL)

{

if (image->getStatus() == EIS_Normal)

{

    if (image->isMonochrome())

    {

      image->setMinMaxWindow();

      Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 ));

      if (pixelData != NULL)

      {

       

      }

    }

} else

    cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;

}

delete image;


五、dcmimage程序包

dcmimage模塊爲dcmimgle模塊提供對彩色圖像的支持。對單色圖像的支持由dcmimgle提供,對JPEG壓縮圖像的支持由dcmjpeg模塊支持。


主要接口類:

--DicomImage: 在dcmimgle中已介紹。

 

工具:

 

--dcm2pnm: Convert DICOM images to PPM/PGM, PNG, TIFF or BMP

--dcmquant: Convert DICOM color images to palette color

--dcmscale: Scale DICOM images

 

舉例:

 

--載入一幅DICOM單幀圖像(單色或彩色),並顯示其像素數據。

#include "diregist.h"  

 

DicomImage *image = new DicomImage("test.dcm");

if (image != NULL)

{

if (image->getStatus() == EIS_Normal)

{

    Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 ));

    if (pixelData != NULL)

    {

     

    }

} else

    cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;

}

delete image;


六、dcmjpeg程序包

dcmjpeg提供了一個壓縮/解壓縮庫以及可用工具。該模塊包含一些類,可將DICOM圖像對象在非壓縮和JPEG壓縮表示(傳輸協議)之間轉換。無失真和有失真JPEG處理都被支持。這個模塊實現了一族codec(編碼解碼器,由DcmCodec類派生而來),可以將這些codec在codec list中註冊,codec list是由dcmdata模塊保存的。


主要接口類:

--DJEncoderRegistration: 一個singleton(孤立)類,爲所有支持的JPEG處理註冊編碼器。在djencode.h中定義。

 

--DJDecoderRegistration: 一個singleton(孤立)類,爲所有支持的JPEG處理註冊解碼器。在djdecode.h中定義。

--DJCodecEncoder: JPEG編碼器的一個抽象codec類。This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG encoder using the DJEncoder interface to the underlying JPEG implementation. This class only supports compression, it neither implements decoding nor transcoding. 在djcodece.h中定義。

--DJCodecDecoder: JPEG解碼器的一個抽象codec類。This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG decoder using the DJDecoder interface to the underlying JPEG implementation. This class only supports decompression, it neither implements encoding nor transcoding.

工具:

dcmcjpeg: Encode DICOM file to JPEG transfer syntax

dcmdjpeg: Decode JPEG-compressed DICOM file

dcmj2pnm: Convert DICOM images to PGM, PPM, BMP, TIFF or JPEG

dcmmkdir: Create a DICOMDIR file

舉例:

--用無失真JPEG壓縮一幅DICOM圖像文件。

DJEncoderRegistration::registerCodecs(); // register JPEG codecs

DcmFileFormat fileformat;

if (fileformat.loadFile("test.dcm").good())

{

DcmDataset *dataset = fileformat.getDataset();

DcmItem *metaInfo = fileformat.getMetaInfo();

DJ_RPLossless params; // codec parameters, we use the defaults

 

// this causes the lossless JPEG version of the dataset to be created

dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, &params);

 

// check if everything went well

if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))

{

    // force the meta-header UIDs to be re-generated when storing the file

    // since the UIDs in the data set may have changed

    delete metaInfo->remove(DCM_MediaStorageSOPClassUID);

    delete metaInfo->remove(DCM_MediaStorageSOPInstanceUID);

 

    // store in lossless JPEG format

    fileformat.saveFile("test_jpeg.dcm", EXS_JPEGProcess14SV1TransferSyntax);

}

  

DJEncoderRegistration::cleanup(); // deregister JPEG codecs

--解壓縮一幅JPEG壓縮的DICOM圖像文件。

DJDecoderRegistration::registerCodecs(); // register JPEG codecs

DcmFileFormat fileformat;

if (fileformat.loadFile("test_jpeg.dcm").good())

{

DcmDataset *dataset = fileformat.getDataset();

// decompress data set if compressed

dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);

 

// check if everything went well

if (dataset->canWriteXfer(EXS_LittleEndianExplicit))

{

    fileformat.saveFile("test_decompressed.dcm", EXS_LittleEndianExplicit);

}

   
DJDecoderRegistration::cleanup(); // deregister JPEG codecs

七、dcmnet程序包

dcmnet是一個網絡庫及可用工具。該模塊包含了實現DICOM網絡通信的所有函數集,即:DICOM上層有限狀態機(DICOM Upper Layer Finite State Machine),關聯控制服務元素(Association Control Service Element, ACSE)以及DICOM消息服務元素(DICOM Message Service Element, DIMSE)。


主要接口:該模塊的主要接口包括在文件assoc.h和dimse.h中定義的大量結構和函數。


--assoc.h: 這個文件包含程序,爲DICOM應用提供關聯管理。它維護描述活動關聯的結構,提供對關聯特定信息的訪問。也提供程序幫助關聯協議association negotiation(presentation contexts, abstract syntaxes, transfer syntaxes, maximum PDU length, and other extended negotiation)。該包使用了DICOM上層機制接收/發送關聯請求/響應。每一個活動的關聯由T_ASC_Association結構表示,包含了所有相關的信息。模塊前綴ASC_。

 

--dimse.h: 這個文件包含程序,爲DICOM應用提供dimse層的服務。

工具:

--echoscu: DICOM verification (C-ECHO) SCU

--findscu: DICOM query (C-FIND) SCU

--movescu: DICOM retrieve (C-MOVE) SCU

--storescp: DICOM storage (C-STORE) SCP

--storescu: DICOM storage (C-STORE) SCU

--termscu: DICOM termination SCU

舉例:

--一個簡單的Echo SCU(Verification Service Class SCU)。大多數錯誤處理代碼省去了,在Win32上的特定代碼如WinSock初始化也省去了。


T_ASC_Network *net; // network struct, contains DICOM upper layer FSM etc.

ASC_initializeNetwork(NET_REQUESTOR, 0, 1000 , &net);

 

T_ASC_Parameters *params; // parameters of association request

ASC_createAssociationParameters(&params, ASC_DEFAULTMAXPDU);

// set calling and called AE titles

ASC_setAPTitles(params, "ECHOSCU", "ANY-SCP", NULL);


// the DICOM server accepts connections at server.nowhere.com port 104

ASC_setPresentationAddresses(params, "localhost", "server.nowhere.com:104");


// list of transfer syntaxes, only a single entry here

const char* ts[] = { UID_LittleEndianImplicitTransferSyntax };

// add presentation context to association request

ASC_addPresentationContext(params, 1, UID_VerificationSOPClass, ts, 1);

 

// request DICOM association

T_ASC_Association *assoc;

if (ASC_requestAssociation(net, params, &assoc).good())

{

if (ASC_countAcceptedPresentationContexts(params) == 1)

{

    // the remote SCP has accepted the Verification Service Class

    DIC_US // generate next message ID

    DIC_US status; // DIMSE status of C-ECHO-RSP will be stored here

    DcmDataset *sd = NULL; // status detail will be stored here

    // send C-ECHO-RQ and handle response

    DIMSE_echoUser(assoc, id, DIMSE_BLOCKING, 0, &status, &sd);

    delete sd; // we don't care about status detail

}

}

ASC_releaseAssociation(assoc); // release association

ASC_destroyAssociation(&assoc); // delete assoc structure

ASC_dropNetwork(&net); // delete net structure

八、dcmpstat程序包

dcmpstat: 一個描述狀態(presentation state)庫和可用工具。This module contains classes that implement a high-level API for the DICOM Softcopy Grayscale Presentation State Storage SOP Class. It also contains various support classes that are used by DICOMscope, a free DICOM viewer that has been developed as a demonstrator for presentation states. See http://dicom.offis.de/dscope

主要接口:

--DVPresentationState: 一個灰度軟拷貝描述狀態。這個類管理着一個描述狀態對象的數據結構。描述狀態可以創建、讀、寫和更改。在dvpstat.h中定義。

--DVInterface: 這個接口類是用來幫助軟拷貝描述狀態瀏覽器工作的。這個類管理着數據庫機制,允許開始和停止網絡交互,並訪問圖像和描述狀態。在dviface.h中定義。

--DVPSStoredPrint: the representation of a Stored Print object。在文件dvpssp.h中定義。

工具:

dcmmkcrv: Add 2D curve data to image

dcmmklut: Create DICOM look-up tables

dcmp2pgm: Read DICOM image and presentation state and render bitmap

dcmprscp: DICOM basic grayscale print management SCP

dcmprscu: Print spooler for presentation state viewer

dcmpschk: Checking tool for presentation states

dcmpsmk: Create DICOM grayscale softcopy presentation state

dcmpsprt: Read DICOM images and presentation states and render print job

dcmpsrcv: Network receive for presentation state viewer

dcmpssnd: Network send for presentation state viewer

舉例:

--給一幅DICOM圖像創建一個缺省的描述狀態

DcmFileFormat infile;

DcmFileFormat outfile;

if (infile.loadFile("image.dcm").good())

{

DVPresentationState pstate; // presentation state handler

if (pstate.createFromImage(*infile.getDataset()).good())

{

    // serialize presentation state into DICOM data set structure

    if (pstate.write(*outfile.getDataset(), OFFalse).good())

    {

      // and write to file

      outfile.saveFile("gsps.dcm", EXS_LittleEndianExplicit);     

    }

}

}


--應用一個描述狀態中的灰度變換管道給一幅DICOM圖像

DcmFileFormat imagefile;

DcmFileFormat gspsfile;

if (imagefile.loadFile("image.dcm").good() &&

    gspsfile.loadFile("gsps.dcm").good())

{

DVPresentationState pstate; // presentation state handler

if (pstate.read(*gspsfile.getDataset()).good()) // parse gsps object

{

    // attach presentation state to image data

    if (pstate.attachImage(&imagefile, OFFalse).good())

    {

      const void *pixel; // pointer to pixel data, one byte per pixel

      unsigned long width;   // width of image bitmap

      unsigned long height; // height of image bitmap

      if (pstate.getPixelData(pixel, width, height).good())

      {

       

      }

      pstate.detachImage(); // release connection between GSPS and image

    }

}

}

九、dcmsign程序包

dcmsign是一個數字簽名庫和可用工具。這個模塊包含了一些類,以創建DICOM數據集中的數字簽名,並驗證和刪除簽名。這個模塊需要擴展的OpenSSL庫的支持。


主要接口:
--DcmSignature: this class provides the main interface to the dcmsign module - it allows to create, examine and verify digital signatures in DICOM datasets or items. The methods in this class do not handle digital signatures embedded in sequence items within the dataset, other than providing helper functions that allow to locate and attach the sub-items separately. 在dcsignat.h中定義。

--SiSecurityProfile: 所有安全框架的抽象基類。abstract base class for all security profiles. 在sisprof.h文件中定義。

--SiCertificate: a class representing X.509 public key certificates. 在sicert.h文件中定義。


--SiPrivateKey: a class representing a private key. 在siprivat.h文件中定義。

--SiMAC: a base class for all classes that implement hash functions. 在simac.h文件中定義。


工具:

dcmsign: Sign and Verify DICOM Files


舉例:

--驗證一個DICOM文件中的所有簽名。

DcmFileFormat fileformat;

if (fileformat.loadFile("test.dcm").good())

{

int counter = 0;          // counts the signatures in the DICOM file

int corrupt_counter = 0; // counts signatures that failed verification

 

DcmDataset *dataset = fileformat.getDataset();

DcmStack stack;           // stores current location within file

DcmSignature signer;      // signature handler

DcmItem *sigItem = DcmSignature::findFirstSignatureItem(*dataset, stack);

while (sigItem) // browse through items that contain digital signatures

{

    signer.attach(sigItem); // each item may contain multiple signatures

    for (unsigned long l=0; l < signer.numberOfSignatures(); ++l)

    {

      if (signer.selectSignature(l).good())

      {

        ++counter;
        if (signer.verifyCurrent().bad()) // verify signature
           corrupt_counter++;
      }
    }
    signer.detach();
    sigItem = DcmSignature::findNextSignatureItem(*dataset, stack);
}
if (counter == 0) 
      cerr << "no signatures found in dataset." << endl;
else 
      cerr << counter << " signatures verified in dataset, " 
           << corrupt_counter << " corrupted." << endl;
}
--給一個DICOM文件增加簽名。
DcmFileFormat fileformat;
if (fileformat.loadFile("test.dcm").good())

{
DcmDataset *dataset = fileformat.getDataset();
SiCreatorProfile profile; // select the "RSA Creator Profile"
SiRIPEMD160 mac;           // use RIPEMD160 as MAC algorithm
DcmSignature signer;       // signature handler
SiCertificate cert;        // our certificate
if (cert.loadCertificate("certificate.pem", X509_FILETYPE_PEM).bad())
{
    cerr << "unable to load certificate" << endl;
    return;
}
SiPrivateKey key; // private key, must be unencrypted here
if (key.loadPrivateKey("privkey.pem", X509_FILETYPE_PEM).bad())
{
    cerr << "unable to load private key" << endl;
    return;
}
signer.attach(dataset); // connect handler to data set
if (signer.createSignature(key, cert, mac, profile).good())
{
    fileformat.saveFile("test_signed.dcm"); // write back
}
}
十、dcmsr程序包
dcmsr是一個結構化報表庫和可用工具。這個模塊包括一些類來讀、寫、創建、修改、訪問、打印和顯示DICOM結構化報表文檔。所支持的SOP類列表由DSRTypes::E_DocumentType提供。

主要接口:
--DSRDocument: Interface class for 'dcmsr' (DICOM Structured Reporting Documents). This class supports reading, writing, creation, printing and rendering of DICOM SR documents (according to DICOM PS 3.x-2004, formerly known as Supplement 23). The list of supported SOP classes is available in file "dsrtypes.h". 在dsrdoc.h中定義。
--DSRDocumentTree: 管理SR文檔樹的類。在dsrdoctr.h中定義。
--DSRContentItem: Interface class for content items. This class allows to access the document tree nodes without using any pointers. 在dsrcitem.h中定義。
--DSRCodedEntryValue: Class for coded entry values. 在dsrcodvl.h中定義。

工具:
dsr2html: Render DICOM SR file and data set to HTML 
dsr2xml: Convert DICOM SR file and data set to XML 
dsrdump: Dump DICOM SR file and data set 
xml2dsr: Convert DICOM SR file and data set to XML

舉例:
--載入一個DICOM結構化報表,並以HTML格式顯示其內容。
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
DSRDocument document;
status = document.read(*fileformat.getDataset());
if (status.good())
{
    status = document.renderHTML(cout);
    if (status.bad())
      cerr << "Error: cannot render SR document (" << status.text() << ")" << endl;
} else
    cerr << "Error: cannot parse SR document (" << status.text() << ")" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
--創建一個DICOM結構化報告,並將其存爲文件。
DSRDocument document;
document.setPatientsName("Doe^John");

document.getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
document.getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue());
document.getTree().addContentItem(DSRTypes::RT_hasObsContext, DSRTypes::VT_Code, DSRTypes::AM_belowCurrent);

DcmFileFormat fileformat;
OFCondition status = document.write(*fileformat.getDataset())
if (status.good())
{
status = fileformat.saveFile("test.dcm", EXS_LittleEndianExplicit);
if (status.bad())
    cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;
} else
cerr << "Error: cannot write SR document (" << status.text() << ")" << endl;
--讀取文檔樹的屬性,並直接修改。
DSRDocument document(DSRTypes::DT_KeyObjectDoc);

document.getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
DSRCodedEntryValue *codePtr = document.getTree().getCurrentContentItem().getConceptNamePtr();
if (codePtr != NULL)
codePtr->setCode("113000", "DCM", "Of Interest");

document.getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Image);
DSRImageReferenceValue *imagePtr = document.getTree().getCurrentContentItem().getImageReferencePtr();
if (imagePtr != NULL)
{
imagePtr->setValue(DSRImageReferenceValue(UID_UltrasoundMultiframeImageStorage, ));
imagePtr->setPresentationState(DSRCompositeReferenceValue(UID_GrayscaleSoftcopyPresentationStateStorage, ));
imagePtr->getFrameList().addItem(2);
imagePtr->getFrameList().addItem(5);
}


十一、dcmtls程序包
dcmtls是網絡庫的安全擴展。This module contains classes that implement DICOM network communication tunneled through a Transport Layer Security (TLS) connection, conforming to the DICOM "Security Enhancements One" extension (formerly Supplement 31). This module requires the external OpenSSL library.

主要接口:
--DcmTLSTransportLayer: factory class which creates secure TLS transport layer connections and maintains the parameters common to all TLS transport connections in one application (e.g. the pool of trusted certificates, the key and certificate to be used for authentication and the list of ciphersuite to be used for association negotiation.)。在tlslayer.h文件中定義。
--DcmTLSConnection: this class represents a TLS (Transport Layer Security) V1 based secure transport connection.

舉例:
--TLS的關聯請求應用
T_ASC_Network *net;        // network initialization code not shown,
T_ASC_Parameters *params; // we just assume these pointers to be valid

// create TLS object that initializes the random generator through a file

// "random.dat" containing random data (1 kByte is sufficient).

DcmTLSTransportLayer *tLayer = new DcmTLSTransportLayer(

DICOM_APPLICATION_REQUESTOR, "random.dat");

if (TCS_ok != tLayer->setPrivateKeyFile("privkey.pem", SSL_FILETYPE_PEM))
{
cerr << "unable to load private key" << endl;
return;
}

if (TCS_ok != tLayer->setCertificateFile("certificate.pem", SSL_FILETYPE_PEM))
{
cerr << "unable to load certificate" << endl;
return;
}

// enable the TLS_RSA_WITH_3DES_EDE_CBC_SHA ciphersuite

tLayer->setCipherSuites(SSL3_TXT_RSA_DES_192_CBC3_SHA);

// accept any certificate from the remote site (not recommended)

tLayer->setCertificateVerification(DCV_ignoreCertificate);

// register and activate TLS layer

ASC_setTransportLayer(net, tLayer, 1);

ASC_setTransportLayerType(params, 1);

十二、dcmwlm程序包

dcmwlm是一個設備工作表(Modality Worklist)數據庫服務器。這個模塊包含類,作爲一個SCP,爲實現DICOM Modality Worklist Management Service的應用提供支持。基於這些類的SCP可以從C-Find-RSP返回消息中找到相關信息。

主要接口:

--WlmActivityManager: This class encapsulates data structures and operations for basic worklist management service class providers. 在wlmactmg.h文件中定義。

--WlmDataSource: This class encapsulates data structures and operations for connecting to an arbitrary data source in the framework of the DICOM basic worklist management service. 在wlds.h文件中定義。

--WlmDataSourceFileSystem: This class encapsulates data structures and operations for connecting to a file-based data source in the framework of the DICOM basic worklist management service. 在wldsfs.h文件中定義。

--WlmFileSystemInteractionManager: This class encapsulates data structures and operations for managing data base interaction in the framework of the DICOM basic worklist management service. 在wlfsim.h文件中定義。

工具:

wlmscpfs: DICOM Basic Worklist Management SCP (based on data files)

舉例:

For an example of how to use the main interface classes of this module, see file 'wlmscpfs.cc' (containing the main function of the corresponding tool) and file 'wlcefs.cc' (making use of the WlmActivityManager class that manages all activities a corresponding SCP has to manage).

十三、dcmqrdb程序包

dcmqrdb是一個圖像數據庫服務器。This module contains a simple image archive that manages a number of storage areas and allows images to be stored in these storage areas using the DICOM Storage Service Class. It also allows image attributes to be queried and images to be retrieved using the DICOM Query/Retrieve Service Class.

工具:

dcmqridx: Register a DICOM image file in an image database index file

dcmqrscp: DICOM image archive (central test node)

dcmqrti: The Terminal Initiator Telnet Client Program

文件:下面文件提供進一步信息。

--dcmqrcnf.txt:

發佈了71 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章