95 CHAPTER 5 A NEAR-LOSSLESS RUN-LENGTH CODER 5.1 GENERAL Ru-legth codig is a lossless image compressio techique, which produces modest compressio ratios. Oe way of icreasig the compressio ratio of a ru-legth coder simultaeously maitaiig high image quality is to develop a ear-lossless approach. I this Chapter, a ovel, ear-lossless ru-legth coder is explaied. 5.2 LOSSLESS RUN-LENGTH CODER I ru-legth codig, the term ru-legth represets the umber of cosecutive pixels of the same gray level i a row vector or colum vector. I a covetioal ru-legth ecoder (RLE), the ru-legth ad the correspodig pixel values are ecoded. Whe the RLE uses row wise correlatio, it is referred to as the 1-D RLE. The 1-D ru-legth codig is the stadard compressio method used i Fax machies. If there is a log ru of zeros ad oes, the ru-legth coder achieves very high compressio ratios. This coditio always occurs for documets which have a black text prited o a white backgroud. 5.2.1 1-D RLE I this method, each sca lie is ecoded idepedetly. Cosider a biary image, ad let r deote the ru-legth i the biary image. All the
96 possible ru-legths together form a source alphabet, R L, which is a radom variable (Jai 1989). R L = r, { r: 0,1,2...} (5.1) Let P w (r) represets the probability of a white ru-legth, ad r w represet the average white ru legth of m white ru-legths. The r w ca be writte as, m r rp (r) (5.2) w r=0 w The etropy of the white rus is give by, m H P ( r)log P ( r ) (5.3) w w 2 w r 0 Similarly the etropy of the black rus, H B also ca be defied. Usig these values, the maximum theoretical compressio factor, Z max for a biary ru-legth coder is expressed as, Z max r H w W rb H B (5.4) 5.2.2 Ru-Legth Codig i Images Ru-legth codig ca be used for the compressio of gray level images also, provided there is a large ru of similar gray levels. Such a situatio happes for medical images, which geerally have a large backgroud of similar gray levels ad a small object regio. The ru legth ecodig algorithm ca be used to compress these images with a good compressio ratio.
97 5.2.3 Compressio Factor for Images Let P (r) represet the probability of the th gray level i the image with the ru-legth, r. The the average ru-legth of the th gray level ad the etropy of the th gray level H are give by Equatios (5.5) ad (5.6) respectively (Jai 1989). r m r rp (r) (5.5) r=0 m H =- P (r)log P (r) (5.6) 2 r=0 The theoretical maximum compressio factor, Z max is defied as, Z max i 1 i 1 r H (5.7) I geeral, RLEs are less preferred for direct image compressio, due to the expasive ature of the two arrays used i ecodig. The first array stores the gray levels ad the secod array stores the ru legths of each gray level. With this arragemet, the ru-legth ecoder produces egative compressio for certai images. A probable solutio is to reduce the size of the array used for storig the ru-legths. This problem is addressed i this work by desigig a ear-lossless ru-legth ecoder (NLRLE). 5.3 NEAR-LOSSLESS RUN-LENGTH ENCODER Ru-legth codig is efficiet for images which cotai repeatig patters of pixels. Eve though atural images do ot cotai repeatig patters, a ispectio of the grey level values of a medical image reveals
98 certai iterestig facts about their distributio. The backgroud pixels of most medical images are of low values ad fall i the rage of 0-3, which makes the maximum differece i the pixel values as ±3. The quatisatio of these values results i a icrease i the correlatio of pixels i the backgroud regio. The overall effect is that the backgroud is trasformed ito a regio with repeatig patters. The secod issue i the stadard RLE is the size of the array used for storig the ru-legths. This array is geerally expasive, due to the presece of a large umber of pixels, which have ru-legths of less tha three. If the small value ru-legths ca be stored elsewhere, the the size of the ru-legth array ca be sigificatly reduced. These two issues are cosidered while desigig the NLRLE. First, the repeatig patters are made available i the backgroud through a visual quatisatio techique ad the bit plae slicig method. A ew approach for reducig the size of the ru-legth array is itroduced by storig the small ru-legths i the bit plaes, at the expese of makig the algorithm ito a ear-loss less oe. The objective is to icrease the compressio ratio of the ru-legth coder, by modifyig the stadard lossless algorithm ito a earlossless oe. Figure 5.1 shows the block diagram of the NLRLE. I the NLRLE, the image is iitially subjected to bit plae slicig ad the visual quatisatio with MAE set to two. The visual quatisatio operatio clears the LSB0 ad LSB1 bits of the image. Afterwards, the image is ecoded usig the stadard RLE, ad the ru-legth values less tha three are idetified. These ru-legths are stored i the LSB0 ad LSB1 bits of the correspodig pixel i a biary form. This arragemet cosiderably reduces the size of the array used for storig the ru-legths.
99 Origial Image Bit plae Slicig Bit plae Quatisatio Rulegth Ecoder Ecoded Image Etropy Ecoder Bit plae Modificatio Ru-legth Search (a) Near-lossless Ecoder Ecoded Image Etropy Decoder Ru-legth Extractio Decoded Image Ru-legth Decoder Modify Ru-legth Array (b) Near-lossless Decoder Figure 5.1 Near-lossless Ru-legth coder The ecodig algorithm cosists of 7 steps which are give below:- Step 1: Decompose the origial image ito bit plaes usig the bit plae slicig techique. Step 2: Clear the bit plaes 0 ad 1. Step 3: Assemble the bit plaes back to form the image. Step 4: Ecode the visually quatised image, usig the stadard RLE. Step 5: Search the ru legth array for ru legths of value 1, 2 ad 3.
100 Step 6: Store the specified ru legth value i the LSB0 ad LSB1 of the correspodig pixel value Step 7: Apply Huffma codig ad geerate the compressed bit stream. 5.3.1 Bit Plae Slicig Bit plae slicig or bit plae decompositio is a spatial domai techique, which is geerally used to decompose a image ito a series of biary images. A give N- bit image is separated ito N biary matrices, where each matrix is called as a bit plae. The bit plae 0 is geerated by collectig the LSB0 bits of all the pixels ad the bit plae 1 is geerated by collectig the LSB1 bits of all the pixels ad so o. A eight-bit image ca represeted i a polyomial form as, x 7 2 7 + x 6 2 6 ++ x 5 2 5 + x 4 2 4 + x 3 2 3 + x 2 2 2 + x 1 2 1 + x 0 2 0 (5.8) The image is decomposed by separatig the eight coefficiets of the polyomial (x 7 to x 0 ) ito eight 1- bit plaes. Figure 5.2 shows the bit plaes of a 8-bit image (Gozalez & Woods 2002). Figure 5.2 Bit plaes of a 8-bit image
101 5.3.2 Bit Plae Quatisatio The geeral objective of ay quatisatio process is to miimise the mea square error betwee the origial ad the quatised image ad ot to miimise the umber of bits per pixel. However, i visual quatisatio, the objective is to miimise the umber of bits per pixel. The visual quatisatio is a grey scale quatisatio techique where, istead of the stadard 8 bits represetatio, a reduced umber of bits per pixel are used. The effect of usig less umber of bits per pixel is the formatio of costat grey level regios. The boudaries of these costat grey level regios are called cotours. Oe scheme suggested for reducig the effect of the cotours is cotrast quatisatio. Cotrast quatisatio is based o the observatio that the huma visio is ot sesitive to chages i the cotrast below a certai level. There are various defiitios of cotrast. A o-liear defiitio of cotrast (C) is give i Equatio (5.9). C= l (1+ u) 0 u 1 (5.9) where ad are costats, ad u is the ormalised lumiace value of the image. It has bee show previously through experimets (Jai, 1989) that, a 2% chage i the cotrast is just perceptible ad this requiremet is equivalet to at least 50 cotrast levels or about 6 bits per pixel. Thus, if the pixels of a image are represeted usig at least 6 bits, the image becomes visually quatised. For further validatio of this observatio, the eight bit Lea image is separated ito eight bit plaes usig the bit plae slicig techique. The bit plaes are show i Figures 5.3(a) to 5.3(h).
102 (a) Bit plae 7 (b) Bit plae 6 (c) Bit plae 5 (d) Bit plae 4 (e) Bit plae 3 (f) Bit plae 2 (g) Bit plae 1 (h) Bit plae 0 Figure 5.3 Bit plae slicig of the Lea image
103 It ca be iferred from Figure 5.3 that bit plaes 0 ad 1 do ot cotai ay visible iformatio. After the bit plae decompositio, the iformatio i the bit plaes 0 ad 1 is cleared which represets the LSB0 ad LSB1 values of the pixel respectively. The bit plaes are cleared by shiftig the pixel values to the right by two bits, ad agai shiftig to the left by two bits. The removal of the iformatio from the two LSB bits is equivalet to represetig the pixels usig 6 bits. This techique is called as bit plae quatisatio. 5.3.3 Ru-legth Search ad Bit Plae Modificatio Oce the image is ecoded usig the RLE algorithm, the ext step is to fid the ru-legths with values 1, 2 ad 3. The ru-legth array is searched to fid the ru-legths less tha or equal to three. If a matchig ru-legth is foud, the the correspodig biary value is etered ito the bit plae of the correspodig pixel. For example, if the ru-legth is 2, the biary value etered i the bit plae is 10. Oce the ru-legth is etered ito the bit plaes, the etry is removed from the ru-legth array. Durig decodig, the LSB0 ad LSB1 bit plaes are scaed oe by oe to check for possible ru-legth etries. A zero etry i the bit plae is skipped, ad the ext pixel is examied. If the ru-legths are preset, they are removed from the bit plaes ad put back ito the ru-legth array of the decoder. This process is repeated till the ed of the array to extract all rulegths. The RLE decodig operatio is performed to retrieve the pixel values ad form the decompressed image. 5.4 SIMULATION RESULTS AND DISCUSSIONS The performace of the NLRLE is evaluated by usig medical images of differet modalities ad sizes. The CT brai image dataset cotaiig 60 Sagittal slices of size 256 x 256 is used. Other datasets used are
104 the MRI brai image dataset with 100 slices, ad a CT abdome dataset cotaiig 30 slices. The slices from the test data set are compressed usig the earlossless coder ad the bit rates are calculated. The bit rates are also calculated for the stadard lossless RLE. Sice the objective is to icrease the compressio ratio of the stadard RLE, all the comparisos are made oly with the stadard lossless RLE. The bit rates ad the PSNR obtaied for various medical images are show i Table 5.1, alog with the average bit rate. The maximum bit rate improvemet is observed for the CT head images. The bit rate depeds o the frequecy cotet ad smoothess of the image. Compared to CT image, MRI images cotai more detail ad have higher frequecy iformatio. Table 5.1 Bit rate compariso for various medical images Average Reductio Average Image No. of Bit rate i the bit Average Size Bit rate Type images (Std rate PSNR (NLRLE) RLE) ( %) CT Head 256 x 256 60 4 2.1 47.5 37.5 MRI Brai 256 x 256 100 6.2 4.4 29.0 40.5 CT Abdome 256 x 256 30 1.7 1.5 11.7 51.4 Average 3.96 2.66 32.82 43.1 5.5 PERFORMANCE COMPARISON OF THE NEAR-LOSSLESS CODERS A comparative aalysis of their performace for medical images is give i Table 5.2. It is clearly see from the results that, the ewly itroduced LTNLIC shows superior performace tha the other two.
105 Table 5.2 Performace compariso of the ear-lossless coders (MAE=3) Image VQ-DPCM LTNLIC NLRLE bpp PSNR bpp PSNR bpp PSNR CT- 017 0.87 37.8 1.1 45.6 2.04 37.7 CT-77 1.28 37.8 1.5 46.6 4.04 37.8 CT-88 0.88 36.7 1.1 47.1 2.39 36.7 MR-10 0.84 38.4 0.9 50.1 3.27 38.4 MR-19 1.0 38.4 1.1 48.8 3.71 38.4 MR-66 1.26 38.4 1.38 47.6 4.4 38.4 5.6 CONCLUSION A ovel NLRLE coder is explaied i this Chapter. The lossless RLE is modified to desig a ear-lossless RLE by usig the bit plae slicig ad bit plae ecodig techiques. The NLRLE is used to compress the CT ad the MRI volumetric images, ad the results are preseted. Sice the method is ear-lossless, the quality of the compressed image is kow before the ecodig process itself. The proposed method outperforms the stadard RLE with a 33% average reductio i the bit rate with high visual quality. Aother advatage of the method is that, the whole image is ot required for processig. A dyamic array is sufficiet to do the ecodig. This is i cotrast to the trasform-based techiques, especially wavelet-based techiques, where the whole image is brought to the memory, ad the trasform is applied to the etire image. Due to this, the NLRLE coder is a good choice for real-time applicatios, ad trasmissio of the 3-D medical iformatio over the Iteret.