Spatial Image Watermarking by Error-Correction Coding in Gray Codes

,


Introduction
Digital watermarking is a technique for uniting digital signals and additional data, which are commonly called watermarks, so as to make changes in the signals imperceptible [1].As for image signals, a watermark is embedded into a source image in a manner such that the resulting degradation of image quality is hardly noticeable.The watermark is to be recovered afterward for verifying the ownership of the image, for instance.From the viewpoint of signal domains to directly modify for expressing watermarks, the watermarking techniques are mainly divided into two categories: spatial-domain-based techniques and transform-domain-based ones.
In transform-domain-based image watermarking, pixel values of a source image, which are expressed in quantized signal levels, are first transformed into frequencies using a signal transformation such as the discrete cosine transform (DCT).These frequencies are, then, modified so as to include a watermark.Lastly, a watermarked image is produced from the modified frequencies by the inverse transformation and re-quantization.The changes in frequencies made by the watermark are inversely transformed to the changes in pixel values and thereby, they are dispersed over the watermarked image in such a way that the image distortion can be less conspicuous.Quantizing errors, however, generally result from the re-quantization of the inverse transforms.These errors disturb the transform domain as a result.Hence, the watermark essentially needs to be embedded with redundancies in the transform domain.These redundancies can also lead to some extent of robustness of the watermarks against signal changes in the spatial domain.
In spatial-domain-based image watermarking, pixel values are directly modified so as to include a watermark.A well-known conventional method for this processing is to replace some bits of pixel values, which are assumed to be expressed in binary notation, with watermark bits.Accurate watermarks can thus be embedded without any such redundancies as that essential to the transform-domain-based watermarking schemes.Such changes in pixel values, however, directly distort the source image.In addition, the watermarked image generally has weak robustness to subsequent signal distortions because even a small change in a pixel value is likely to cause a significant change in the binary representation [2].However, spatial-domain watermarks are nevertheless used in a number of applications such as steganography and fragile watermarking for content authentication.
As regards today's digital systems, data are usually compressed for transmission, storage, etc.When a watermarked image is transmitted through an image communication system, the image is usually compressed by, for example, the JPEG coding scheme before transmission.Hence, when the image is recovered at the receiver, it is distorted due to the lossy data compression.Because such lossy data compression is a kind of usual processing in communication systems, if watermarking is carried out before transmission, the watermark must be robust against at least the distortion caused by a data compression method being in use.Wang et al. proposed the pixel surrounding (PS) method as a spatial-domain-based image watermarking method, and reported that the watermarks embedded by the method can survive JPEG lossy compression [3].The PS method reduces effects of signal distortions on the embedded watermark by averaging pixel values, which is a kind of low pass filtering.On the other hand, error correcting techniques in channel coding such as the Bose-Chaudhuri-Hockquenghem (BCH) codes [4] can be used to improve robustness of spatial-domain watermarks [5].A number of the related coding methods were studied in the late 1990's [2].Most of such error-correction coding (ECC) methods have been applied to transform-domain watermarks [6].
With regard to signal bits, a quantized signal level is generally represented by a natural binary code, which is one of equal-length codes.Another equal-length code is the Gray code (also called the reflected binary code).This code has the property that any two adjacent codewords differ in only one bit position.Thus, small changes in a signal level are unlikely to affect all the bits of the codeword [7].Accordingly, if the number of the changed bits is limited, they can be corrected by using error-correcting codes.In this paper, we consider watermarking by using both the Gray code to express the spatial domain and an error-correcting code to achieve robustness to signal changes.The objective of robustness here is to survive ordinary data compression such as the JPEG lossy coding.
The rest of this paper is organized as follows.Section 2 describes the codeword properties of Gray code.In the section, first, a single bit position where two adjacent codewords differ is given as a function of a signal level.Then, for each difference signal-level, the distribution of bit positions where two codewords just apart by the level from each other differ is demonstrated and compared with that in the case of the natural binary code.After formalizing the watermarking of signal codewords, Section 3 presents a scheme of error-correction coding in the Gray code representation.Based on the properties of the Gray code described in the preceding section, signal codewords involving single-error-correcting codewords are defined.The performance of error correction in the change of signal levels is verified by stochastic analyses.In Section 4, results of some experiments conducted on test images are presented to demonstrate performance of the proposed method, referred to as the Gray-ECC method, by comparison with the PS method.To begin with, the procedures for implementing the Gray-ECC method in image watermarking are defined.In addition, with regard to the PS method being compared, the implementing procedures are explained on referring to [3], and its properties depending on the parameter values are discussed to make a reasonable comparison with the ECC method.Then, both the image quality and the capability of robustness to JPEG lossy compression are evaluated from the experimental results.Section 5 concludes the paper.

Difference between Two Adjacent Codewords
First of all, we define the notation used in this paper.An m-bit Gray code is transformed from the natural binary code of the same length.Let R m denote the decimal range of m-bit quantized levels , and let C R generally represent an m-bit binary code that consists of codewords corresponding to respective levels in R m .The m-bit where b i is either 0 or 1 for .Let C RN denote the m-bit natural binary code and 0,1, , . In Equation ( 2 A bit position where two adjacent Gray codewords differ depends on the levels that the codewords represent.For a level v ( 0 and , and the respective succeeding codewords and and is expressed as the bit sequence that, by using Equation ( 2) with the associative and commutative laws of the exclusive OR operation, is given by the relations for .From another viewpoint, the least 0, 1, , 1 i  significant bits of any can be expressed as ; that is, a certain exists, and and for .Here, we define if v is even.Note that the corresponding bits in are .Then, for .Thus, and 0, 1, , In addition, it is found that if v is odd. 1 J 

Difference between Two Codewords
The difference between and where d (≥1) is a difference signal-level, is given by the result of accumulating bit changes from Hence, these two codewords differ in those bit positions where the bit inversion occurs once or odd times during the accumulation.For d ≥ 2, thus, one or more bits differ between the codewords, and the loca-tions of difference bits are determined from the starting level v. Consequently, the distribution of difference bits in the entire m-bit codeword for all v's that satisfy is derived using Equation (6).
Let m = 8 as a practical example.for each value of d from 1 to 8, for instance.

Comparison with Natural Binary Code
As for m-bit natural binary representations, the difference between two codewords is analyzed as below.The number, μ, of bit positions where two adjacent codewords differ ranges from 1 to m.For each μ, there are 2 m   possible codeword pairs, and any of the pairs differs in the bit positions from 0 through 1 As the above examples demonstrate, for a given difference signal-level d, with regard to the pairs of codewords whose levels are apart by d from each other, the number of bit positions where two Gray codewords differ lies in a narrower range than that of bit positions where two natural binary codewords differ.

Formalization of Watermarking Codewords
The process of watermarking signals in code representations can be expressed in a generalized form as below.
1) Embedding process In addition to the notation used in the preceding section, we define the inverse mapping from C R to R m , that where a unique v is determined for each c since the code C R is a one-to-one mapping.As for a watermarking algorithm to be considered, let us regard both of the embedding of watermarks and the extracting of watermarks as kinds of point operations where the processing for any signal in a signal sequence depends only on the value of that signal.Also, for simplicity, we assume that one watermark bit is embedded in one chosen signal.Suppose that a source signal sequence, X, and a watermark-bit sequence, W, are given.In the embedding process, first, the value v x of a given signal x in X is mapped to the codeword Next, for a given watermark bit , a procedure, named EMBED, performs embedding w into c x ; this is expressed in the form of a point operation such that where c y is the resulting codeword and . The signal value, v y , that c y represents is given by   and the source signal x is replaced with the signal of the level v y .Let Y denote the entire sequence of the replaced signals.Thus, the signal sequence X is changed to Y with the watermark W embedded there.The difference of the signal values v x and v y , which is generally referred to as an embedding distortion, degrades the signal quality of Y from X.
2) Extracting process Assume that, undergoing some signal processing such as data compression, the above sequence Y changes to another one, Z, of different signal values.In the watermark recovering process, a procedure for extracting watermark bits from codewords in C R is defined as the following inverse process of Equation (9): Referring to the procedure as EXTRACT, we can write it in the form of a point operation; that is, using the notation of Equation (9), To extract the watermark from Z using this procedure, first, the value, v z , of each signal in Z is mapped to the Then, the procedure performs on c z as where w' is the resulting bit.
Robust watermarking requires w' to be equal to w in spite of the change in signal level from v y to v z .However, of the one-to-one mapping of the code.As a result, the change in codeword is likely to lessen the reliability of a watermark extracted from the resultant codeword.It is clear from the above relations that the change in codewords affects directly the extraction of watermark bits.This also implies that for the purpose of recovering watermarks, it is sufficient to recover at least those bits of a codeword which affect the embedded watermark.

Single-Error-Correcting in Gray Code
When a signal changes by one level, one bit of the corresponding Gray codeword changes.Accordingly, the changed bit can be corrected by means of a single-errorcorrecting (SEC) code.Then, we employ single-errorcorrection coding in watermarking to make embedded watermarks completely robust against a change by one level in any signal.1) Encoding procedure The processing of encoding watermark bits with a SEC code can be involved in the embedding operation EMBED of Equation ( 9).Let C E denote an error-correcting code to be used, which is assumed to be a linear block code in this paper, and n E be the code length of C E .For a signal level v x and a watermark bit w, given the corresponding codeword x w c can be defined by the following two steps.Note that we still use a general notation of C R as the code that represents signal levels.
(EN.1) Generate a codeword, c w , in C E corresponding to the bit value of w.
(EN.2) Replace n E consecutive bits of c x from a specified bit position k (≥ 0) with all the bits of c w .Here, the bit position 0 designates the least significant bit (LSB).The resulting codeword is equivalent to c y of Equation (9).Let us define a REPLACE operator to implement the operation of this step in the form In the above procedure, the codeword c x is changed depending on both c w and k.The change in codeword immediately affects the signal level and the resultant level v y is determined.To reduce the embedding distortion, y x , a code C E of short codewords is desirable.A binary linear SEC code of the minimum code length is a (3, 1, 3) code consisting of two 3-bit codewords that are apart by the Hamming distance of 3 from each other and that correspond to respective values of an informa-tion bit 0 and 1.A typical (3, 1, 3) code is the so-called (3, 1) repetition code or also known as the general Hamming (3, 1) code [4].Regarding each watermark bit as the information bit per codeword, we concentrate on a (3, 1, 3) code from now on.

v v 
2) Determining signal codewords Given a source signal and a watermark bit, to reduce the embedding distortion, from those codewords which include the error-correcting codeword corresponding to the watermark bit in the same bit-position, the one that results in the smallest embedding distortion must be chosen as the encoded codeword of the signal.The problem of choosing such codewords can be simplified in the way below.
Suppose that a (3, 1, 3) code where the two codeword c E0 and c E1 correspond to respective watermark bits of 0 and 1 is given.Given a code C R for representing signal levels, for each value of watermark bit, putting the corresponding error-correcting codeword into all the codewords of C R by means of the REPLACE operator with a specified value of k, we obtain a subsetcode of C R , expressed in the form for b = 0 and 1 respectively.From each subset-code, a set of all signal levels that the codewords of the subset-code represent is obtained such that It follows that U k,0 and U k,1 are subsets of R m .Thus, these subsets consist of signal values that each have had a watermark bit embedded by the error-correcting code.
For a given signal level x m v R  and a watermark bit It can be proved that in the case that the Gray code C RG is used as C R , the unique v y exists closest to each v x in either U k,w .Let us denote the choosing operation of Equation ( 17) by the operator ENCODE in the form This operator involves U k, 0 and U k, 1 that both have been made from C R and C E by Equations ( 15) and ( 16).The signals of a sequence X are thus encoded one by one to the single-error-correctable values, which compose the watermarked sequence Y.
3) Determining SEC codewords Since C E affects U k, 0 and U k, 1 through Equations ( 15) and ( 16), embedding distortions also depend on the codewords comprised in C E .On the assumptions that each level in R m is equally likely to occur for any signal and also that a watermark bit is a random variable, for a given code and a bit-position parameter k, the amount of embedding distortion can be estimated by calculating the expected value of the mean squared error (MSE) between the source signal levels and the encoded signal levels, defined by In fact, if C R has a periodic structure in codeword bits, the above ranges of summation can be reduced.
There exist the following four kinds of pair of 3-bit codewords that are apart from each other by Hamming distance of 3: (i) {(000), (111)}, (ii) {(001), (110)}, (iii) {( 011), (100)}, and (iv) {( 010), (101)}.Under the condition of using the Gray code C RG as C R , the expected MSE values of Equation (19) were calculated not only for each of the four codeword pairs but also for each bit position k of 0 and 1, respectively.The results are listed in Table 1, together with the peak-signal-to-noise ratio (PSNR) values in decibels (dB) defined by On the above assumptions for stochastic analysis, the codes (i) and (iii) have exactly the same MSE values, and so do the codes (ii) and (iv) for both the bit positions.As shown in Table 1, the codes (i) and (iii) yield less distortion than the codes (ii) and (iv).On the other hand, as shown later, all the four codeword pairs have almost the same performance in error correction.Consequently, the codeword pair (iv) has been selected as C E for the Gray code; denoted by C EG , that is, .We refer to the encoding by the ENCODE operator with C EG and the position parameter k = 0 as ECC G0 and that with C EG and k = 1 as ECC G1 .The encoding with the bit posi- Figure 2 shows the relationship between source signal levels v x and encoded signal levels v y of Equation (18) in ECC G0 and ECC G1 .The relationship in the interval of 16 source levels and that in the interval of 32 source levels repeat periodically over the 8-bit dynamic range for ECC G0 and ECC G1 , respectively.In the period of ECC G1 , the stepwise changes differ for the two codewords.With regard to embedding distortions, the magnitude of difference in signal levels caused by ECC G0 is less than or equal to 6, and that caused by ECC G1 , less than or equal to 12.
4) Decoding procedure Given a signal sequence Z that has come from Y described in Section 3.2 (2), the process for decoding signal values to extract watermark bits is described as follows.Assume that both the error-correcting code , consecutive bits starting at the bit position k.We define the operator SEPARATE that performs this bit-operation as where actually for the (3,1,3) code 2) The codeword e, which might have been distorted, is supposed to be decoded by using C E .To implement the decoding, assuming all distorted codewords are equally likely, we use a maximum-likelihood decoding method [4].By the method, e is mapped to one of the two codewords c E0 and c E1 such that is closer to e than the other in terms of the Hamming distance.Let e' be the resulting codeword. (DE. 3) The bit value, w', corresponding to e' in C E is immediately obtained as the watermark bit extracted from v z .
We express the procedure that performs the above three steps for a given v z by the operator DECODE of the form which is implicitly associated with C E and k.

Stochastic Analysis of Error-Correcting Performance
Error-correcting performance of ECC G0 and ECC G1 are revealed by stochastic analysis below.
is determined.The agreement between the two bits b and b' depends on the difference between the two error-correcting codewords, c Eb of   RG C u and a' of that is obtained by where a' is the same as that of Equation ( 23 where S denotes the number of elements in a set S, for b = 0 and 1, and k = 0 and 1 according to Section 3.2 (3).
On the additional assumption that watermark bits are random variables, an estimate of the correctly decoding probability of ECC Gk , for k = 0 and 1, can be defined as follows.For the definition, and where d > 0 .
As regards ECC G0 , Figure 3   For comparison, we define a (3, 1, 3) code, denoted by C EN , to use for the natural binary code C RN .Two codewords in C EN have been determined from MSE values similarly to those in C EG ; that is, We refer to the encoding by the ENCODE operator with C EN as the natural ECC method, and let ECC Nk denote the natural ECC method with the position parameter k, where practically or 1.Note that no operation is actually needed for the transformation between m-bit binary signal values and m-bit codewords in C RN .Also, the expected probability of correctly decoding by ECC Nk for a parison among the four codeword-pairs, the variations of these probabilities with d have been found to be almost the same.Consequently, the four codeword-pairs have no difference in error-correcting performance.
3) Bit position of error-correcting codewords For the bit position 1 k  , the performance of ECC G1 has been evaluated.The variation of with d is shown in  Hence, ECC N1 is barely expected to achieve the error correction in this range of d.
From the above stochastic analyses, the advantages of the Gray code over the natural binary code in the ECC method are summarized as follows: a) For any d, while These advantages result from the limited distribution of bit positions where two codewords differ as described in Section 2.2.Because of the advantages, ECC Gk achieves the capability of correcting "errors", namely signallevel changes particularly if the changes are limited in a small range.

Watermarking Procedures
The procedures for implementing the ECC method, which means both the Gray-ECC and the natural ECC by generalization, is introduced in this section.Source images are assumed to be monochrome images or signals of one channel of color images, and a signal level of each pixel is represented by an m-bit code in natural binary notation.Using a general notation, for an image f, let denote a pixel, or equivalently a pixel value at the coordinates ( , ) f x y ( , ) x y on the image plane.A watermark is a sequence of bits, and the bits are supposed to be embedded into a source image one by one in order.
1) Embedding procedure Given a source image, f X , of the size N X by N Y pixels and a watermark-bit sequence , where N W is the number of watermark bits the embedding procedure performs according to the following steps: , out of the coordinates of f X in a manner such that all the N W points are situated separately on the image plane.Let the sequence of the ordered points be represented by K; that is, (WE.2) According to K, obtain a pixel sequence, X, (WE.3)For each pixel x i in X, , encode the pixel value with a given watermark bit w i using the operator ENCODE of Equation ( 18), so that 0, 1, , 1 Then, replace the value of x i with v i .Expressing the resultant pixel by y i , we thus obtain the sequence (WE.4) Substitute y i in Y for the pixel at   x y in the image f X for 0, 1, , 1 . Thereby the watermarked image, f Y , is achieved.
The sequence K is supposed to be associated with each f Y , and it must be protected from unauthorized use.We here refer to the ratio of N W to the number of pixels in f X as an embedding pixel ratio  ; that is, 2) Extracting procedure Given an image, f Z , that is assumed to be derived from the above f Y , the procedure for extracting watermarks from f Z is as follows: (WD.1) Using the same K as that has been used in the embedding procedure for f X , obtain a pixel sequence, Z, , decode a bit, w' i , from the pixel value using the operator DECODE of Equation ( 22).We thereby obtain the bit 0, 1, , 1  

Pixel Surrounding Method
The performance of the proposed ECC method has been compared with that of the conventional pixel surrounding (PS) method [3].The procedures of the PS method are outlined below.In addition, our analysis will reveal its essential properties in terms of embedding distortions and robustness. 1) Embedding procedure Given a source image f X and a sequence of N W watermark bits, the embedding procedure is as follows: (PE.1)As in the step (WE.1) of the ECC method, determine a sequence of N W points in f X .Let K denote the sequence, and the same notation as that in the ECC procedure is used here.
(PE.2) According to K, obtain a sequence, X, of N W pixels from f X .
(PE.3) Foreach x i in X, calculate the mean value, a i , of the eight pixels surrounding x i in the neighborhood of 3 by 3 pixels.Thus, a sequence for , where 0, 1, , 1  is a specified positive value of signal level.Letting x' i denote the resultant pixel, we thereby obtain a pixel sequence x .
(PE.5) Substitute x' i in X' for the pixel at  , be the resulting image, so that 2) Extracting procedure The procedure for extracting watermarks from a given image, ( ) P Z f , that is supposed to come from the above is as follows: (PD.1)Using K that has been determined in the step (PE.1), obtain a pixel sequence, Z, from (PD.2) For each z i in Z, calculate the mean value, a'' i , in the neighborhood of z i in the same way as in the step (PE.3).Then, a sequence is ob- with a'' i , a bit value, w'' i , is determined in a manner such that . Thus, the bit sequence is obtained as a watermark extracted from 3) Embedding distortions Embedding distortions caused by the PS method are signal changes at the embedding points.To estimate the amount of the distortion, we use the measurement of MSE between the two images f X and ( ) P Y f , expressing it by MSE PS .The general definition of MSE between two images f 1 and f 2 of the same size of N H by N V pixels is where the summation is taken over the entire image area.
Replacing f 1 and f 2 in Equation ( 33) with the respective images of f X and ( ) yields directly the form of MSE PS .Based on the definition, the value of MSE PS for a given  is approximately proportional to the embedding ratio.
Using MSE PS instead of MSE in Equation (20), we can also obtain the value of PSNR.
At each of the embedding points in ( ) P Y f , the pixel has a value different from the average of its neighborhood pixels by  according to Equation (31).Then, the pixel value can be regarded as the sum of the spatial average and a noise signal that is randomly chosen between  and ( )   on the assumption that the watermark bits are random variables.Hence, the image ( ) gets closer to a result of spatial averaging with decreasing  , and accordingly, it looks more blurring, particularly when the embedding pixel ratio is large and close to 1.

4) Robustness
In the step (PE.3) of the above embedding procedure, the neighborhood averaging is carried out using source signal levels of f X and hence, the resulting average at each point is independent of the situations of any other points of K.In addition, the steps (PE.4) and (PE.5) are implemented by point operations.Accordingly, the steps from (PE.2) through (PE.5) can be accomplished by a parallel processing with the 3 by 3 operator applied to f X at each point of K.The pixels of ( ) are consequently generated from f X independently of each other.
On the other hand, in the extracting procedure, the step (PD.2) involves the calculation in the neighborhood in around each point of K.This spatial operation makes the mean value calculated at each point dependent on the situations of the other points of K as described below.Suppose that a point of K, say,  ,  j j x y , has its neighbors including another point of K, say,   , x y   .Also, suppose a mean value, a' j , calculated in the neighborhood around   , j j x y in ( ) P Y f .Then, a' j is no longer equal to a j obtained in the step (PE.3) due to the difference between the level of and The difference between the mean values a j and a' j has a certain effect on the performance of watermark extraction.The condition for extracting correct watermark bits from ( )  where j j a a j     .This interval of j  just depends on  .If j  is larger than  , either a watermark bit of 1 or that of 0 is unable to recover, according to whether j  is positive or negative.Hence, all the watermark bits would be hard to recover even from the watermarked and still unchanged image without any limitation of the situations of embedding points.The condition sufficient for correctly recovering all the watermark bits is that every point of K is situated outside the 3 by 3-pixel neighborhoods of any other points of K.Note that satisfying this condition makes the embedding pixel ratio  unable to exceed 1/9.
As for a processed and probably changed image , and respectively, for .Substituting these expressions in Equation (32), we find that if 0, 1, , 1 , the watermark bit of either value is to be correctly extracted from ( )   , the watermark bit of 1 is lost, and otherwise, the watermark bit of 0 is lost.

Experimental Methods
The experimental procedure that was carried out to evaluate the ECC method is described here.Some 8-bit monochrome images of 256 by 256 pixels, such as commonly used "Lena," were used as source images in the experiment.The embedding of watermark bits was carried out for all the pixels of a source image so that the performance with the upper limit of the embedding pixel ratio, that is, 1   could be evaluated.Note that the watermarking is actually to be implemented with 1   to hide where watermarks are embedded.As an instance of watermark, W, a sequence of 256 × 256 bits was generated using a pseudo-random number generator with a computer, and thus,  where 256 256 W N   .The procedure applied to each source image, f X , consists of the following steps: (EX.1) Embed W into f X by the ECC method.Let f Y denote the resulting image.Then, measure a PSNR value between f X and f Y .
Here, ECC G0 and ECC G1 were used as the Gray-ECC method, and also, ECC N0 and ECC N1 were used for comparison.Furthermore, the PS method was implemented for f X with 1   and various values of  .Thus the respective f Y s were produced from each f X by these methods.
(EX.2) Compress f Y using the JPEG DCT-baseline system, and decompress the resultant data to reconstruct an image, f Z .Then, measure a PSNR value between f Y and f Z to estimate the amount of distortion caused by the JPEG lossy compression.
To obtain various amount of distortion, the JPEG coding performance was varied by multiplying the entire luminance-quantization matrix that is specified as the recommended one in [8] by a constant and thus, several f Z s with the various distortions were produced for each f Y .
(EX.3) Extract a watermark-bit sequence from f Z using the decoding procedure corresponding to each embedding method.Let the resulting bit-sequence be We define a watermark-bit correct ratio, R C , of f Z as the ratio of correct watermark bits among those extracted from f Z .Using the above W and W', it can be calculated by R C of f Y can be defined similarly from a watermark-bit sequence extracted from f Y .
As described in the step (EX.1), all the methods are compared under the condition that the embedding pixel ratio 1   .As for other values of  , due to the point operation in these methods, generally, MSE values between f X and f Y defined by Equation (33) vary almost in proportion to  of f Y for each f X .

Experimental Results and Discussion
1) Quality of watermarked images Table 2(a) lists PSNR values of the watermarked images f Y obtained by applying each of the ECC methods to four different source images f X : "Lena," "Aerial," "Peppers", and "Parrots".Compared among these images, the PSNR values given by each method are almost the same; the PSNR values given by ECC G0 and those given by ECC G1 agree well with the respective values obtained by the stochastic analysis (previously shown in Table 1), and so do the PSNR values given by ECC N0 and ECC N1 .
On the average, PSNR values of the results of ECC G1 are about 5.5 dB smaller than those of the results of ECC G0 for any test image; PSNRs of the results of ECC Gb are about 2 dB smaller than those of the results of ECC Nb for and 1.Note that R C of f Y by any ECC method is equal to 1.

b 
In addition, weighted signal-to-noise ratio (WSNR) values were calculated from the difference between f Y and f X .In the calculation, the viewing distance of 13 inches and the image resolution of 200 pixels per inch were assumed.  is comparable to ECC G1 in terms of PSNR.Also, from a comparison between Tables 3(a) and (c), we find that each watermarked image has a WSNR value, on the average, 2.7 dB larger than the PSNR value.
To evaluate image appearance, Figure 5 shows examples of the watermarked images.The ECC G0 hardly yields perceptible distortions on the resulting images as shown in Figure 5(b).As seen in Figure 5(c), on the contrary, the ECC G1 tends to generate visible artifacts similar to "false contours" [7] particularly in areas of smooth gray levels.As for the PS method, the image degradation is mainly due to the averaging operation, which is a kind of low-pass filtering: the watermarked images of small δs as shown in Figure 5(d) look considerably blurred; the images of large δs look grainy as well as blurred as seen in Figure 5(e).
2) Error-correcting capability The error-correcting capabilities of the ECC methods for signal changes were evaluated from the experimental results.As a measure of the capability, we define a error-correction success ratio, R S , of f Z for f Y as the ratio of those pixels from which correct watermark bits are able to be extracted among those watermarked pixels of f Z whose signal levels differ from those of f Y .To formulate R S for calculation, let K err be a set of locations of those watermarked pixels whose values differ between f Y and f Z ; that is, Then, using the original watermark W and the extracted W', R S can be calculated by where err K represents the number of elements of K err .Before evaluating error-correcting performance, we examine the amount of signal distortion caused by JPEG compression.Figure 6 shows examples of occurrence frequencies of difference levels between a JPEG-compressed image and its source image for various degrees of data compression.As this figure demonstrates, the difference levels tend to concentrate into small ones and also, the range is limited to a few levels particularly in the distorted images of PSNR larger than 40 dB.
Figure 7 shows the experimental results for two test images, depicting variations of R S with PSNR values of JPEG-compressed images for each of the ECC methods.Both the images have almost the same result.These experimental results agree well with the stochastic analyses described in Section 3.3: As the PSNR value increases, the MSE value equivalently decreases, and accordingly, the difference levels concentrate in a narrow range as and 4(b).In Figure 7, ECC G0 and ECC G1 have R S over 0.5 beyond about 35 dB and 30 dB, respectively, and achieve R S over 0.9 above about 50 dB and 45 dB, respectively.Thus, these two methods have the capability of error correction for JPEG distorted images.In contrast, ECC N0 is unable to afford the error correction for any distribution of difference levels; ECC N1 has R S values greater than 0.5 and as much as 0.75 beyond about 37 dB.
3) Robustness for JPEG lossy compression Figure 8 shows the experimental results for two test images, depicting variations of R C with PSNR values of JPEG-compressed images for ECC G0 and ECC G1 .As regards these ECC methods, both the images have almost the same result.These results indicate that correct watermark bits can be recovered from JPEG-distorted images of PSNR of over 30 dB by either Gray-ECC method.dance with Table 3, R C values for the image "Lena" are larger than those for the image "Aerial." Figure 8(a) implies that the performance of ECC G0 is comparable to that of the PS method with 3   in the range of about 35 to 45 dB, and the performance of ECC G1 , that of the PS method with 5   in the range of about 35 to 40 dB.To obtain a better performance than that of ECC G1 , the PS method needs to be implemented with a large  value such as 10 at the expense of enormous embedding distortions.

Conclusions
In this paper, the error-correction coding in Gray codes (ECC-in-Gray) has been considered to enhance the errorcorrecting capabilities, and its performance has been evaluated using the Gray-ECC method where ECC-in-Gray is applied to the protection of image signals watermarked in the spatial domain.The stochastic analyses and the experimental results have shown that although level changes caused by error-correcting codewords are somewhat enlarged by the transformation from Gray to natural binary codes, ECC-in-Gray is suitable for distorted signals of such error-distribution as caused by lossy data compression.
The performance of the Gray-ECC method is summarized in comparison with that of the PS method as follows: 1) The Gray-ECC method has robustness against signal distortions caused by JPEG lossy compression comparable to that of the PS method.
2) The Gray-ECC method yields a considerably smaller amount of embedding distortion than the PS method in terms of PSNR.
3) The embedding distortion caused by the Gray-ECC method looks similar to the signal distortion by coarse quantization and tends to get noticeable particularly in smooth image areas.As for the PS method, the watermarked images primarily look blurred because of the use of neighborhood averaging, and increasing the capacity of robustness makes the image appearance grainier.ECC G1 has stronger robustness than ECC G0 , but it possibly yields more perceptible distortions in smooth image areas.From this point of view, effectively robust watermarks are expected to be achieved by switching between ECC G0 and ECC G1 for each image area depending on, for example, the degree of smoothness of the area.Such an adaptive system will be a subject in the further study.
), denotes the exclusive OR operation, and b m that the equation needs is temporary here and supposed to be 0. Let C RG denote the  m-bit Gray code and in C RG associated with a level  .
one bit J  , and J depends on the bit patequivalently, on the value of v. Consequently, the bit position J where and differ is given by

differ ranges from 1 to m − 1 .
For a difference signal-level d = 2, the number, also denoted by μ, of bit positions where two codewords and There are 2 m   possible codeword pairs for each μ, and any of the pairs differs in the bit positions from 1 through μ while the b 0 's are always the same.For a difference signal-level d = 3, the number of bit positions where two codewords differ ranges from 2 to m.The difference between the codewords gets more complicated than that for the above d = 2 or d = 1, while the b 0 's are always different.

Figure 1 .
Figure 1.Distributions of difference bits between two 8-bit Gray codewords apart by a difference signal-level d from each other, for : N diff denotes the number of difference bits occurring in a codeword; the numbers written in the right side denote the total numbers of codeword pairs to which the bit distributions apply; the number written at each bit position in parentheses denotes the number of codeword pairs which differ at the position; the asterisks indicate those bit positions only one of which differs at the same time.1, 2, , 8 d  

)
If the Hamming distance between c Eb and a' is either 0 or 1, then a' is mapped to c Eb in the decoding procedure and thus, b' agrees with b.Otherwise, a' is mapped to the other error-correcting codeword Eb c , where b denotes the 1's complement of b, and consequently, b' is regarded as b .Because the difference bits between two signal codewords and  depend on the u in , we define a ratio of the correctly decoding of signals for the entire as follows.First, the whole of those values of which are allowed to increase by d within R m is described by a set, , k b which, after increasing by d, still contain correctly decodable error-correcting codewords is expressed in the form such that denotes the Hamming distance between two codewords x and y.Supposing that signal values in , k b U are equally probable, we estimate the probability of the correctly decoding of for a variable d, denoted by , same d are put together by taking the average of the two values on the assumption that a signal change by d levels and that by −d levels are equally likely to happen to any level in .In fact, because of the symmetrical , d and each b.Then, the overall probability of correctly decoding by ECC Gk for a variable d, denoted by   G k P d , is defined by b = 0 and 1, and for any possible d, and they have one of three values 0, about 0.5 and 1 if d is so small that , the denominator of Equation (26), is composed of a lot of elements.As shown in Figure 3(a), for any d, and d has one of three values about 0.25, about 0.5, and 1. Particularly for 1 d  , .

Figure 4 (
Figure 4(a), compared with that of .In ECC G1 ,   1 N P d
the pixel values and the mean values calculated in the step (PD.2) by the relations

Figure 6 Figure 6 .Figure 7 .
Figure 6.Examples of distribution of difference levels in JPEG compressed images: The source image to JPEG encoder is "Lena" watermarked by ECC G0 ; JPEG compressed images have respective PSNRs of (a) 48.0 dB, (b) 42.5 dB, (c) 31.4 dB, and (d) 27.0 dB; The relative frequency of difference level d is defined as the ratio of the number of pixels of difference level d to the number of unchanged pixels in each image.

Figure 8 1   and 3 Figure 8 .
Figure 8. Variation of watermark-bit correct ratio with amount of signal distortion caused by JPEG lossy compression for the test image (a) "Lena" and (b) "Aerial."

Table 2 (
b) lists the WSNR values of the results of each ECC method for the four test images.On the average in the ECC methods, each watermarked image has a WSNR value 3.7 dB larger than the PSNR value.
  and some δs.The results for 1   in Table 3(a) demonstrate that the PSNR values are substantially small and more than 10 dB smaller than those of ECC G0 even for 1   .Increasing  decreases the PSNR values whereas achieving large values of R C requires