DICOM medical image processing: WEBPACS Session 4, PHPDICOMClass

Source: Internet
Author: User
DICOM medical image processing: Introduction to WEBPACS 4. Background of PHPDICOMClass:

I have not sorted out several Blog columns that have been posted for a long time. The main reason is that the WML server plan I hoped to build had encountered problems. Taking the reference of dcmtk's official document wwwapp.txt, combined with the WAMP server set up two days ago, we can smoothly implement the WML service, so that we can simultaneously complete the web pacs series and build the Dicom WML server two blog posts. However, several serious problems were found during the actual deployment, which could not be solved at the moment. However, when searching for a solution, I accidentally found the article encapsulated by PHP on the DCMTK toolkit posted on the DCMTK Forum. Therefore, this blog post, while recording the problems encountered during WML setup, mainly wants to introduce the PHP class of this simple DCMTK package, and provides demonstration instances on the WAMP server established in the earlier stage. (PS: I also want to know how to solve this problem)

Problem:

According to the dcmtkofficial document wwwapp.txt File (http://support.dcmtk.org/docs/file_wwwapp.html) instructions, to build DICOM Basic Worklist Management service preparations have been basically completed, the aforementioned web pacs platform has successfully provided HTTPD, CGI, and Perl parsing functions (for details, see The Perl example in the blog post: http://blog.csdn.net/zssureqh/article/details/40516745 ). However, when you copy the executable files (such as preplock, readoviw, readwlst, and writwlst) in the wwwapps directory according to the instructions in the wwwapp.txt document, the files are not found in the compiled project and only the corresponding ones are displayed. cc source code file.

Wwwapp installation materials:

After searching for relevant information, I found that Liu Beifeng's predecessors had encountered this problem before and consulted the maintenance personnel of OFFIS. What is the description of the predecessors? F=1&t=723&hilit=wwwapp.txt.

Solution:

According to the above instructions, I am sure that there is a problem in the process of compiling the DCMTK source code, leading to the loss of several exe files that should be generated smoothly. The discussion in the official forum is about how to use the make tool to compile in a Linux environment, in this environment, the make distclean command is used to control the cleanup of executable files such as preplock, readoviw, readwlst, and writwlst. Hosts file. So far, the solution to this problem is terminated, and a good solution has not been found at the time of posting.

Php dicom Class

When browsing the OFFIS Forum and looking for solutions to the above problems, I accidentally clicked"Third-Party DCMTK ApplicationsAs shown in, the sub-forum describes the development of many DCMTK-related applications, one of which is called "php dicom Class".


AuthorVedicvekoThe design intention and detailed instructions of the PHP Dicom Class are provided. the URL of this document is http://deanvaughan.org/wordpress/dicom-php-class /.

Download the source code (https://github.com/vedicveko/class_dicom.php/zipball/master), open the class_dicom.php core class file, we can see that the author uses the exec command in PHP to package the corresponding DCMTK toolkit, with the advantages of the PHP language, DCMTK makes it easier to implement networked applications. The call between the Apache network server and PHP can directly use the simple web pacs platform we set up earlier (the platform calls PHP through FastCGI ), then, you can use php dicom Class to perform most operations on the dcm file. the specific implementation is as follows.

Install php dicom Class:

First, place the compiled DCMTK toolkit in the specified location. for example, if my local address is c: \ dcmtk \ bin, modify the following code in the class_dicom.php file, point TOOLKIT_DIR to the local toolkit directory c: \ dcmtk \ bin.

Define ('toolkit _ dir', 'C:/dcmtk/bin'); // CHANGE THIS IF YOU HAVE DCMTK INSTALLED SOMEWHERE ELSE

Second, create a class_dicom_php directory under the root directory of the website service (my local machine is c: \ WAMP \ www \) with the help of the preceding wamp service, copy the downloaded php dicom Class source code file to the class_dicom_php directory, as shown in:

Third, enable the wamp server service and enter http: // localhost/class_dicom_php/examples/get_tags.php in the browser to perform the test. if it is normal, the system outputs the dean. the Tags tag information of the dcm file, as shown in:

The result displayed in the browser is the same as the result viewed by d1_ump.exe, indicating that the php dicom Class has been successfully installed on the web pacs platform.

[Note ]:An error may occur during actual running because $ argv command line variable is used in get_tags.php to obtain the path of the specific dcm file, however, in web pacs, we can only pass parameters to the php script by using GET or POST methods. Therefore, you can modify the parameter acquisition method in get_tags.php or directly import the test file dean. dcm is written to the file path variable as follows:

$ File = (isset ($ argv [1])? $ Argv [1]: 'Dean. dcm ');

# Original Code: $ file = (isset ($ argv [1])? $ Argv [1]: '');

After the modification, enter http: // localhost/class_dicom_php/examples/get_tags.php in the browser again, and the above results will be obtained smoothly.

Example: output the DCM image data to the browser. 1) add the dcm_to_bmp () function:

Although php dicom Class simply calls the DCMTK toolkit to implement PHP operations on DICOM files, due to the powerful DCMTK toolkit, currently, when the concurrency of the simple web pacs platform is small, we can try to use php dicom Class to output the image information of the DCM file to the browser in the previous blog.

View class_dicom.php, and see that the dicom_convert class has a free bidirectional transformation from JPEG to DCM. the source code uses the dcmj2pnm in the DCMTK toolkit. you can see the help documentation of dcmj2pnm, this tool can also implement the conversion from DCM to bmp files. Therefore, it is decided to extend the dicom_convert class in class_dicom.php and add the dcm_to_bmp () function. the specific code is as follows:

### zssure 20141104function dcm_to_bmp() {$filesize = 0;$this->jpg_file = $this->file . '.bmp';$convert_cmd = BIN_DCMJ2PNM . " +ob " . "\"" . $this->file . "\" \"" . $this->jpg_file . "\"";$out = Execute($convert_cmd);if(file_exists($this->jpg_file)) {$filesize = filesize($this->jpg_file);}return($this->jpg_file);}

Dcm_to_bmp () is different from dcm_to_jpg () in that the command parameters of dcmj2pnm are different. The bmp file uses the + ob parameter. of course, you can also identify the specific image data of dcm from adaptation, dcmj2pnm can generate bmp images in multiple formats, as shown in:

2) instance test:

Compile the dcm_to_bmp test php with the following code:

#!/usr/bin/php
 \n";exit;}if(!file_exists($file)) {print "$file: does not exist\n";exit;}$job_start = time();$d = new dicom_convert;$d->file = $file;$d->dcm_to_bmp();#$d->dcm_to_tn();#system("ls -lsh $file*");$job_end = time();$job_time = $job_end - $job_start;#print "Created BMP and thumbnail in $job_time seconds.\n";header("Content-type:image/bmp\n\n");$jpgName=$d->jpg_file;$fp=fopen($jpgName,"r");fpassthru($fp);exit;?>

After dcmj2pnm is used to convert dcm to a bmp file, you can directly use PHP in the previous blog post to output the image to the browser code, and enter: http: // localhost/class_dicom_php/examples/dcm_to_bmp .php to get dean smoothly. shows the image information of the dcm test file:

So far, the php dicom Class can be used to quickly and conveniently output the image information of the dcm file to the browser.

Learn about DCMTK:

Originally only the use of OFFIS Forum (http://forum.dcmtk.org/index.php) to search for the use of DCMTK encountered in the process of various errors, never carefully and comprehensively browsed the various parts of the OFFIS Forum, through today's personal experience, it is found that the Third-Party DCMTK Applications under the DCMTK project of the OFFIS Forum is also a knowledge treasure, which contains various tools developed by coders using DCMTK, mostly open source, relevant documents are also detailed and can be used as the key learning materials in the future.

Below are some links that I think are worth learning for your reference:

  • Http://forum.dcmtk.org/viewtopic.php? F = 19 & t = 1225, an open source DICOM file browser with rich functions;
  • Http://forum.dcmtk.org/viewtopic.php? F = 19 & t = 2919. the post we mentioned above by the author of php dicom Class. thank you for your selflessness;
  • Translate (translation will be performed one by one when time is available );
  • Http://forum.dcmtk.org/viewtopic.php? F = 19 & t = 2373, a DICOM file browser in Windows;
  • Follow-up blog introduction:

    Use PHP Skel and DCMTK to develop web pacs applications

    Use DCMTK to build a WML server

    Using oracle to directly operate DICOM data

    Application of C # asynchronous programming mode in fo-dicom

    Test the three network connection modes of VMWare


    By zssure@163.com

    Time: 2014-11-04

    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.