74 CHAPTER 4 REVERSIBLE IMAGE WATERMARKING USING BIT PLANE CODING AND LIFTING WAVELET TRANSFORM Many data embedding methods use procedures that in which the original image is distorted by quite a small amount of noise due to data embedding itself. This distortion cannot be removed completely due to quantization, bit-replacement, or truncation at the grayscale ends. Even though the distortion is often quite small, it may not be acceptable for medical imaging for legal reasons or for military images inspected under altered viewing conditions like filtering or zooming. In this paper, we introduce an approach for high-capacity data embedding that is lossless without any distortion. After the embedded information is extracted from the stego-image, we can revert to the exact copy of the original image before the embedding occurred. The new method can be used as a powerful tool to achieve a variety of tasks that needs distortion-free image after watermark embedding and extraction of watermarks. The proposed concept can be extended to commonly used image formats. Two techniques proposed by Fridrich et al (2001) is based on robust spatial additive watermarks combined with modulo addition and the second one on lossless compression and encryption of bit-planes The first technique embeds the hash of the whole image as a payload for a robust watermark and the second method for invertible authentication based on
75 lossless compression of bit-planes and encryption is much more transparent for analysis. A high capacity distortionless data embedding method is presented by Goljan et al (2001) which has opened many lossless data embedding methods. A method for reversible data-embedding in digital images using a technique called difference expansion is discussed. Location map is used to locate the marked coefficients. The redundancy in the digital content to achieve reversibility is used. The payload capacity limit and the visual quality of embedded image are considered (Tian 2002). Reversible data hiding method, in which the watermarked image can be reversed to the original cover media exactly, has attracted increasing interests from the data hiding community. The existing reversible data hiding algorithms, have been classified as those developed for fragile authentication, for achieving high data embedding capacity, for semi-fragile authentication. In each category the principles, merits, drawbacks and applications of these algorithms are analyzed and addressed by Ni et al (2006). A reversible Data Hiding method by Xuan is based on wavelet spread spectrum and histogram modification. Using spread spectrum scheme data is embedded in the coefficients of the integer wavelet transform in high frequency bands (Xuan et al 2004). A lossless data hiding method for digital images using IWT and embedding based on threshold is done. Data are embedded into the LSB planes of high frequency integer wavelet coefficients whose magnitude are lesser than a chosen threshold (Xuan et al 2005). Data is embedded in the bit planes of color component of the Integer wavelet transformed image. Bit plane complexity segmentation is used. To estimate the complexity a particular criteria is used and the IWT coefficient areas which can be replaced to maintain imperceptibility is used
76 (Ramani et al 2007).Reversible data Hiding Scheme for binary images is suggested. JPEG2000 compressed data is used and the bit-depth of the quantized coefficients are also embedded in code-blocks (Ohyama et al 2009). 4.1 BIT PLANE CODING In the discussion, eight-bit grayscale images are considered and the least significant bit-planes is denoted as the 1st bit-plane, the most significant bit-plane as the 8th bit-plane. In the commonly used grayscale images the study shows binary 0s and 1s are almost equally distributed in the lower bitplanes. The bias between 0s and 1s starts gradually increasing in the higher bit-planes. This kind of bias indicates redundancy, implying that we can compress bits in a particular bit-plane or more than one bit-plane to leave space to hide other data like text or image as watermark. Image transforms offer a larger bias between 0s and 1s in the wavelet domain than in the spatial domain. To eliminate more redundancy to embed data and to avoid round-off error, we propose to use the second generation wavelet transform such as IDWT which maps integer to integer. This technique is based on the lifting scheme. 4.1.1 Bit-plane Embedding Using Arithmetic Coding Today's multimedia applications require generally more than simple and good compression performance. Algorithms needed for compression are application dependent. Sometimes time and sometimes space is considered critical. Also the amounts of compression done for a given quality with tolerable quality measures are important. The algorithms which aim to meet these new requirements are called coding algorithms. The primary goal of a coding algorithm is obviously compression. It aims to minimize the number of bits required to represent the original data.
77 It may be lossy compression or lossless compression. Depending on the requirement of the application, the coded representation must enable a perfect reconstruction as in the case of lossless coding, or it can tolerate some loss in order to obtain much higher compression ratio as in the case of lossy coding. The methods developed for image compression are generally done by removing three redundancy types: Visual redundancy: The accuracy of the human visual system is not infinite and it is possible to remove some details or reduce pixel precision by quantization, without affecting the perceived quality of the image. Spatial redundancy: an image generally contains uniform regions of pixels or regular patterns that can be efficiently represented with very few symbols by prediction or by changing it to a specific transform domain. Statistical redundancy: when the distribution of symbols is not uniform and some symbols appear more often than others, it is generally possible to find an appropriate coding that will reduce the overall data length. This is called entropy coding. For the bit plane coding algorithm, lossless arithmetic coding is used. 4.2 ARITHMETIC CODING The most common lossless statistical compression methods are Huffman coding and Arithmetic coding. Huffman coding utilizes a static table to represent all the characters and their frequencies and then generates a code table accordingly. More frequent characters will be assigned shorter code so that the source can be effectively compressed. Arithmetic coding works slightly differently from Huffman. It also uses a statistical table for coding similar to Huffman, but this table is adaptive and it is modified from
78 time to time to reflect the real time distribution statistics. Whenever a new character is being processed, the table will re-calculate frequencies until the end of the text stream. Huffman uses a static table for the whole coding process and it is fast, but does not produce an efficient compression ratio. Arithmetic coding can generate a high compression ratio, but all the complex calculation takes much more time, resulting in a slower implementation. The table 4.1 presents a comparison between these compression methods. Table 4.1 Comparison between Arithmetic Coding and Huffman Coding Compression Method Arithmetic Coding Compression Ratio Very Good Fair Compression Speed Slow Fast Decompression Speed Slow Fast Memory Space Very Less More Huffman Coding An ideal compression method should satisfy all those features given in the table above. Although arithmetic coding is not the best in every category, it does result in the highest compression ratio. Binary Arithmetic Coding : The Binary Arithmetic Coding approach specified in the JBIG standard can be used for coding gray scale images via bit plane encoding. In bit plane encoding we combine the most significant bits for each pixel into one bit plane, the next most significant bits into another bit plane and so on till the least significant bit plane.
79 The least significant bits of the grayscale image form plane 0 and the most significant bits of the gray scale image values form bit plane 7. Mostly the five highest order planes contain visually significant data. The other lower bit planes contain subtle details in the image. The occurrence of zeroes and ones in the image statistically shows equal distribution of zeroes and ones in the lower planes than in the higher planes. This leads to lower compression ratio and lower embedding capacity in the lower bit planes than in the higher planes. This is because a binary sequence of length L and probability of P (0) = 0.9 may be encoded more compactly than another one of the same length with P(0) = 0.5 But the signal to noise ratio drops down as we alter the higher bit planes more for embedding. The goal is to obtain a representation, where few coefficients are sufficient for reconstructing the image with a good quality. The precision of transformed coefficients is generally reduced by quantization in order to make them more compressible by an entropy coder, which aims to remove statistical redundancies of quantization indices. The compressed representation, called code stream, is usually obtained by a rate-allocation process that tries to achieve the best trade-off between the compression ratio and the reconstructed image quality. Figure 4.1 Bit Plane arrangement
80 Figure 4.1 illustrates the arrangement of bit planes of an 8 bit gray scale image. All the LSB bits of the pixel values form plane 0 which is the least significant bit plane and all the MSB bits of the pixel values form the most significant bit plane which is bit plane 7. Study has revealed that bias between binary 0s and 1s starting from the 2nd bit- plane of the IDWT coefficients increases than in the spatial domain. The higher the bit-plane, the larger the bias. But alterations made in higher bit-plane will lead to degradation of image quality. In order to have the watermarked image perceptually the same as the original image, we choose to hide data in one or more middle bit planes in the IDWT domain. The approximate coefficients in the LL subband contribute to visual perception. So specifically the LH, HL and HH subbands are used for watermark embedding. In the chosen bit-plane of the middle and high frequency subbands, the arithmetic coding is used to compress losslessly binary 0s and 1s because of its high coding efficiency. 4.3 PROPOSED SCHEME The given image is decomposed into its frequency components using suitable wavelet transform. We have used the integer discrete wavelet transform IDWT and the pixel values are transformed in the forward and reverse directions losslessly. In the proposed scheme the watermarked bits are embedded into bit planes. The original image is preprocessed by performing lifting scheme. Now integer to integer wavelet transform is performed to decompose the image into its components namely, Approximate coefficients, horizontal, vertical coefficients and diagonal coefficients.
81 The horizontal, vertical as well as the diagonal detailed bands are used to embed the watermark. Bit plane of the detailed bands are selected. The original bits in the selected plane are compressed losslessely to create space for embedding the payload bits. The compression exploits the fact that 0 s and 1 s are nonuniformly distributed as we move from least significant bit plane to higher ones After compression necessary headers are generated reflecting the original bit distribution in the chosen plane of the quadrants. 4.3.1 Embedding Process For a given image of size M N in which the gray scale set {0,1,2..255} indicate the pixel values and the wavelet coefficients are represented using eight bits. All the LSBs in a block represent the lowest bit plane, the next significant bits form the next plane and so on till the most significant bits form the most significant plane. Watermark bits are embedded in the chosen bit plane. Let B represent original bits in the chosen plane and CB the compressed bits. Let W be the watermark bits. The structure of the embedded bit plane is, 16 Bits 16 Bits 16 Bits 16 Bits 16 Bits 16 Bits 32 Bits CH Header CV Header CD Header CH Length CV Length CD Length Watermark Length CH, CV, CD headers represent the bit distribution needed for arithmetic encoder and decoder used for compression. CH, CV and CD length represent the length of compressed bit stream in the chosen plane of the LH, HL and HH components. Bit Plane Identification shows (7th 6th 5th 4th 3rd
82 2nd 1st 0th) are the plane identifiers.0th plane represents the least significant plane and 7th plane represents the most significant plane. Original Image Integer Wavelet Decomposition Select H, V & D Components Choose Bit plane(s) of components Approximate coefficients Header Information Watermarked Image Inverse IWT Embedding Algorithm Compression Algorithm Embedded H,V & D Components Compressed Original bits CH, CV, CD Watermark Data Figure 4.2 Embedding Process Figure 4.2 illustrates the embedding algorithm for bit plane coding indicating the process of converting the original image into a watermarked image. The selected subbands of the wavelet transformed image are taken and the chosen bit planes are compressed to create space to embed the watermark. The steps in embedding are as follows. 4.3.1.1 Embedding Algorithm 1. I m = Original Image; (A,H,V,D) = IWT (I m ). 2. A Unmarked Approximate coefficients; H,V,D detailed coefficients. 3. Selected bit planes BH, BV and BD 4. Arithmetic coded BH, BV and BD CH,CV and CD 5. Headers headers for encoding and decoding.
83 6. Watermark bit string W. 7. Complex stream W + Headers + CH + CV + CD. 8. EH, EV and ED Embedded H, V and D with Complex stream. 9. Watermarked Image I w IIWT (A, EH,EV, ED). 4.3.2 Extraction Algorithm The integer wavelet transform of the watermarked image is taken to get the embedded H, V and D sub bands and the unmarked approximate coefficients. The header, compressed H, V and D sub bands and the watermark bits are separated. The watermark bits are removed and the planes of the H, V and D sub bands are decompressed to reconstruct the sub bands. Inverse integer transform of the reconstructed H, V and D sub bands is taken after decompression along with the unmarked approximate component to get the original image. The extracted headers are used to reconstruct the original bit plane of the image. Figure 4.3 illustrates the extraction algorithm to extract the embedded watermark and to recover the original image. Watermarked Image Integer Wavelet Decomposition Select H, V & D Components Separate Chosen Bit plane(s) Approximate coefficients Header Information Recovered Image Inverse IWT Decompression Separate original bits &watermark Original H,V & D Components Compressed Original Bits Figure 4.3 Extraction of the watermark data Watermark Data
84 4.4 EXPERIMENTAL RESULTS AND DISCUSSIONS 4.4.1 Watermarked Image Quality Performance measure Watermarking the original image slightly degrades the original images as far as Peak Signal to Noise Ratio (PSNR) is concerned. But it is well within the visual perception and we do not readily visualize the watermark and the degradation. The visual quality of the marked image is measured in PSNR. The Mean Square Error (MSE) indicates the difference between the original image and the watermarked image. Table 4.2 shows the Image Quality of different Gray scale images for each payload. The embedding capacity is image dependent and is also based on the bit distribution of the chosen bit plane. The table shows Lena has better embedding capacity than Baboon and Barbara. Figure 4.4 indicates the comparison of the images for different payloads. Table 4.2 Image Quality Tested for different Gray Scale Images for each Payload using bior 3.3 wavelet Watermark Image Size Payload bpp Lena Baboon Barbara 10 10 0.0003 32.81 28.61 31.28 50 50 0.01 32.78 28.60 31.22 100 100 0.04 32.67 28.57 31.10 150 150 0.09 32.46 28.53 30.74 200 200 0.15 32.10 28.47 30.29 250 250 0.24 31.69 Insufficient 31.01 300 300 0.34 31.28 Insufficient 29.94 350 350 0.47 31.18 Insufficient Insufficient
85 Insufficient - Arithmetic coding is a lossless compression method and though it gives best performance, maximum level of compression for a given bit pattern is fixed. Embedding capacity is based on this factor. Image Quality (PSNR db) 33.5 33 32.5 32 31.5 31 30.5 30 29.5 29 28.5 28 Lena Baboon Barbara 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 Payload (bpp) Figure 4.4 Comparison of embedding Capacity in bpp versus distortion in PSNR for different Grayscale Images Figure 4.4 indicates that embedding capacity of different images is different. Lena image has a better capacity than Barbara and baboon images for this algorithm. Table 4.3 Embedding Capacity of bit plane 3 and bit plane 4 and Signal Quality after embedding. Embedded Bits PSNR db Bit Plane 4 Bit Plane 3 100 34.50 35.18 2500 34.45 35.14 22500 33.92 34.87 40000 34.86 34.72 50625 33.83 34.64 62500 33.07 34.59 90000 32.36 Insufficient 122500 32.13 Insufficient
86 Figure 4.5 Comparison of embedding Capacity and Image Quality in different bit planes. Table 4.3 shows the signal quality for various number of bits embedded in bit plane 4 and bit plane 3. Figure 4.5 shows that the embedding capacity of plane 4 is higher than plane 3. But the image quality drops down as we continue to embed in that plane. Similarly as we move from plane 4 till plane 6 embedding capacity increases at the cost of reduced peak signal to noise ratio. Figure 4.6 illustrates watermarked images in bit plane 4. Table 4.3 shows the embedding capacity of lower bit planes is lesser than the higher bit planes. Experiment is conducted on bit plane 3 and bit plane 4 and the results show bit plane 4 has more embedding capacity but since it is more significant plane, the PSNR is slightly lesser in this plane, than in Plane 3. Figure 4.5 indicates these results.
87 Figure 4.6 a b c d e f Original Image and Watermarked Images in Bit Plane 4. (a)original Image, (b) 30.01 db with 129600 bits (c) 30.36dB with 105625 bits, (d) 30.62 db with 78400 bits, (e) 30.93 db with 55225 bits, f. 31.36 db with 22500 bits
88 Table 4.4 Performance of various wavelets and their Image Quality in PSNR for a fixed payload of 10,000 bits Wavelet Type Images Lena Baboon Barbara PSNR MSE PSNR MSE PSNR MSE coif1 30.81 51.41 29.23 72.27 30.64 59.61 9.7 34.81 20.14 29.70 64.27 32.06 37.28 cdf 2.2 34.92 20.09 29.35 67039 31.83 41.61 db2 31.77 41.52 29.40 63.37 30.85 50.91 sym 2 31.77 41.5 29.40 63.37 30.86 50.91 bior 1.1 32.56 34.09 29.26 64.78 30.88 51.08 bior 3.3 32.87 33.48 28.61 82.67 31.257 46.79 rbio 6.8 34.50 22.162 29.37 71.65 31.98 40.53 bior 6.8 Insufficient Insufficient 30.25 67.67 32.475 41.52 rbio 1.1 Insufficient Insufficient 30.01 54.68 31.873 39.31 rbio 3.3 Insufficient Insufficient 28.65 78.679 31.125 47.84 Table 4.4 shows the performance of different wavelets on Lena, Baboon and Barbara images. The PSNR for the payload of 10000 bits is shown along with the mean square error between the original and the water marked image. Bior 6.8, rbio 1.1 and rbio 3.3 are not able to embed this capacity on Lena image whereas other wavelet decompositions are able to accommodate this capacity. Figure 4.7 shows watermarked Lena images in bitplane 4 for various capacities. Figure 4.8 shows the performance of different wavelets tested on Lena image. 9.7 wavelet and bior 3.3 wavelet has more embedding capacity compared to other wavelet decomposition. Tables 4.5 and 4.6 shows the performance of various wavelet families on Lena image in bitplane 3 and bitplane 4.
89 (a) (b) (c) (d) Figure 4.7 Original and Watermarked Images in Bit Plane 4: (a) Original Image (b) Watermarked with 10,000 bits at- 34.92 db (c) Watermarked with 62,500 bits at PSNR 33.4623dB (d) Watermarked with 122500 bits at PSNR 32.4736dB Image Quality (PSNR db) 36 35 34 33 32 31 30 Coif 1 cdf 2.2 9.7 bior 3.3 rbio 4.4 sym 2 0 0.2 0.4 0.6 0.8 1 Payload (bpp) Figure 4.8 Performance of different wavelets tested on Lena image
90 Table 4.5 Bitplane 4 Lena image -Comparison of performance of various wavelet families on Lena Message Size(bits) bpp Coif 1 cdf 2.2 9.7 bior 3.3 rbio 6.8 sym 2 10x10 0.0003 30.81 34.93 34.81 32.81 34.50 31.78 50x50 0.01 30.79 34.87 34.76 32.78 34.45 31.75 100x100 0.04 30.69 34.69 34.58 32.67 34.73 31.65 150x150 0.09 30.48 34.40 34.28 32.46 33.92 31.45 200x200 0.15 30.25 33.97 33.87 32.10 34.86 31.16 250x250 0.24 30.20 33.46 33.39 31.69 33.07 30.99 300x300 0.34 30.11 32.7999 32.75 31.28 32.36 30.99 350x350 0.47 Insufficient 32.47 32.397 31.18 32.13 Insufficient 400x400 0.61 Insufficient Insufficient 32.11 31.23 Insufficient Insufficient 450x450 0.77 Insufficient Insufficient 31.79 31.46 Insufficient Insufficient Table 4.6 Biplane 3 Lena image -Comparison of performance of various wavelet families on Lena Message Size(bits) bpp Coif 1 cdf 2.2 9.7 bior 3.3 rbio 6.8 10x10 0.003 34.63 36.56 36.05 34.65 35.17 35.55 50x50 0.01 34.63 36.52 36.01 34.63 35.14 35.55 100x100 0.04 34.62 36.39 35.88 34.60 35.04 35.53 150x150 0.085 34.60 36.19 35.72 34.55 34.87 35.51 200x200 0.15 Insufficient 36.02 35.53 34.48 34.72 35.55 sym 2 250x250 0.24 Insufficient 35.96 35.49 34.41 34.60 Insufficient Figure 4.5 illustrates that the embedding capacity of bit plane 3 is lower due to bit distributions in that plane. This is lesser than the capacity of bit plane 4 which is higher but at the cost of slight compromise in watermarked image quality. This can be compared with the watermarked Barbara images shown for plane4 in fig 4.6 and for bitplane 3 in Figure 4.9.
91 Figure 4.9 a b c d e f Original Image and Watermarked Image in Bit Plane 3. (a) Original Image, (b) 34.6479 db with 50625 bits (c) 34.67dB with 40000 bits, (d) 34.7605 db with 22500 bits, (e) 34.8904dB with 10,000 bits, (f) 35.0526dB with 100 bits.
92 4.5 BIT PLANE CODING ALGORITHM WITH IMAGE HASH 4.5.1 Embedding Figure 4.10 shows embedding hash of the image along with watermark for authentication and security. Original Image Wavelet Transform Separate H, V, D, Components Select Bit Plane Arithmetic Coding Water Marked Components Hash Image Hash Embedding Algorithm IDWT Watermarked Image Watermark Figure 4.10 Embedding Process with Image Hash 4.5.2 Extraction Watermarked Image Extraction algorithm Recover Image Compute Hash Computed Hash Watermark Extracted Hash Compare Hash Image Authentication Figure 4.11 Extracting hash of the image to check authenticity
93 4.5.3 Hash output of Images Hash functions are used to generate digest of a given function. It is a one way function that accepts a variable length input and produces a fixed length output. Many functions like MD4, MD5, SHA 256, SHA 384 and SHA 512 may be used to produce a message digest or hash. The hash of the original image using SHA 256 is used and tested for authentication. The embedding and extraction algorithm along with image hash is illustrated in Figures 4.10 and 4.11. After lossless compression of the chosen bit plane of the original image we may construct a stream by augmenting the watermark bit stream and the hash of the original image to the compressed bits of the chosen plane after arithmetic coding. To authenticate the watermarked image against tampering the hash of the image is very useful. If any alteration is done the hash computed at the receiving end does not match with received hash. SHA 256 hash of the original image is used for authentication and testing. SHA 256 hash of the original images: The following Figures 4.12 through 4.16 are the test images and their hash outputs computed using SHA 256 hash algorithm.
94 Figure 4.12 Input Image: Boat Hash of Boat image is, imhash = 24366ac1ad2e8fd90958f8c4814fe06018d3bc f558128e2d0a85ace62da9626f Figure 4.13 Input Image: Lena Hash of Lena image is, imhash = bc2598c8ce4edee92776a1582960a 1138091b994c2f16365f747e27d9ce8fc33
95 Figure 4.14 Input Image: Baboon Hash of Baboon image is, imhash = 1080cae4b70e3706763e0d004aae15538064b283fabdce74663b2942adcce481 Figure 4.15 Input Image: Barbara Hash of Barbara image is, imhash = f278c72d3ada653dc1156351c164f4f0d40aa5bbb8ab90ebfb8f3a2c8be6d746
96 The original 256 bits hash of the image is computed and embedded in the image. After the watermark is extracted and the original image is recovered it may be checked if it has got altered by recomputing the hash using the recovered image and comparing it with the received hash. They will be same only if the watermarked image is not altered. 4.6 CONCLUDING REMARKS Reversible image watermarking using bitplane coding is done and is completely reversible. Arithmetic coding used for compression guarantees complete reversibility. Lower bit planes have lower embedding capacity but since they are less significant for visual perception image quality is better than in higher bit planes. Performances of various wavelet families are studied. Bior 3.3 and cdf 9/7 perform better than other wavelets for this algorithm. Hash of the images were embedded and tested for authentication and security. Arithmetic coding is a lossless compression method and though it gives best performance, maximum level of compression for a given bit pattern is fixed. Embedding capacity is based on this factor. For more capacity higher bit plane has to be used which affects the visual quality of the watermarked image. So another reversible watermarking method using histogram shifting is implemented in the next chapter which gives better image quality for a given embedding capacity.