DICOM Medical Image processing: A preliminary discussion on WEB PACs four, PHP dicom Class

Source: Internet
Author: User
Tags php language
Background:

A long preview of several column posts has not been sorted out, mainly because the WML server plan that I wanted to build earlier was having problems. At first, the DCMTK official document Wwwapp.txt combined with the WAMP server that was set up two days ago can implement WML services smoothly, so you can complete the Web PACs series as well as build two blog posts of dicom WML server. However, in the actual deployment process found a few serious problems, temporarily unable to solve. But in search of the solution, occasionally found in the DCMTK forum posted in the PHP DCMTK Toolkit package of articles. Therefore, this blog post in the record to build WML encountered problems, the main want to introduce you to this simple Package DCMTK Toolkit PHP class, in the previous build Wamp server to give a demonstration example. (PS: Also want to know how to solve the problem of the Great God hurriedly appeared)

Problem:

Set up Dicom Basic worklist as described in DCMTK Official document Wwwapp.txt file (http://support.dcmtk.org/docs/file_wwwapp.html) The previous preparation of the management service has been largely completed, and the aforementioned Web PACs platform has been able to provide httpd, CGI, and Perl parsing capabilities (see blog post for Perl example: http://blog.csdn.net/ zssureqh/article/details/40516745). However, as instructed by the Wwwapp.txt documentation to copy the executable files under the Wwwapps directory (such as Preplock, Readoviw, Readwlst, Writwlst), it was not found in the compiled project, only the corresponding. cc source files were seen.

Wwwapp installation of the relevant information:

After searching the relevant data, found that Liubei wind Elder has also encountered this problem, and to OFFIS related maintenance personnel have consulted. The description of the predecessor of the blog address is: Http://qimo601.iteye.com/blog/1701026,OFFIS Forum discussion address is: http://forum.dcmtk.org/viewtopic.php?f=1&t= 723&hilit=wwwapp.txt.

Try to resolve:

According to the above instructions, it is believed that in the compilation of DCMTK source code in the middle of a problem, causing a few EXE files should be successfully generated lost. The discussion in the official forum is about compiling with the Make tool in the Linux environment, which controls Preplock, Readoviw, Readwlst, and Distclean commands when making the installation. Cleanup of executable files such as Writwlst. But in a Windows environment, CMake is used to generate the sln file corresponding to vs. After opening the DCMTK.sln solution did not find how to set up to build the above executable file, and according to Liu Predecessors, even if the compilation is successful, in the WIN7 environment is also missing a preplock.exe file. At this point the resolution of the problem has been terminated, to the publication time has not found a good solution.

PHP DICOM Class

When browsing the Offis forum, looking for solutions to the above problems, inadvertently opened the "third-party DCMTK Applications" branch in the forum, as shown in this sub-forum, which introduces a number of DCMTK-related application development, one of which is called " PHP DICOM Class ".


The author Vedicveko gives the design intention of the PHP Dicom class and the detailed usage instructions, the document URL is: http://deanvaughan.org/wordpress/dicom-php-class/.

After downloading the source code (https://github.com/vedicveko/class_dicom.php/zipball/master), open Class_ Dicom.php Core class files, it can be seen that the author by using the EXEC command in PHP to package DCMTK corresponding toolkit, the advantage of the PHP language to make the DCMTK easier to network applications. The call between the Apache Web server and PHP can take advantage of the simple Web PACs platform we built earlier (the platform is implemented via fastcgi for PHP calls), and then by combining PHP DICOM class, you can implement most operations on DCM files. The specific implementation is as follows.

Installation of the PHP DICOM class:

First, the DCMTK compiled toolkit is uniformly placed in the specified location, for example, my native address is: C:\dcmtk\bin, modify the following code in the class_dicom.php file, Toolkit_dir point to the Native Toolkit directory C:\dcmtk\bin.

Define (' Toolkit_dir ', ' c:/dcmtk/bin '); Change the IF you have DCMTK installed somewhere ELSE

Second, with the help of the Wamp service in front of the site service root directory (I am c:\wamp\www\) under the new class_dicom_php directory, the download of the PHP Dicom class source files directly copied to the class_dicom_php directory, As shown in the following:

Third, open the WAMP Server service, enter http://localhost/class_dicom_php/examples/get_tags.php in the browser, test, normal words will output DEAN.DCM file tags tag information, as shown in:

The results seen in the browser shown above are consistent with the results viewed using the Dcmdump.exe tool, which shows that the PHP DICOM class has been successfully installed in the Web PACs platform.

Note: errors may occur during actual operation because Get_tags.php uses the $ARGV command-line variable to obtain the specific DCM file path, but the web In PACs, we can only pass parameters to the PHP script via get or post, so we can modify the method of obtaining parameters in get_tags.php, or write the test file DEAN.DCM directly into the file path variable as follows:

$file = (Isset ($argv [1])? $ARGV [1]: ' DEAN.DCM ');

#原来代码为: $file = (Isset ($argv [1])? $ARGV [1]: ');

Once you have modified the http://localhost/class_dicom_php/examples/get_tags.php in your browser, you will get the results.

Example: Output DCM image data to a browser

1) Add the Dcm_to_bmp () function:

Although the PHP Dicom class simply calls the DCMTK Toolkit to implement PHP for the DICOM file operation, but because of the powerful DCMTK Toolkit, at present, our simple Web PACs platform concurrency number is not large, you can try to directly use the PHP dicom Class to enable the output of the DCM file's image information to the browser in the previous post.

See class_dicom.php, see the Dicom_convert class in which there is a free bidirectional transformation of JPEG to DCM, which is used in the source of the DCMJ2PNM in the DCMTK Toolkit, to view the DCMJ2PNM help document, The tool also enables the conversion of DCM to BMP files, so it is decided to extend the Dicom_convert class in class_dicom.php, adding the dcm_to_bmp () function, 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 () differs from dcm_to_jpg () in the main place is DCMJ2PNM directive parameters, BMP file is used to +ob parameters, of course, can also be identified by the DCM specific image data from the adaptation, The DCMJ2PNM itself can generate BMP images in a variety of formats, as shown in:

2) Example test:

Write 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 using DCMJ2PNM to convert DCM to BMP file, you can directly use the previous blog post PHP output image to the browser code to output the results, in the browser input: HTTP://LOCALHOST/CLASS_DICOM_PHP/EXAMPLES/DCM _to_bmp.php, get the image information of the DEAN.DCM test file smoothly, as shown in:

At this point, using the PHP DICOM class to quickly and easily implement the DCM file image information output to the browser function.

Learn the DCMTK information:

Originally just use Offis forum (http://forum.dcmtk.org/ index.php) to search for the various errors encountered during the DCMTK process, never thoroughly visited the various parts of the Offis forum, and through today's experience, found in the Offis forum DCMTK project "Third-party DCMTK Applications "Part is also a knowledge treasure, which contains a variety of cattle people using DCMTK development tools, mostly open source, related documents are also very detailed, later can be used as a key learning material.

Here are a few of the links I think are worth learning, for your reference:

  • http://forum.dcmtk.org/viewtopic.php?f=19&t=1225, an open source Dicom file browser, features rich;
  • http://forum.dcmtk.org/viewtopic.php?f=19&t=2919, as we mentioned above, the PHP DICOM class author sent The post, thank the great God selfless;
  • Http://medicalanonymization.olympe.in/index.html, an excellent DCMTK programmer during the internship project of the open source station: There is a detailed introduction to the use of DCMTK (follow-up time on a translation);
  • http://forum.dcmtk.org/viewtopic.php?f=19&t=2373, a dicom file browser under the Windows system;
  • Follow-Up Blog introduction:

    Develop Web PACs applications with PHP Skel combined with DCMTK

    Using DCMTK to build WML servers

    Direct operation of DICOM data with Oracle

    Application of the asynchronous programming pattern of C # in fo-dicom

    Practical testing of VMware three network connection modes


    Author: zssure@163.com

    Date: 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.