[Post] DCMTK-based DICOM programming strategy

Source: Internet
Author: User

Preface:

As the image storage and transmission of medical imaging equipment is gradually moving closer to the DICOM standard, during our medical image processing process, you often need to write various program modules related to DICOM images to complete your processing functions. It is a huge project to understand the DICOM protocol from the beginning and write the code on your own to implement the Protocol. DCMTK developed by German offis provides a platform for us to implement DICOM protocol, so that we can easily complete our main work on the basis of it, you don't have to focus too much on implementing the DICOM protocol. This article uses Windows XP + vc6.0 as the development platform, and introduces the DCMTK-based DICOM programming process from the aspect of downloading, debugging, and usage of DCMTK.

1. DCMTK Overview

DCMTK is an open-source project provided by German offis and has the relevant copyright. After more than 10 years of development and maintenance, this development kit has basically implemented all the content of DICOM protocol. This development kit provides all source code, support libraries, and help documentation. DCMTK provides possible versions used in various operating systems, such as Linux, sun, and windows. You can compile it on your own development platform. The current DCMTK version is 3.5.3.

Ii. Download and debug DCMTK

DCMTK company home page: http://dicom.offis.de.

1. Download the source code of dtmtk. You can use the following address: ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk353/dcmtk-3.5.3.zip

2. Download the supported libraries:

Ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk353/support/dcmtk-3.5.3-win32-i386-support.zip

3. Installation or debugging.

(1) first, extract the source code of DCMTK and put it in the same directory as its support library.

(2) Use the cmake software to obtain the DCMTK project file.

By using the make tool cmake, you can not only create DCMTK to compile the project file, but also configure DCMTK. The procedure is as follows:

① Download the latest version of cmake for Windows from http://www.cmake.org/html/download.html.

② Install cmake and set the following options for cmake (delete the original project file before setting): 1

Where is the source code: dcmtk-3.5.3 path

Where to build the Binaries: dcmtk-3.5.3 path

Build for: Visual Studio 6

Configure --> modify cache values! --> Configure

OK!

Figure 1. Use cmake to create DCMTK to compile the project file

(3) Open the project file DCMTK. DSW with vc6 for compilation. Add the corresponding header files and library files to the compilation environment (tools-> Option-> Directories) as prompted.

(4) Compilation of DCMTK may take a long time, and various connection errors may also occur during the process, most of which are caused by the compiling environment.

3. DCMTK-based DICOM programs.

1. Create your own application project and add it to the DCMTK workspace (Project-> insert project to workspace ).

2. Add the DCMTK static library and header file to your project.

Enter the link library file in the correct order (the order of the Link Library is also very important !) The DCMTK Library has the following dependencies:

Dcmdata-"ofstd

Dcmimage-"dcmimgle, dcmdata, ofstd

Dcmimgle-"dcmdata, ofstd

Dcmjpeg-"G8, ijg12, ijg16, dcmimage, dcmimgle, dcmdata, ofstd

Dcmnet-"dcmdata, ofstd

Dcmpstat-"dcmimage, dcmimgle, dcmsign, dcmsr, imagectn, dcmtls, dcmnet, dcmdata, ofstd

Dcmsign-"dcmdata, ofstd

Dcmsr-"dcmdata, ofstd

Dcmtls-"dcmnet, dcmdata, ofstd

Dcmwlm-dcmnet, dcmdata, ofstd

Imagectn-dcmnet, dcmdata, ofstd

3. compile your own project.

4. The failure may cause the following problems.

(1) for a single document project, the following prompt is displayed during running:

Generated debug assertion

If (! Processshellcommand (cmdinfo ))

Return false;

-- File: docsingl. cpp

Line: 215

Cause: the afx_ids_untitled string is missing.

Solution: add the id = afx_ids_untitled key value to the string table of the resource file.

(2) Prompt during editing:

Fatal error c1189: # error: please use the/MD switch for _ afxdll builds

Cause:

Solution: remove the _ afxdll item from project> Settings> Preprocessor definitions.

(3) Compile prompt:

Libcmtd. Lib (dbgheap. OBJ): Error lnk2005: _ malloc already defined in msvcrtd. Lib (msvcrtd. dll)

Cause: As VC tries to write the same function code from two different libraries during compilation, it can be solved by ignoring these conflicting default libraries.

Solution: choose Project> Settings> link> Category> input> ignore liberies.

Msvcprtd. lib and msvcrtd. Lib.

Another solution: ensure that your compiling environment is:

A) project-> Settings-> C/C ++-> category-> use run-time library of code generation is debug multithreaded.

B) Remove the _ afxdll item from project-> Settings-> Preprocessor definitions.

C) if necessary, add the id = afx_ids_untitled key value to the string table of the resource file.

D) in this way, you do not need to ignore those libraries.

You can also:

Later, I tried a lot of methods. After some exploration, I finally came up with a solution:

Define _ afxdll in Preprocessor

If it prompts: Fatal error c1189: # error: please use the/MD switch for _ afxdll builds

Change it like this:

C/C ++-> code generation-> multithread DLL (Implementation/MD option)

(4) Compile prompt:

Dcmdata. Lib (dcuid. OBJ): Error lnk2001: unresolved external symbol _ NetBIOS @ 4

Cause: the required link library file is missing

Solution: add the DCMTK static library and header file to your project, and pay attention to the sequence.

(5) Compile prompt:

Fatal error lnk1181: cannot open input file ....... Debug. OBJ

Cause: a similar error may occur because the directory contains too long Chinese names.

Solution: Change the Chinese directory name to English.

(6) Running prompt:

Cause:

Solution: remove the _ afxdll item from project> Settings> Preprocessor definitions.

(7) If you copy the DCMTK directory that has been made to another directory, you need to make it again. Otherwise, a lot of path errors may occur.

4. A practical example

We often use DICOM to read and write DICOM files. The following uses reading and writing DICOM as an example to describe how to use DCMTK.

5. Other problems

1. Use DCMTK as a static library: DCMTK provides a static library, that is, Lib. All functions will be added when linked to your project, therefore, the executable files are large and not easy to upgrade. If you need to use DCMTK as the dynamic Library Link, you need to build the corresponding DLL project and then add the original program file, write another file for the export function. These export functions remain fixed. In this way, the dynamic library program will not be upgraded and re-compiled when used elsewhere.

2,

Reference file:

1. dcmtk faq Forum: http://forum.dcmtk.org/

2. DCMTK help document: ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk353/docs/dcmtk-3.5.3-html-help.zip

3. DICOM standard version 2004.

4. DICOM validation tool is a DICOM validity test tool used to test the DICOM compatibility of products. Advt is the DICOM validation tool provided by AGFA ......

5, http://www.pacser.net/dispbbs.asp? Boardid = 20 & id = 72 & page = 1

Reprinted from: http://blog.csdn.net/jackmacro/archive/2010/02/27/5332654.aspx

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.