The DICOM Image Compression and Patient Data Integration using Run Length and Huffman Encoder

Maintaining human healthcare is one of the biggest challenges that most of the increasing population in Asian countries are facing today. There is an unrelenting need in our medical community to develop applications that are low on cost, with high compression, as huge number of patient’s data and images need to be transmitted over the network to be reviewed by the physicians for diagnostic purpose. This implemented work represents discrete wavelet-based threshold approach. Using this approach by applying N-level decomposition on 2D wavelet types like Biorthogonal, Haar, Daubechies, Coiflets, Symlets, Reverse Biorthogonal, and Discrete Meyer, various levels of wavelet coefficients are obtained. The lossless hybrid encoding algorithm, which combines run-length encoder and Huffman encoder, has been used for compression and decompression purpose. This work is proposed to examine the efficiency of different wavelet types and to determine the best. The objective of this research work is to improve compression ratio and compression gain.


Introduction
Digital technology has, in the last few decades, entered in almost every aspect of medicine. There has been a huge development in noninvasive medical imaging equipment. Since there are multiple medical equipment manufacturers, there is a strong need to develop a standard for storage and exchange of medical images. DICOM (Digital Imaging and Communications in Medicine) makes medical image exchange easier and independent of the imaging equipment manufacturer. The DICOM standard has been developed by ACR-NEMA to meet the needs of manufacturers and users of medical imaging equipment for interconnection of devices on standard networks. The DICOM technology is suitable when sending images between different departments within hospitals and/or other hospitals and the consultant. DICOM file contains both a header, which include text information such as patient's name, modality, image size, etc., and image data in the same file. Hence DICOM standards are widely used in the integration of digital imaging systems in medicine. Figure 1 shows the structure of DICOM image file. It has two main components. The first is header; it consists of 128 bytes of file preamble which is followed by string by 4-byte prefix, and it contains four-character string. The second is data set; it consists of multiple set of data elements. Each data element has four fields; these are tag, value representation, value length, and value field. The third is image pixel intensity data; it contains necessary medical image data display like number of frames, lines, columns, etc.

File format used by DICOM images
There are four major file formats in medical imaging, and they are Neuroimaging Informatics Technology Initiative (NIfTI), Analyze, DICOM, and MINC. The task of the image file format is to provide a standardized way to store the unique data in a much organized and systematic manner and showcase how the pixel data understood the correct loading, visualization, and analysis was derived by the software. The major file format currently useful in medical imaging is DICOM format. The DICOM format includes some information that can be useful for image registration, such as position and orientation of the image with respect to the data acquisition device and patient information with respect to voxel size. DICOM file format design consideration is based on the following concept such as pixel depth, photometric interpretation, metadata, and pixel data. The DICOM file format is created by addition of header size and pixel data. Mathematical equations are as follows:  The more popular formats used in daily practice are the JPEG, JPEG 2000, TIFF, GIF, PNG, and BMP formats. The images saved in these formats can be accessed on any personal computer without the need of specific viewers. File format are designed with the help of image conversion technique and coding schemes.
The rest of the chapter is organized as follows. Section 2 provides an overview of image file format and image standard used for medical image compression, and data hiding methods are described in the Section 3. Section 4 provides proposed work brief explanation. Section 5 discusses regarding results that are obtained after implementation of application. Finally, Section 6 concludes the chapter.

Related work
The related work is a comprehensive summery of previous research on image file format, standard image compression using transform coding, and patient information integration into image for DICOM images. The more popular formats used in daily practice are the JPEG, JPEG 2000, TIFF, GIF, PNG, and BMP formats. The images saved in these formats can be accessed on any personal computer without the need of specific viewers. File formats are designed with the help of image conversion technique and coding schemes [1][2][3]. Figure 2 shows the basic digital image file formats and its classification. The vector images are not commonly used in medical data processing. Table 1 gives the summary of various parameters of raster image file format [4,5,[7][8][9][10][11]. Table 2 gives a characteristic overview of the major file formats currently used in medical imaging, i.e., NIfTI, Analyze, DICOM, and MINC [6,12,13].
Two types of compression methods are classified. The lossless image has huge application in archival of medical and digital radiography document, where loss of information in original image could consider improper diagnosis. The medical imaging application required lossless image compression. Thus, medical image compression application development is a challenging problem. The survey paper [14] conveys that compression ratio 4:1 is possible using lossless compression. An increasing volume of data generated by new imaging modality, CT scan and MRI lossy compression technique are used to decrease the cost of storage and increase the efficiency of transmission over networks for teleradiology application [12]. There are two main categories of compression lossless (reversible) and lossy (irreversible). DICOM support lossless compression schemes like run-length encoding, Huffman coding, LZW coding, area coding, and arithmetic coding. The RLE is used for medical image compression in hybrid approach, where gray scale value gives certain interesting fact about the distribution in image. The background pixels of all the medical image are low values, and they differ by +3 or À3. The RLE is based on dynamic array implementation, no need to process whole image [8]. The paper served that the number of repeated zero count which is represented as "RUN" and appends the nonzero coefficients represented as "LEVEL" [15,16]. The Huffman coding is a lossless compression technique, which is used for medical image compression. This works on variable length encoding principal, which includes calculation of length of unique codes. It generates a binary tree, which is also known as Huffman tree. Huffman algorithm gives higher compression ratio in the case of medical image compression. During the whole process of compression, there should not be any loss of information that will affect proper diagnosis [17,18]. The Huffman code is designed to integrate the lowest probable symbols, and this integration is repeated until only two probabilities of two symbols are left. In this survey paper, certain improvements are discussed on the existing Huffman technique which will help to preserve any loss of information during compression that will affect proper diagnosis [19]. In lossy compression method, data are rejected during compression and cannot be recovered completely. This method reaches much greater compression performance than lossless compression. Wavelet and higher-level JPEG are the example of lossy compression technique where JPEG 2000 is a progressive lossless-to-lossy compression algorithm [20][21][22]. This article uses the concept of data hiding into image for data encryption. In order to enable large capacity of data hiding and maintaining good image quality, the data integration is applied on detail coefficients of high-frequency sub-bands. It works on transform domain of multilevel two-dimensional discrete wavelet transform. The objective of this implementation is to perform image compression as much as possible. It will help to reduce the redundancy of the image and to store or transmit data in an efficient form. As in telemedicine, the medical images are transmitted through advanced hyperlinks; medical image compression without any loss of useful information is of immense importance for the fast transfer of the medical data [23].

Proposed work
This proposed compression approach deals with .dcm file of DICOM format. It splits .dcm file into patient data with bmp.txt extension and gray scale image with . bmp extension. Then N-level DWT using various wavelet types is applied to a gray image. Firstly, this splits the image into n number of high-frequency sub-bands (HLn, LHn, HHn) where n = 1, 2, 3 … ..N and one low-frequency sub-band (LLn) where n = maximum level (N). The high-frequency sub-bands at levels 1, 2, 3, and 4 are threshold and quantized and find detail coefficients are encoded directly through run-length encoding. Secondly, the one low-frequency sub-band is also threshold and quantized and find high-level approximate coefficient. Lastly, both the coefficients (detail coefficients, high-level approximate coefficient) are encoded by Huffman coding.
In a gray scale image, each pixel is represented by 8-bit unsigned integer value. The minimum and maximum value of unsigned integer is 0 to 255. The 0 represented black and 255 represent white. In text file every text file is represented by ASCII value. The ASCII value is run between 0 and 128. The extended ASCII value is 8 bit, and it matched with 8-bit pixel intensity. So, both the entities are treated as normal integer. In this proposed system, we have practiced bitwise XOR approach for text integration into image. The proposed work deals ASCII conversion of patient data and multilevel two-dimensional discrete wavelet transform. Advantages of this work are high data integrity even with large patient data. Accepted levels of imperceptibility, excellent PSNR values, and high CR and good payload capacity are obtained. Figures 3 and 4 represented the block diagram of compression and decompression with data integration scheme. The decompression process is the inverse process of DICOM image compression as shown in block diagram in Figure 4. The DICOM compressed image is recreated with acceptable quality through the abovementioned process.

Multilevel 2D DWT decomposition on wavelet types
We implement an N-level 2D DWT decomposition. At each level of decomposition, the LL sub-band from the previous level is obtained, and each previous level is replaced with four new sub-bands. Each new sub-band is half the width and half the height of the LL sub-band from its parent sub-bands. The formula to calculate the total number of sub-bands depends on the number of level n. The number of sub-bands is therefore 3n + 1, where HHn represent high-frequency band, LLn is low-frequency band, and LHn and HLn are middle-frequency bands. The coefficients in LL are dominant. If any of the coefficients in LLn frequency band are changed, observer can observe that the corresponding spatial domain image has been modified. Figure 5 shows the process of character integration in LHn sub-band, and it generates wavelet coefficients. It shows the scale and orientation selectivity of the DWT. Greatest energy is contained in the LLn sub-band, and the least energy is in the HHn sub-band. The HLn sub-band contains the vertical edges, and the LHn subband contains the horizontal edges. In this proposed work, we focus on data integration in LHn sub-bands because this band has high energy distribution as compared to other bands like HLn and HHn. The finest wavelet type and the appropriate coefficient selection method using threshold and quantization.

Thresholding
Let n Â n be matrix of an original image; noise observation can be written as s ¼ x þ n, where s = noise observation, x = original image, and n = noise. Let s (i), x(i), and n(i) denote ith sample of pixels. By applying discrete wavelet transform, the observed noised image obtained wavelet coefficients y = θ + z, where y = Ws, θ = Wx, and z = Wn, respectively. To recover θ and y, y is transformed into wavelet domain that decomposes y into many sub-bands [19,20]. Then the coefficients with small value in the sub-bands are dominated by noise, thus replacing noise coefficients by zero. It is denoted by where y (i) is the input and noise wavelet coefficients, λ is the Threshold Valu, d y i ð Þ is the Threshold output. We define the PCDZ parameter; this parameter is required to calculate the percentage of nonzero DWT coefficients.
where NBz = number of zeros in DWT coefficients. Ly = Number of Coefficients in DWT. The proposed method used in the global threshold value that is derived by Donoho [19,20] is given by the equation below. It is known to have a universal threshold.
where Ly is the number of pixels in the medical image and σ is the noise variance.

DWT coefficient quantization
The quantization of each level permits to collect the set of nearest values. The uniform quantization on thresholded DWT coefficients in sub-bands will be transformed and to be contained in the interval width for quantization is between 0 to 2 Q . The quantized matrix will be computed as follows: to choose the quantization value Q (Q represents the interval width for quantization of the DWT coefficients in sub-bands), further determine the max(y(i)) and min(y(i)) values of the DWT coefficients which will represent as DWTmax and DWTmin. The uniform quantization on the resulting DWT coefficient sub-bands is formulated by the following equation:

Encoding of wavelet coefficients using run-length encoder and Huffman encoder
In this implementation, hierarchical relationship of wavelet structure is explored to arrange wavelet coefficients into odd rows and even rows. The wavelet coefficients odd rows contain an ordering of wavelet coefficient that acts as approximate (smooth) value, and even rows contain different sign data that act as detail values. After evaluated many zeros in different orders of wavelets, by applying hard thresholding condition Eqs. (4), (5) on wavelet coefficients. In this whole process, separated approximate coefficients contain best information, while detail coefficients contain information like shapes and edges of image. The threshold condition chooses fixed threshold value to obtain desired quality of reconstructed image. After classifying threshold coefficients, need to transmit those coefficients using lossless method which will further be used for decompression purpose. Now encoded detail coefficients with run-length encoding excluding the highest approximate coefficient LL3 sub-bands, because LL3 sub-band does not have much long run of zeros. To convert repetitive data into bit stream, Huffman encoder has been used in this implementation. Huffman code is an example of optimum prefix code; these codes are generated using variable code length where a number of bits are essential. This will be helpful in average code length calculations, and thus the data compression is taking place where sometimes compressed image is smaller than original image.

Results and discussion
The performances of implemented method are based on few essential criteria: the obtained compression ratio (CR), compression gain, and the quality of the reconstructed image using PSNR, MSE (mean squared error), and SNR. Data compression equations are given below.
Data compression ratio = Uncompressed size/Compressed size Space saving (%) determines performance of transformation efficiency over storage of data bits for original bit size to unprocessed bit size. It is like compression ratio; however it reflects percentage of how much data space is saved following compression [21]. It is given by the following equation: Percentage of Compression Gain = 1 -Compressed size/Uncompressed Size The calculated peak signal to noise ratio between maximum values is power of signal and power of distorting noise which affects the quality of its representation. The PSNR is generally expressed in terms of logarithmic decibel scale [22].
MAX f is the maximum signal value which exists in the original image, which is known to be good value of image?
where the MSE where f is the matrix data of our original image. g is the matrix data of our degraded image. m is the numbers of rows of pixels of the images. i is the index of that row. n is the number of columns of pixels of the image. j is the index of that column.
where SNR is given as the ratio of the mean value of the signal and the standard deviation of the noise.
To analyze the performance of our proposed method, we take Table 3 as an input MR image for evaluation of various parameters, and their information are as follows:  Figure 6 shows that pop-up message is generated after compression of DICOM input image, and it displayed warning dialog that image is compressed successfully, and then after pressing the ok button, compressed image is stored in image folder with. Hdwt extension (Figure 7).      DWT gives higher compression ratio, and Discrete Meyer DWT and Reverse Biorthogonal DWT give lower compression size. N = 4 gives better compression ratio (15:1 for Biorthogonal DWT and 10:1 Daubechies DWT) than N = 3.
In Figure 10, figure graph shows comparison of compression gain when decomposition level is 3 or 4 for various wavelet types where size of input MRI is 522 KB. Biorthogonal DWT gives higher compression gain, and Discrete Meyer DWT and Reverse Biorthogonal DWT give lower compression gain. N = 4 gives better compression gain (93.6781% for Biorthogonal DWT and 90.6130% for Daubechies DWT) than N = 3 ( Figure 11). Table 4 shows comparison of image quality parameters when application run at decomposition levels 3 and 4 for various wavelet types where size of input MRI is 522 KB. Daubechies DWT gives higher PSNR (42.0998db) where MSE is (35.2626db) and SNR is (28.3993 db). So, picture quality is good for N = 3. When we consider N = 4 decomposition level, we can choose Daubechies DWT for

Conclusions
Compression and decompression are necessary tasks in medical imaging applications. This implementation provides patient data integration within the medical image. It is very important to maintain the patient data security. This implementation work is very helpful to hide and recover patient information within the medical image and follow compression/decompression without any data loss. In this implanted work, 2D DWT and N-level decomposition are applied on medical image, and then the extracted detail coefficients are firstly encoded by RLE. Secondly, the extracted approximate coefficient and encoded detailed coefficients are encoded by Huffman encoder. The generated result shown that Biorthogonal DWT gives better compression size, compression ratio, and compression gain for higher decomposition level (N = 4), but image quality parameters like PSNR and MSE are degraded. After comparison with JPEG file format and implemented work, this work gives less compression size. We conclude that for medical image compression, we can select N = 3, decomposition level with λ = 3, threshold value, and Biorthogonal DWT for good image quality. 10 CT110 512 Â 512 24 4616 769 61 68 Table 7.
Comparison of implemented method and .JPG format for 10 CT scan DICOM images.