How to Use DCMTK to traverse and read all tags of DICOM files

Source: Internet
Author: User

Key function: dcmobject * dcmitem: nextincontainer (const dcmobject * OBJ), which is a virtual function in dcmobject and implemented by the dcmitem class. Because the dcmdataset class inherits from dcmitem, therefore, the dcmdataset object can use this method to traverse the tag between 0008-7fe0.

The original code of this function is

Dcmobject * dcmitem: nextincontainer (const dcmobject * OBJ) {If (! OBJ) return elementlist-> get (elp_first); // elementlist is dcmlist *, and else {If (elementlist-> get () in dcmitem ()! = OBJ) {for (dcmobject * search_obj = elementlist-> seek (elp_first); search_obj & search_obj! = OBJ; search_obj = elementlist-> seek (elp_next) {/* do nothing, just keep iterating */} return elementlist-> seek (elp_next );}}

The analysis code shows that:

(1) When nextincontainer (null) is used, a dcmobject pointer is returned. Using the gettag () method of this pointer, A tag1 can be obtained, this tag1 is the first tag with the group number 0008 in the image. (A returned object of nextincontainer (null) is defined here: dcmobject * pobject_tg)

(2) When nextincontainer (pobject_tg) is used, a dcmobject pointer is returned. Similarly, the gettag () method of this pointer can obtain a tag2, this tag2 is the second tag with the group number 0008 in the image. That is, the tag following tag1.

In this way, we can design a simple loop to traverse all the tags between 0008-7fe0.

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.