DICOM medical image processing: web pacs 3. PHP extension skeleton, dicompacs

Source: Internet
Author: User

DICOM medical image processing: web pacs 3. PHP extension skeleton, dicompacs

In the last two column blogs, we have explained how to build a web pacs environment. If the backend of the platform is not related to DICOM, there is actually nothing to do with PACS, so the last few articles seem to have some run-off questions, but don't worry. The establishment of the development environment itself is a huge and difficult project. The subsequent development of PACS will be as handy as the standalone version, after a while, we will soon begin to introduce the development of web pacs on the platform.

C/C ++:

The last two blog posts are just a clever attempt to the environment. The first blog directly uses the CGI provided by the APACHE service to directly call the exe file compiled by C, as the CGI technology has been gradually replaced by FastCGI, the first blog is used only for demonstration, not for later development. The second blog continues the first article, trying to transmit images, in the end, we cannot find the correct way to transmit image data in C language. We can only use PHP, Perl, and other explanatory languages to implement it, however, PHP and Perl cannot be well integrated with the DCMTK we introduced earlier, so the second blog does not play a major role. In view of the above reasons, it is decided to add a C/C ++ language PHP extension framework based on the FastCGI platform that has been built to realize the complete development environment of web pacs.


1) PHP source code: Download the PHP source code to generate the latest PHP runtime program that is the most compatible with the database, that is, php.exe (of course, you can also directly install Baidu/Google's latest PHP installation package by double-clicking );

2) PHP source code compilation: PHP source code is open-source and must be compiled in linux. Therefore, a mini Linux compiling environment must be installed in windows, download Cygwin or msys + MingGWen (refer to this blog post for detailed differences between the two); -- Remember to modify $ cygwin_path = 'C: \ cygwin64 \ bin'syntax, which is used to indicate the location of sh.exe.

3) php sdk: the SDK is called Software Development Kit. as its name implies, it is a collection of commonly used gadgets (which can be understood as APIS) in Software Development. In this case, we only use bison.exeand flex.exe in the php-binary-sdkpackage to copy them to the current windows Directory, so that we can find them (or add the two paths to the environment variable Path ).

Compile and generate: PHP source code compilation:

The local computer is installed with VS2012 and VS2010. Select VS2012 to compile the PHP source code. First, enter the command line status of VS, such:

Input: cd c: \ PHPDev \ php-5.6.2

Convert to the php source code Directory, which contains the buildconf. bat file. (PHPDev is the upper-level directory created by myself. Replace it with your local directory during actual compilation)

Input: buildconfig. bat. Start the script program buildconfig. js in the batch processing command and search all. w32 files in the directory to prepare for compiling in windows. If the task runs successfully, the system prompts "Now run 'configure -- help'". Otherwise, the system prompts "Error generating configure script, configure script was not copied ". After the compilation is successful, follow the prompts to enter configure -- help to view the compilation options. Then, refer to the instructions in http://demon.tw/software/compile-php-on-windows.htmlin the blog post:

Configure-without-xml-without-wddx -- without-simplexml -- without-dom -- without-libxml -- disable-zlib -- without-pdo-sqlite -- disable-odbc -- disable-cgi -- enable-debug -- without-iconv -- disable-ipv6

Note:This is slightly different from the introduction in the blog post. Before without, there are two "-". For details, refer to the prompt "configure -- help", for example:

After the configuration is complete, it is the compilation process. Enter nmake to start the actual compilation.

[Note]: errors may occur during compilation, as shown in. In this case, use EditPlus, NotePad ++, and other editing tools to convert the file to UTF-8 encoding and restart nmake.

After compilation, the debug_tsfolder is displayed. The PHP executable file generated after the source code is compiled under the folder. The php.exe file is displayed in the figure showing the nmake compilation success result.

Input php.exe "echo 'Hello world';" to the debug_tsdirectory. The correct output is displayed. This shows that the compilation of php source code on windows is successful.

PHP Skeleton Generation:

Php.exe ext_skel_win32.php -- extname = zsgetdcmimage

After obtaining the PHP executable program, the skeleton is generated. Go to the ext folder in the php source code, and you can see the two files used for Skeleton Generation, ext_skel and ext_skel_win32.php. Ext_skel, and then automatically changed the originally written C/C ++ dynamic library-based project to our own named project by using a php script. You can open the ext \ skeleton directory of the source code and find that there is a project named skeleton. dsp, which is only named differently from the final skeleton project.

C Programming PHP extension test:

After the basic environment is set up, let's perform a practical test.

The skeleton project provides us with a test function with the same name as our project. For example, the function in my zsgetdcmimage project is:

/* Remove the following function when you have successfully modified config.m4
   so that your module can be compiled into PHP, it exists only for testing
   purposes. */

/* Every user-visible function in PHP should document itself in the source */
/* {{{ proto string confirm_zsgetdcmimage_compiled(string arg)
   Return a string to confirm that the module is compiled in */
	char *arg = NULL;
	int arg_len, len;
	char *strg;
	len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "zsgetdcmimage", arg);
	RETURN_STRINGL(strg, len, 0);


The php source code we compiled above enables the debugging status, that is, the parameter is -- enable-debug. Therefore, the corresponding Debug_TS mode should be used for compiling the skeleton program, at the same time, the link library php5ts_debug.lib is added. The file is in the Debug_TS source code folder compiled by php.

After compilation is successful, the generated zsgetdcmimage. the dll is copied to the ext subdirectory in Debug_TS, the Directory of the compiled php executable program, and php in Debug_TS is modified. ini, add extension = ext/zsgetdcmimage. dll statement.

Finally, create a test. php document. The Code is as follows:

<?phpecho confirm_zsgetdcmimage_compiled("zssure");?>

In the command line status, go to the debug_tsdirectory and enter php.exe test. php. If the configuration is successful, the following output is displayed:

Now, the skeleton extension and instance test are complete.

Note: Change PHP In WampServer

In the first two blog posts, we have used wamp to fight for an opportunity to use the Apache + PHP + MySQL Web service framework to compile the above-compiled zsgetdcmimage. dll extensions are placed in c: \ wamp \ bin \ php5.5.12 \ ext. After wampServer is started, the following error message cannot be called:

This error indicates that the extension generated by the extension skeleton of php5.6.2 does not match in php5.5.12. In this case, to add the PHP extension skeleton to the previously established web pacs platform, there are only two options: 1) download the source code of the corresponding version php5.5.12, rebuild the skeleton program according to the above record; 2) Replace php In the wamp installation package.

I was not very familiar with WampServer configurations, so I would like to take advantage of this opportunity to learn it easily. Then I decided to replace PHP In the WampServer installation package with php5.5.12 and php5.6.2. I searched the internet and found a lot of related information. The basic operation ideas mainly refer to the introduction of the two blog posts. Now I am given in Win7 32 bit + WampServer-64-bits-php-5-5 environment under the specific implementation steps. First, go to the c: \ wamp \ bin \ php Directory, and decompress the latest binary installation package in windows downloaded from the php official website to this directory. For example, the complete path of php5.6.2 is c: \ wamp \ bin \ php \ php5.6.2. The subsequent modification method and sequence are as follows:

WampServer Modification 1 Wampmanager. conf

Replace the [php] tag with the new version 5.6.2.

Replace the version number in the [phpCli] label with 5.6.2.

WampServer modification 2 Wampmanager. ini

Use NotePad ++ or EditPlus and other text editors to search for phpX. X. X in a file and replace it with php5.6.2;

[Note]: replace X. X. X with 5.6.2, for example, the Caption under [switchPhp5.6.2] and [phpVersion.

PHP Modification 1 Php. ini 1. Set extension_dirto the path of php.exe in the new version. extension_dir = "c: \ wamp \ bin \ php \ php5.6.2 \ ext \"
2) then selectively cancel the annotation of extension = XXX. dll and add php extensions.
PHP modification 2 PhpForApache. ini Copy the php. ini file and rename it phpForApache. ini.
APACEH Modification Httpd. conf

In the FastCGI configuration moduleVersion NumberModify the settings as follows:

LoadModule php5_module "c:/wamp/bin/php/php5.6.2/php5apache2_4.dll"

PHPIniDir c:/wamp/bin/php/php5.6.2

LoadModule fcgid_module modules/mod_fcgid.so

<IfModule mod_fcgid.c>

AddHandler fcgid-script. fcgi. php

# Directory for storing php. ini

FcgidInitialEnv PHPRC "c:/wamp/bin/php/php5.6.2"

# Set PHP_FCGI_MAX_REQUESTS to be greater than or equal to FcgidMaxRequestsPerProcess to prevent the php-cgi process from exiting before processing all requests

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000

# Php-cgi maximum number of requests for each process

FcgidMaxRequestsPerProcess 1000

# Maximum number of php-cgi Processes

FcgidMaxProcesses 5

# Maximum execution time

FcgidIOTimeout 120

FcgidIdleTimeout 120

# Php-cgi path

FcgidWrapper "c:/wamp/bin/php/php5.6.2/php-cgi.exe". php

AddType application/x-httpd-php. php


Actual test

1) Put the zsgetdcmimage. dll extension compiled using the PHP skeleton to the php5.6.2 \ ext directory.

2) create a php test file in the wamp \ www directory, test. php

Enter localhost \ test. php In the browser

The output is as follows:

So far, the change of the PHP version in the WampServer installation package has been successfully completed. After several attempts, we have successfully built the Basic Environment for web pacs development with three blog posts. In the future, we will introduce how to use the PHP extension skeleton and dcmtk to implement various web pacs functions.

Follow-up blog posts:

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


Time: 2014-10-31

Who can tell me the details of PACS, and what is WEB-PACS? What are the similarities and differences between the two? It is best to have more details.

PACS is short for Picture Archiving and Communication Systems, which means image Archiving and Communication Systems. PACS is a multimedia DBMS system involving radiology, imaging medicine, digital image technology (acquisition and processing), computer and communication, and C/S architecture, it involves software engineering, image synthesis, post-processing, and other technologies. It is a high-tech and complex system with high technical content and strong practicality.
PACS is used in hospital imaging departments. It was initially used in radiology. After years of development, PACS has been used to store and communicate images between several simple radiology imaging devices, extended to the mutual operation between all hospital imaging devices and even different hospital images, so there are many classification methods. For example, the networking of several radiology devices is called Mini PACS ); iot Radiology PACS (Radiology department pacs) for all imaging equipment in Radiology department; integrated Hospital PACS, which shares the image resources of the whole Hospital. The degree of integration between PACS and RIS and HIS has become an important criterion for measuring whether the function is powerful or not. The future of PACS will be the formation of regional PACS. It will build a regional and cross-regional Wide Area Network (PACS) to achieve the network of medical images in the whole society. Since PACS needs to be connected to all the hospital's imaging equipment, a unified communication standard must be established to ensure that the imaging equipment of different manufacturers can be connected. Therefore, in 1983, the North American radiology Society (ACR) the ACR-NEMA digital imaging and Communication Standards Committee was established under the initiative. In response to the initiative, many manufacturers have agreed to adopt common interface standards in the medical radiation devices produced so that different manufacturers can exchange image data with each other. The ACR/NEMA1.0 standard version was released on April 9,. On April 9, the standard was revised again. On April 9, the third version of ACR/SCN was officially renamed DICOM3.0 (Digital lmaging and Communication in Medicine ), it can be translated into "medical digital images and communication standards ". DICOM3.0 has been widely followed by international medical imaging equipment manufacturers, and all produced photo and video devices provide DICOM3.0 standard communication protocols. Image devices that comply with this standard can communicate with each other and can communicate with other network communication devices. The DICOM3.0 standard must be supported for system output and input. This has become an international specification for PACS. Only the PACS established under the DICOM3.0 standard can provide users with the best system connection and expansion functions.
PACS is collectively referred to, while WEB-PACS is also called based on its technology. With WEB technology, clients do not need to install any programs. They only need to install ie browsers. They can be used for mobile office and can be deployed in any corner of the world. The true embodiment of "PACS is not only a product, but also a complex information engineering" concept. For example, WEB-VIDIPACS is developed by providing.com using WEB technology, B/S architecture of the PACS system. For details, visit the website of providing.com.
WEB-PACS is a type of PACS, so its usage is the same. The difference is that the environment is different. Generally, PACS uses the C/S architecture, while WEB-PACS uses the B/S architecture. Clients do not need to install any programs. They only need to install ie browsers and can be used for mobile office.
Reference: baike.baidu.com/view/4105683.htm

Where can I download the DICOM Development Kit (SDK? As mentioned above

[System/software/source code/control] DICOM Development Kit (SDK) DICOM is the abbreviation of Digital Imaging and Communications in Medicine, that is, medical Digital Imaging and communication standards. Is ACR (American College of Radiology, American Radiology Society) and National Electrical Manufactorers Association (American National Electronics Manufacturers Association) mainly developed standards for digital medical image transfer, display and storage. The DICOM Standard defines the composition format and exchange method of the image and its related information in detail, you can create an interface on an image device to input/output image data. The DICOM standard is based on the industrial standards of computer networks. It helps more effectively transfer and exchange digital images between medical imaging devices, including CT, MR, nuclear medicine, and ultrasound checks, it also includes CR, digital film system, video acquisition system, and HIS/RIS information management system. VIDI-WebPacsSDK includes the complete DICOM server and WebDicomViewer. ocx, allowing you to easily build a PACS system. The WebPacs SDK is applicable to VB, VB. NET, VC ++, DELPHI, C ++ Builder, PB, and WEB development platforms. It has a low investment risk and can quickly establish HTML for PACS systems. Control features: fully complies with DICOM standards, uses DICOM protocol, and the Internet uses the WADO protocol to completely function the PACS system. The WorkLIST feature scans images and converts them to DICOM standard formats. Allows you to connect to other image formats and convert them to DICOM standard formats. You can burn CDs or DVDs. Has the key graph tagging function. Support Store SCP transmission (DICOM file receiving) Support Store SCU transmission (DICOM file sending) Support Query/Retrive Service (DICOM Query retrieval) DICOM Standard Print protocol DicomVCL is a 16-bit image. 3D Reconstruction (volume reproduction, surface rendering, and 3D projection ). Video Capture and conversion to DICOM standard format view all kinds of DICOM Image view BMP, JPG image DICOM, BMP, JPG image window width/window adjustment to DICOM image into BMP, JPG or TIFF images convert BMP and JPG images into DICOM images (grayscale and RGB modes are supported) when converting multiple BMP and JPG images into a multi-frame DICOM image and non-DICOM images into DICOM images, you can set parameters such as patient name and ID to support measurement (length, angle, area) supports image processing functions (reversed color, pseudo color, flip, denoising, sharpening, etc) view multiple DICOM images, play videos, and distribute multiple DICOM images (tiled multiple images) multi-frame DICOM images can be directly converted to AVI video files to provide Image stream output (images can be directly placed into the Image control). controls can be placed into the HTML webpage WebDicomViewer, allows you to access DICOM standard images on the Internet. Address: bbs.hc3i.cn/thread-21247-1-13.html

Hope to adopt

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.