194 Bellamy Rd. N. Scarborough, Ontario M1J 2L5 September 16, 2002 Mr. M. E. Jernigan, Department Chair Department of Systems Design Engineering University of Waterloo Waterloo, Ontario N2L 3G1 Dear Sir: I have prepared the enclosed report, “Effectiveness of Still Image Digital Watermarking Algorithms,” as my 2A Work Report for the Research and Development department at Leitch Technologies Inc. This report is the second of four that I must submit as part of my degree requirements, and it has not received any previous academic credit. Leitch Technologies produces a wide variety of television broadcasting equipment for broadcasting studios like CTV. As part of the R&D department, under the management of Leigh Whitcome, I participated in their strive to develop new technologies as well as improve upon their current products. In an attempt to bring the latest technologies to the market, Leitch is currently looking at incorporating digital watermarking algorithms into their existing video routing equipment. However there are a wide variety of digital watermarking algorithms available. I have created this report to analyze these algorithms in an attempt to aid the Leitch engineers in finding the most suitable algorithms to use in their products and also to familiarize them with the concepts of digital watermarking. At this time I would like to thank Leigh Whitecome, Samson Tam and Thiru Siva for their help. Sincerely, Parthipan Siva ID 00168041 University of Waterloo Faculty of Engineering Department of Systems Design Engineering Effectiveness of Still Image Digital Watermarking Algorithms Leitch Technologies Inc. North York, ON Parthipan Siva, 00168041, 2A September 15, 2002 Abstract Various authors have proposed many watermarking algorithms. These algorithms are implemented in ether the spatial, frequency or wavelet domains. But which algorithms are better? Is embedding a watermark in one domain better than another? Do combining domains result in a better watermarking algorithm? This report attempts to answer these questions by selecting eight algorithms and analyzing them. Of these eight algorithms 2 embeds the watermark in the spatial domain, 2 in the frequency domain, 2 in the wavelet domain, one in a combination of frequency and spatial domain and one in a combination of wavelet and frequency domain. Do to the wide variety of algorithms a standard benchmark is also developed, within this report, to analyze the algorithms. iii Table of Contents Abstract .............................................................................................................................. iii Table of Contents ............................................................................................................... iv List of Tables ..................................................................................................................... vi List of Figures ................................................................................................................... vii 1 Introduction ................................................................................................................. 1 2 Digital Watermarking ................................................................................................. 3 3 2.1 What is Digital Watermarking? .......................................................................... 4 2.2 Properties of Watermarks ................................................................................... 4 2.3 Applications ........................................................................................................ 5 2.3.1 Broadcast Monitoring ................................................................................. 5 2.3.2 Content Authentication ............................................................................... 5 2.3.3 Transaction Tracking .................................................................................. 5 Algorithms .................................................................................................................. 6 3.1 Basic Algorithms ................................................................................................ 6 3.1.1 Embedder .................................................................................................... 6 3.1.2 Detector ....................................................................................................... 7 3.2 Advanced Algorithms ......................................................................................... 8 3.2.1 Spatial Domain............................................................................................ 8 3.2.2 Frequency Domain ...................................................................................... 9 3.2.3 Wavelet Domain ......................................................................................... 9 3.3 Combination Algorithms .................................................................................. 10 3.3.1 Frequency-Spatial Domain Algorithm ...................................................... 10 Mask Generation ................................................................................................... 10 3.3.2 4 Wavelet-Frequency Domain Algorithm ................................................... 11 Benchmark ................................................................................................................ 12 4.1 Fidelity .............................................................................................................. 12 iv 4.1.1 4.2 Fidelity vs. Correlation ............................................................................. 12 4.2.1 Robustness ........................................................................................................ 12 4.3 Robustness vs. Correlation........................................................................ 13 5 Data Presentation and Analysis ................................................................................ 14 5.1 Fidelity .............................................................................................................. 14 5.2 Robustness ........................................................................................................ 17 5.2.1 Cropping ................................................................................................... 17 5.2.2 Column Removal ...................................................................................... 18 5.2.3 Scaling....................................................................................................... 19 5.2.4 Squeeze ..................................................................................................... 20 5.2.5 Gausian Noise ........................................................................................... 22 5.2.6 JPEG Compression ................................................................................... 23 5.2.7 Small Angle Rotations .............................................................................. 24 5.3 6 False Positive / False Negative ......................................................................... 13 False Negative / False Positive ......................................................................... 25 Conclusion ................................................................................................................ 29 Appendix A – Algorithm Details ...................................................................................... 30 Appendix B – MATLAB Code ......................................................................................... 35 Reference .......................................................................................................................... 45 v List of Tables Table 1: Algorithm performance for Image Fidelity. ...................................................... 16 Table 2: Algorithm performance under cropping attack. ................................................. 18 Table 3: Algorithm performance under JPEG compression ............................................ 24 vi List of Figures Figure 1: Annual number of papers published on watermarking during the 1990s........... 1 Figure 2: Lenna Image details............................................................................................ 3 Figure 3: Basic Algorithm Examples................................................................................. 8 Figure 4: Advanced Spatial Domain Algorithm Example. ................................................ 9 Figure 5: Advanced Frequency Domain Algorithm Example. .......................................... 9 Figure 6: Advanced Wavelet Domain Algorithm Example. ............................................ 10 Figure 7: Frequency-Spatial Combination Algorithm Example ...................................... 11 Figure 8: Wavelet-Frequency Combination Algorithm Example.................................... 11 Figure 9: Correlation vs. Watermark Strength Graphs .................................................... 15 Figure 10: Image Fidelity vs. Watermark Strength Graphs ............................................. 16 Figure 11: Correlation vs. % Cropped Graphs................................................................. 17 Figure 12: 75% Cropped Lenna image ............................................................................ 18 Figure 13: Correlation vs. Column # Removed Graphs .................................................. 19 Figure 14: Correlation vs. % Scaled Graphs .................................................................... 20 Figure 15: 60% Squeezed Lenna Image .......................................................................... 21 Figure 16: Correlation vs. % Squeezed Graphs ............................................................... 21 Figure 17: Correlation vs. Noise Strength Graphs ........................................................... 22 Figure 18: Correlation vs. JPEG Compression Quality Graphs ...................................... 23 Figure 19: 50 Rotated Lenna Image ................................................................................. 24 Figure 20: Correlation vs. Rotation Angel Graphs .......................................................... 25 Figure 21: % of Images vs. Correlation Graphs With No Attack .................................... 27 Figure 22: % of Images vs. Correlation Graphs With 70% JPEG Compression ............. 28 vii 1 Introduction In the past few years the digitization of multimedia has increased dramatically. Media can be shared between people around the world, within minutes, by use of computer networks such as the World Wide Web. Also digital media are easily and quickly edited by anyone with a computer. In such a time as this, copyright protection and copy control becomes very difficult. In an attempt to create a copyright protection system, researchers have turned to the field of digital watermarking. In the past few years, research into digital watermarking has increased dramatically. Figure Number of records in INSPEC database 1 illustrates the annual number of papers published on watermarking in the 1990s [5]. 300 250 200 150 100 50 0 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 Year Figure 1: Annual number of papers published on watermarking during the 1990s In short digital watermarking is embedding a hidden message within the digital media, identifying the owner or composer of the media. Currently there have been many algorithms proposed for watermarking image, video and audio. This report will focus only on grayscale image-watermarking algorithms. Presently watermarking algorithms embeds the watermark in one of spatial, frequency or wavelet domains. Some algorithms use info from multiple domains to embed the watermark. But what is the effectiveness of watermarks in the varying domains. Comparative analysis of algorithms from these various domains and combination of these domains are presented in this report. Particular algorithms were chosen from the spatial, frequency and wavelet domains. Also algorithms that combined frequency and wavelet domains as well as frequency and spatial domain were chosen. Descriptions of these algorithms can be found in chapter 3. 1 All algorithms are analyzed with a set of benchmark developed in chapter 4. The benchmark will focus on the following three criteria: 1) Quality of the watermarked image, compared to the original image. 2) Robustness of the watermarks against common image processing techniques. 3) Successful detection rate of the watermark, once embedded. Before proceeding to the presentation of the algorithms and the development of the benchmark, a brief introduction of the philosophy behind digital watermarking is presented in the next chapter. 2 2 Digital Watermarking Watermarking is not a new concept. Visible watermarks such as the ones appearing on money have been used to identify and even to protect media. However visible watermarks significantly alter the quality of the work. For this reason visible watermarks are usually placed on the edges of artworks to reduce the impact on the quality of the artwork. This leads to the easy removal of the watermark, simply by cropping the watermark out of the picture. A famous example of this is the picture of Lena Sjooblom, which is a popular standard test image used in image processing algorithms. The original Lena picture appeared as a centerfold in a Playboy magazine in 1972. On the lower right corner, of the original image, appeared a watermark identifying the picture (Figure 2). Later the image was scanned to be used as a test image in image processing algorithms. However when the image was scanned, only the top (Lena’s shoulders and up) was scanned (Figure 2). This cropped the watermark right out of the picture. Researchers in their papers use the scanned image without proper references to the owners of the image. Many researchers don’t even know the origins of this image. Figure 2: Lenna Image details (Left) Bottom right corner of the original lenna image. (Right) Scanned lenna image used in image processing papers. As this example illustrates a visible watermark on the edge of pictures is not an effective way of identifying the picture as it can easily be removed. So what other options are there? 3 Well, digital watermarking attempts to spread the copyright information through out the entire picture such that it can be detected even after cropping the image. 2.1 What is Digital Watermarking? Digital watermarking is defined as "the practice of imperceptibly altering a Work [the image] to embed a message about that Work." [5] Watermarking works in two phases, the embedding phase and the detecting phase. In the embedding phase a message and an image, called the cover work, is passed to the embedder algorithm. The algorithm embeds the message within the image resulting in the watermarked image. In the detecting phase, the watermarked image or any image is passed to the detector algorithm, which returns a message indicating whether a watermark is present in the image. It can be seen from the stated definition that watermarking is closely related to steganography, the art of concealed communication. However the meaning of watermarking differs slightly from the meaning of steganography. In steganography the hidden message has no relation to the medium in which the message is transmitted. Where as in watermarking the hidden message is always about the medium in which it is transmitted. A famous example of steganography comes from a story by Herodotus. In the story a slave is sent by his master, Histiaeus, to the city of Miletus with a secret message tattooed on his head. Once the message was tattooed on his head the slave let his hair grow back so that the message was concealed. Upon arriving in Miletus, the slave once again shaved his head and revealed the message to the city’s regent, Aristagoras. The message prompted Aristagoras to revolt against the Persian king. This is a prime example of steganography but not of watermarking. This situation is not considered watermarking because the message had nothing to do with the medium in which it was sent, mainly the slave himself. Had the message been the slaves name or the name of the slave’s owner then it would been considered an example of watermarking. 2.2 Properties of Watermarks Watermarks have three main properties fidelity, robustness, and detection error. These properties determine the effectiveness of the watermarks. Fidelity refers to the perceptual similarity between the original and watermarked work. A good watermarking algorithm will ensure that the original and watermarked images are perceptually the same. Robustness refers to the ability of the watermark to survive attacks on the watermarked image. Watermark should be robust enough to survive attacks such as JPEG compression, cropping, scaling etc. Detection error is measured in two ways false negatives and false positives. False negative is when the detector algorithm detects no watermark when there is a watermark present. False positive is when the detector algorithm detects a watermark when there is no watermark present. The detector algorithm should be able to prevent these types of errors. 4 2.3 Applications In this section three examples of watermark applications are presented. These applications are broadcast monitoring, content authentication and transaction tracking. The algorithms used in each example will be different because they have different requirements. 2.3.1 Broadcast Monitoring Consider a broadcasting studio, which plays advertisements for various companies. How can the company know for sure, that the studio did actually play the advertisement on the appointed time? One-way is to pay someone to watch the studio’s broadcast. This is not a feasible solution for a big company that wants hundreds of advertisements broadcast from different studios in a day. Another option for the company is to have all its advertisements watermarked. This way a computer can be setup to scan all TV broadcasting and try to detect the company's watermark. This way the company can tell if their advertisement was broadcasted. A sophisticated watermarking algorithm is not needed in this case because the broadcasted signals will only go through natural signal processing. It can be fairly cretin that no malicious attacks will be used to remove the watermark. 2.3.2 Content Authentication There are circumstances when the artist or composer of a media will want the ability to determine if their work has been altered. Sometimes even how the work was altered. In this way the author of the work can track any misuse of their works. Alteration of media can be determined by first embedding the media with a fragile watermark. A fragile watermark by design will degrade or change as the media is edited. Upon detection of the degraded or changed watermark one can determine that the work has been edited. Also if the fragile watermark is sophisticated enough that the change it goes through is constant under different editing techniques, it can be determined what editing technique was applied to the media. 2.3.3 Transaction Tracking The artist or composer of work might wish to sell copies of their work to the public. As copies are sold more and more pirated versions of the work will be created and sold. Pirated copies must be tracked and destroyed. In order to prevent piracy, the artist must track his works. Placing a unique watermark on each copy that is sold can do this. If a pirated copy is detected in the market, the pirated work can be scanned to see what watermark is on it. This way the original copy from which the pirated copies are being created can be tracked. Thus all sources of pirated copies can be eliminated. In this type of system the watermark must be very sophisticated and robust. It can be guaranteed that pirates will send the work will go through malicious attacks in an attempt to remove the watermark. 5 3 Algorithms Last chapter looked at watermarking at the system level. In this chapter a select set of watermarking system, used within this report, will be illustrated. In all a set of eight algorithms has been carefully chosen to illustrate the differences in the spatial, frequency and wavelet domains. These algorithms are divided into three categories basic, advance and combination. The basic category contains three algorithms, which are essentially the same; only difference is that a different domain is used for each algorithm. These algorithms will illustrate the basic similarities and differences of the different domains. The advance category contains three algorithms that illustrate how the three domains can be exploited. The combination category contains one algorithm that combines info from the frequency and wavelet domains to embed the watermark and one that combines the spatial and frequency domains. The scope of this report is the comparison of these algorithms therefore very little information is presented on the development of the algorithms. However the information necessary to code the algorithms are presented in this chapter. For detailed theory behind the development of the algorithm please refer to the referenced articles. All algorithms were coded in MATLAB and the code can be found in Appendix B. 3.1 Basic Algorithms There are three algorithms under this category. The algorithms are based on the same basic principals. These algorithms use the most basic principals of watermarking. They are by no means the most complex or sophisticated algorithms available. However since these algorithms are based on the same embedding and detection techniques, their analysis will show us the differences and similarities between watermarking in the various domains. 3.1.1 Embedder The embedder is based on the following formulas: I w I W I w DCT ( I ) W I w DWT ( I ) W The top formula represents watermarking in the spatial domain, middle formula in the frequency domain and the bottom formula in the wavelet domain. In the middle formula the image is converted to the 6 frequency domain using the 2-D discrete cosine transform [DCT(I)]. In the bottom formula the image is converted to the wavelet domain using a level three 2-D discrete wavelet transform [DWT(I)] with a Daubechies 8-tab filter. The watermark [W] is simply a randomly generated gaussian noise, the same size as the image. The scaled watermark [ W ] is simply added to the image or its transform, to create the watermarked image. 3.1.2 Detector The detector is based on linear correlation (Zlc). Z lc I w W MN where Iw is the watermarked image, W is the watermark and M and N are the dimensions of the image. Linear correlation of zero indicates watermark is not present and a value of about one represents that the watermark is present. To account for image deterioration after watermark is embedded, a threshold value of 0.75 is set. Therefore if Zlc 0.75 the watermark is present, else watermark is not present. Figures 3 illustrates the performance of the three algorithms. Each figure contains the original image, the watermark to be embedded and the watermarked image. Please note that the actual images are 512 by 512 in resolution they have been scaled down to fit within the structure of this report. 7 (a) (b) (d) (c) (e) Figure 3: Basic Algorithm Examples (a) Unwatermarked image. (b) Watermark. (c) Basic spatial domain watermarked image. (d) Basic Frequency domain watermarked image. (e) Basic wavelet domain watermarked image. 3.2 Advanced Algorithms The advance algorithms were obtained from watermarking papers published in the last few years. There are three algorithms in total, one for each domain. A brief outline of each algorithm is presented bellow. Some additional information on the development of the algorithms are presented in Appendix A. 3.2.1 Spatial Domain This algorithm was written by I. Pitas and was obtained from [6]. It is a statistical approach to watermarking in the spatial domain. This algorithm differs from the other seven algorithms used within this report in two ways. First the watermark is not a randomly generated gaussian noise, it is a set of ones and zeros. Second linear correlation is not used to detect the watermark. This algorithm uses hypothesis testing to determine the presence of a watermark. An example of the watermarked image is given in figure 4. watermarked is the one shown in figure 2. 8 The original image that was Figure 4: Advanced Spatial Domain Algorithm Example. 3.2.2 Frequency Domain This algorithm was developed by A. Piva, and was obtained form [1]. This algorithm is quite similar to the basic frequency domain algorithm presented in section 3.1. The difference is that in this algorithm the watermark is only embedded into a select region of the frequency domain. The watermarked image of Lenna using this algorithm is shown in Figure 5. Figure 5: Advanced Frequency Domain Algorithm Example. 3.2.3 Wavelet Domain The wavelet domain algorithm proposed by Rakesh Dugad, Krishna Ratakonda and Narendra Ahuja in [10], is used in this report. This algorithm embeds an N by M watermark (W) into an N by M image (I) to produce the watermarked image (Iw). Watermark is embedded into all wavelet domain coefficients grater than T 1. For the detection process all wavelet domain confidents grater than T 2 is used, where T2 > T1. Watermarked image of Lenna picture with T 1=40 is shown in Figure 6. 9 Figure 6: Advanced Wavelet Domain Algorithm Example. 3.3 Combination Algorithms The algorithms presented in this section, are algorithms that attempt to improve robustness, detection errors and fidelity by considering information from more than one domain. The first of these algorithms is an extension to the advanced frequency domain algorithm presented earlier. A visual mask, which will increase the watermark strength without decreasing the image fidelity, is added to the advanced frequency algorithm. This way the detection error is reduced with little effect on the fidelity. The second of this algorithm will attempt to combine the wavelet domain and frequency domain to increase robustness. 3.3.1 Frequency-Spatial Domain Algorithm This algorithm as with the advanced frequency domain algorithm was proposed by A. Piva in [1]. The detection algorithm is identical to the advanced frequency domain algorithm. The embeder algorithm is also identical to the advanced frequency domain algorithm with one exception. An additional step has been added to the end of the advanced frequency domain algorithm. This additional step will create a new '' watermarked image I w by applying a mask (M) to the watermarked image Iw, produced by the advanced frequency domain embeder. The mask is added according to the following formula: I w'' (1 M ) I MI w The mask M is generated in the spatial domain. Its purpose is to use the HVS to embed the watermark more strongly on regions of low noise sensitivity and less strongly on regions of high noise sensitivity. Mask Generation A simple mask based on the variance of luminance value within sub-regions of the image has been chosen. For each pixel Ii,j, create block matrix of dimensions R by R with I i,j at the matrix’s center. The sample variance of the block matrix becomes the value of the mask at location M i,j. Once all block sample variance has been calculated, normalize M by dividing all elements of M with the largest element in M. 10 Figure 7: Frequency-Spatial Combination Algorithm Example (Left) The mask. (Right) Watermarked image. 3.3.2 Wavelet-Frequency Domain Algorithm This algorithms proposed by V. Fotopoulos and A. N. Skodras in [12], combines the DWT and DCT to embed the watermark. By combining the two domains they are able to embed the watermark in a grater number of transformed coefficients. Since a large number of coefficients are used to embed the watermark, the algorithm is claimed to be very robust watermarking scheme. Refer to appendix A for some details on this algorithm. Figure 8: Wavelet-Frequency Combination Algorithm Example 11 4 Benchmark Since varieties of algorithms are to be compared, a standard benchmark is necessary. The benchmark will be based on the properties of watermarks, mainly fidelity, robustness, false negative and false positive. All algorithms will be run under this one benchmark. The benchmark will focus mainly on natural image editing techniques and not on malicious attacks. 4.1 Fidelity Image fidelity (IF) will be measured using the normalized mean square error (NMSE). IF 1 NMSE 1 (I m,n I m' ,n ) 2 m,n I 2 m,n m,n where I is the original image, I’ is the watermarked image and m and n are the dimensions of the image. The advantage of using the NMSE is that the calculation is fast and simple. However the disadvantage is that NMSE does not incorporate any sort of human visual system (HVS). Without a HVS the image fidelity is based on differences between the pixel values. This does not account for the fact that the human eye can only see changes in a certain region of the spatial frequency domain. Image comparison metrics involving the HVS are presented in [11 4]. Unfortunately due to the complex calculations necessary for these metrics, they will not be considered in this report. 4.1.1 Fidelity vs. Correlation Image fidelity will be measured in relation to the correlation value. The correlation value determines the strength at which the watermark is detected after being embedded in an image. Image fidelity will be measured as the correlation value changes. These measurements will be graphed for each algorithm. For a given correlation value the higher the IF the better the algorithm. 4.2 Robustness The watermark should be robust enough to survive standard image processing techniques. These imageprocessing techniques such as cropping are referred to as attacks in this report. This report will consider the following attacks: 12 1. Cropping 2. JPEG compression 3. Column deletion 4. Scaling (Resizing) 5. Rotation 6. Addition of Guessing Noise 7. Squeezing 4.2.1 Robustness vs. Correlation Robustness as with fidelity will be measured in relation to the correlation value. The correlation value will be measured as the strength of the attack changes. All other variables including the watermark strength will be held constant. These measurements will be plotted to create the robustness vs. correlation graph. For a given attack strength the higher the correlation value the better. 4.3 False Positive / False Negative False positive and false negative rate will be based on experimental data. A set of 100 images will be run through the detector with and without a watermark. The overlap in the correlation values will be used to determine the false positive and false negative rates. Another method of measuring the false positive and false negative rates is through probability calculations. Unfortunately this calculation depends on the type of algorithm used to detect the watermark. Therefore it becomes difficult to compare two different algorithms based on the probability calculations. As a result it was determined that the experimental data would present an unbiased conclusion. The experiment will be held in two phases. Phase one will involve no attacks. The experiment of phase one has two steps. In step one 100 unwatermarked images will be sent through the detector algorithm and the correlation value recorded. In step two 100 watermarked images will be sent through the detector algorithm and the correlation value recorded. The overlap of these two sets of correlation values will determine the rate of false positive and false negative. Phase two will involve attacks. This phase is exactly the same, as phase one but the image will undergo an attack of a set strength before passing through the detector algorithm. This attack is necessary because it will force more occurrences of false negatives and false positives. This experimental test procedure was obtained from [5]. The reason it works is there needs to be a defined correlation value to determine if the watermark exists, or not. That is to say if calculated correlation less that x there is no watermark and if it is greater than x there is a watermark. If there is an overlap, the presence of watermark cannot be determined, since for a given correlation value there is a possibility the watermark does exist and at the same time there is a possibility the watermark does not exist. 13 5 Data Presentation and Analysis Now that the algorithms and the benchmark have been presented, it is time to determine how well the algorithms perform under the benchmark conditions. Trough out this chapter all examples will be illustrated with the lenna picture. However the actual result was obtained by the average result from applying the algorithm on multiple images from various sources. Also note that it was determined that presenting eight sets of graphs on one axis will be too difficult to read. Therefore the each category of algorithms will be graphed on separate axis (i.e. all basic algorithm data are presented on one axis, all advanced algorithm data on another axis and combination algorithm data on the third set of axis). 5.1 Fidelity In the benchmark it was determined that IF will be measured relative to the correlation value. However, the correlation value is hard variable to control. The correlation will depend on the algorithm and the actual image being watermarked. The image cannot be controlled since this analysis is to determine how effective the algorithms are on any arbitrary image. The only option left is to control the algorithm, preferably through some input. Note that all basic algorithms, all combination algorithms and the advance frequency and wavelet algorithm use a watermark strength value . The advanced spatial algorithm also has a similar value, which is t. Though this is actually the expected tolerance in the detection process, for this section consider this value as watermark strength. It can be argued that this watermark strength value is directly proportional to the correlation value. This is because as the watermark strength increases, the watermark should be more visible to the detector. This argument can be verified by plotting the correlation as watermark strength varies. Figure 9 contains a plot of linear correlation as watermark strength varies from 0 to 1.8. It can be seen from these graphs that indeed watermark strength is directly proportional to the correlation value. 14 Figure 9: Correlation vs. Watermark Strength Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms Since watermark strength is directly proportional to the correlation value, plotting IF vs. watermark strength will be directly proportional to plotting IF vs. correlation. Figure 10 presents the IF vs. watermark strength data. From the graph it can be noted that all the basic algorithms have about the same IF for a given . From these graphs it can also be noted that the IF for the basic algorithms are much higher than for any other algorithms. Table 1 lists all the algorithms from the highest IF to the lowest IF for a given . 15 Figure 10: Image Fidelity vs. Watermark Strength Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms Table 1: Algorithm performance for Image Fidelity. Priority Algorithm 1 Basic spatial, frequency & wavelet 2 3 4 5 Comments There is little difference between the performance of these three algorithms. Frequency-spatial combination Advanced spatial Wavelet-Frequency combination Advanced wavelet & frequency The advanced frequency algorithm performs a little bit better than the advanced wavelet algorithm, but the difference is very small. This result suggests that the basic algorithms have a higher IF for a given also be noted that for a given . However it must the basic algorithms have a much lower correlation value, as can be seen 16 from Figure 9. This would suggest that the basic algorithms are giving up robustness for IF (higher the correlation value, the easier it is for the detector algorithm to detect the watermark and thus more robust). 5.2 Robustness Robustness as discussed in the benchmark will be measured under different attacks by measuring the correlation value. We will look at cropping, column removal, scaling, squeezing, addition of guassian noise, JPEG compression and small angle rotation in that order. 5.2.1 Cropping The lenna image was watermarked using each of the embeder then it was sent through the detector algorithms after varying levels of cropping. The image was cropped by 0% to 75% at 5% incremental (that is to say 0%, 5%, 15% … 75%). Figure 11 presents the percentage cropped vs. correlation data. Figure 11: Correlation vs. % Cropped Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms Notice the horizontal line set at 0.75 on all the graphs. This indicates the watermark detection tolerance on all the algorithms. This value is set by the user and for this report it is always 0.75. Any 17 correlation value below this tolerance indicates the absence of the watermark and any value above it indicates the presence of the watermark. It is very clear from the graphs that the advanced wavelet domain algorithm performs better under crop attacks than any other algorithms. The advanced frequency algorithm has a fairly good performance as well since the correlation value never drops below the tolerance. Note that the watermark strength for all basic algorithms was 1 and 0.2 for the rest of the algorithms. This was necessary because the watermark strength of 0.2 for the basic algorithms will result in correlation values below the tolerance even before the image is cropped. Table 2 lists the algorithms from the best to worst under cropping attack. Table 2: Algorithm performance under cropping attack. Priority Algorithm 1 Advanced wavelet 2 3 Advanced frequency Both combination 4 5 Basic spatial & frequency Advanced spatial and basic wavelet Comments Several magnitudes better than any algorithms. Very similar results as basic spatial & frequency algorithms but is set higher since watermark strength during the test was lower for this. Figure 12 shows the Lenna image 75% cropped. This figure is to give the reader a visual sense of how robust the various algorithms are under cropping attack. Figure 12: 75% Cropped Lenna image 5.2.2 Column Removal The lenna image was once again watermarked under each embeder algorithms then sent through the detector algorithms after the column removal attack. Column removal attack refers to removing an entire 18 column of pixel value from the image. That is to say if you have a 512 by 512 image after a column of pixel value is removed you will end up with a 512 by 511 image. In this experiment column 101, 106, 111, 116, 121 and 126 was removed one at a time from a watermarked image before sending it through the detector algorithm. The resulting correlation value vs. column removed data appears in Figure 13. Figure 13: Correlation vs. Column # Removed Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms From the graphs it can be seen that only the advanced frequency, advanced wavelet and the frequency spatial algorithms meets the required tolerance of 0.75. Of these algorithm the advanced wavelet has the best performance followed by the advanced frequency and the frequency spatial combination algorithm. 5.2.3 Scaling The Lenna image was once again watermarked under each embeder algorithms then sent through the detector algorithms after the scaling attack. The scaling attack consisted of scaling the image to a smaller size then back up to the original size. In this scaling process the image will loose some details, which might affect the detectors ability to detect the watermark. 19 In this experiment the image was scaled by 0% to 60% with 5% increments (ie scaled by 0%, 5%…60%). Then the image was scaled back to the original size of 512 by 512. The correlation vs. percentage scaled data is presented in Figure 14. Figure 14: Correlation vs. % Scaled Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms From the graphs it can be seen that only the advanced frequency, advanced wavelet and the frequency spatial algorithms meets the required tolerance of 0.75. Of these algorithm the advanced wavelet has the best performance followed by the advanced frequency and the frequency spatial combination algorithm. 5.2.4 Squeeze The lenna image was watermarked under each embeder algorithms then sent through the detector algorithms after the squeeze attack. The squeeze attack consisted of scaling the image to a smaller size. A lot of image data is lost in this process. Unlike the scaling attack these lost information is not reconstructed since the image is not scaled back to the original size. Figure 15 is an image of this attack. 20 Figure 15: 60% Squeezed Lenna Image In this experiment the image was squeezed by 0% to 60% at 5% increments. The correlation vs. percentage squeezed is presented in Figure 16. Figure 16: Correlation vs. % Squeezed Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms 21 It is quite clear from the graph that none of the algorithm can embed a watermark that will survive the squeeze attack. Though the advanced wavelet domain algorithm did detect the watermark (correlation value grater than the tolerance) at certain squeeze levels, it is too chaotic to be dependable. 5.2.5 Gausian Noise The lenna image was watermarked under each embeder algorithms then sent through the detector algorithms after the gaussian noise attack. The guassian noise attack consisted of adding a randomly generated guassian noise to the watermarked image at varying strengths. This is a typical attack resulting from transmitting the watermarked image. Gausian Noise (N) was added to the image using the formula: I w' I w N where ranged from 0 to 10. The resulting correlation vs. noise strength data are presented in Figure 17. Figure 17: Correlation vs. Noise Strength Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms From the graph it can be seen that the correlation values are all well above the tolerance. Notice that for the combination algorithms and the advanced wavelet algorithm, the correlation value decreases quite a bit. However they are still much greater than the tolerance value. 22 For the basic algorithm something unique happens, the correlation actually increases. This is because the watermark for the basic algorithms is also a gussian noise. Though the watermark and the noise (N) are different they would complement each other at certain reigns resulting in an increase in the correlation value. The basic algorithms seem to be the best in the case of a gaussian noise attack. However the best result under this attack should be a near constant correlation. Consider the unique case of the basic algorithms as an anomaly since it will not occur if the watermark is something other than gussian noise. Therefore the best result was obtained from the advanced spatial and the advanced frequency algorithms, because their correlation value behaved as a near constant. 5.2.6 JPEG Compression The lenna image in tiff format was watermarked under each embeder algorithms then sent through the detector algorithms after JPEG compression. During JPEG compression image data will be lost which will affect the detector’s ability to correctly detect the watermark. The image was compressed with quality of 100% to 40%. Hundred being the compressed image having a high quality to 40 being compressed image having a low quality. The correlation vs. quality deterioration is presented in Figure 18. Figure 18: Correlation vs. JPEG Compression Quality Graphs 23 (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms From the graph it can be seen that only advanced frequency, advanced wavelet and frequencyspatial combination algorithms seem very robust to JPEG compression. The rest of the algorithms falls bellow the tolerance value. Table 3 lists the algorithms from the best to worst under JPEG compression. Table 3: Algorithm performance under JPEG compression Priority 1 2 Algorithm Advanced wavelet and frequency Frequency-spatial 3 4 5 Advanced spatial Wavelet-frequency All basic 5.2.7 Comment Both have fairly small percentage drop in correlation value. Drops close to the tolerance but still above it. No good under JPEG compression Small Angle Rotations The lenna image was watermarked under each embeder algorithms then sent through the detector algorithms after a rotation. The rotation varied from –50 to 50 in increments of 10, where the +’ve direction is counter clockwise. Figure 19 illustrates the after shot of the rotated image. Note that image is cropped to the original size after rotation. Figure 19: 50 Rotated Lenna Image The correlation vs. rotation angle data is presented in Figure 20. From the graphs it is quite clear that none of the algorithms, with the exception of the advanced wavelet algorithm, are robust against small rotations. The advanced wavelet algorithm is somewhat robust against small rotation; however even it’s correlation value drops dramatically under small angle rotations. 24 Figure 20: Correlation vs. Rotation Angel Graphs (Top Left) Basic Algorithms. (Top Right) Advanced Algorithms. (Bottom) Combination Algorithms 5.3 False Negative / False Positive Both phases of false negative and false positive experiment as described previously was carried out. The results are presented in Figure 21 & 22. For Figure 21 no attack was used. From this graph note that there is no significant overlap of correlation value between the watermarked and unwatermarked images, with the exception of the combined wavelet frequency domain algorithm. This would indicate that the false negative error and false positive error under normal conditions are very low for these algorithms. For Figure 22 70% JPEG compression attack was used. From these graphs note that there are overlaps of correlation values between the watermarked and unwatermaed images, for almost all algorithms. Only good result is obtained from the advanced wavelet domain, which has no overlap. In fact it has a significant boundary between the watermarked correlation values and the unwatermarked correlation values. 25 The advanced frequency algorithm and the frequency-spatial combination algorithm also have fairly good results. However it does not have a boundary between the watermarked correlation values and unwatermarked correlation values, as is the case with the advanced wavelet algorithm. (a) (b) (c) (d) (e) (f) 26 (g) (h) Figure 21: % of Images vs. Correlation Graphs With No Attack (a) Basic Spatial Algorithm. (b) Basic Frequency Algorithm. (c) Basic Wavelet Algorithm. (d) Advanced Spatial Algorithm. (e) Advanced Frequency Algorithm. (f) Advanced Wavelet Algorithm. (g) FrequencySpatial Combination Algorithm. (h) Wavelet-Frequency Combination Algorithm. Note that all algorithms with the exception of (e), (g) and especially (h) have a large separation between the watermarked and unwatermarked correlation values. (a) (b) (c) (d) 27 (e) (f) (g) (h) Figure 22: % of Images vs. Correlation Graphs With 70% JPEG Compression (a) Basic Spatial Algorithm. (b) Basic Frequency Algorithm. (c) Basic Wavelet Algorithm. (d) Advanced Spatial Algorithm. (e) Advanced Frequency Algorithm. (f) Advanced Wavelet Algorithm. (g) FrequencySpatial Combination Algorithm. (h) Wavelet-Frequency Combination Algorithm. Note that only algorithms (f) has a large separation between the watermarked and unwatermarked correlation values. 28 6 Conclusion Watermarking algorithms in the spatial, frequency and wavelet domains were tested for their effectiveness. All together eight algorithms were chosen, three basic algorithms one in each domain, there advanced algorithms one in each domain and two combination algorithms. These algorithms were tested for fidelity, robustness and detection errors. Fidelity was tested using the normalized mean square error (NMSE) method, which is not the best test of fidelity but is the easiest. Robustness was tested under the following attacks: cropping, JPEG compression, column deletion, scaling (Resizing), rotation, addition of Guessing Noise and squeezing. Detection errors were tested by the false positive and false negative rates, which is the measure of how much overlap there is between the correlation values of unwatermarked and watermarked images. It was found that the basic algorithms (algorithms that simply added gaussian noise to the spatial, frequency or wavelet domain of the image) had the best fidelity, however these algorithms are not very robust and also have high detection errors. Overall the advanced wavelet domain algorithm (which added the watermark to specific regions of the wavelet domain) was the most robust and less prone to detection error. The advanced wavelet domain algorithm however did have the lowest image fidelity. Taking into account that the NMSE compares only the differences in the pixel values of the watermarked and unwatermarked images and does not account for the HVS, it can be said that the advanced wavelet domain algorithm has the best performance. This asks the question why the basic wavelet algorithm did not perform as well as the advanced wavelet algorithm. The domain in which the watermark is embedded does not seem to affect the watermark’s robustness as much as the region of the domain in which the watermark is embedded. This is proven by the fact that the advanced wavelet domain algorithm, which embedded the watermark in all coefficients grater than 40, proved more robust than the basic wavelet domain algorithm, which embedded the watermark in all coefficients of the wavelet domain. The same was true with the frequency domain algorithms. The advanced frequency algorithm, which embedded the watermark near the top left corner of the frequency domain, proved more robust than the basic frequency domain algorithm, which embedded the watermark in all coefficients of the frequency domain. A future study on how regions of the wavelet and frequency domain affect watermarking algorithms might prove interesting. 29 Appendix A – Algorithm Details Advanced Spatial Domain Algorithm Following is a step-by-step instruction on how the advanced spatial domain algorithm works. Embedding Process 1) Create the watermark. A watermark S of size N by M, where M and N are the dimensions of the image to be watermarked, is randomly generated. The elements of matrix S consists of “ones” and “zeros” such that the number of “ones” equals the number of “zeros.” S {snm , n {0,1, where, 2) , N 1}, m {0,1, , M 1}} snm {0,1} . Subdivide the image into two vectors A and B. The image is represented as: I {xnm , n {0,1, where, xnm {0,1, , N 1}, m {0,1, , M 1}} , L} . The L represents the maximum luminance value of 255. Note only gray scale images are considered. The image I is subdivided into two sets A and B such that: A {xnm I , snm 1} B {xnm I , snm 0} 3) Create the watermarked image Is. The watermarked image [Is] is obtained using the formula: Is C B where, CkA k 2 wt t tolerance ( sa2 sb2 ) NM / 2 2 w 30 The sa denotes the sample variance of subset A and sb represents the sample variance of B. The user defines the tolerance, the recommended level is 0.75 and it is also the value used primarily within this report. Detection Process 1) Calcualte the correlation value q. q w w ( sc2 sb2 ) NM / 2 w c b w2 These calculations are based on the theory of Hypothesis Testing. Also note x is the mean of subset X, and sx is the sample variance of subset X. The value q will be referred to as the correlation value. 2) Determine if the watermark is present. If q < t (t = user defined tolerance from the embedding process) then the watermark is not present, else the watermark is present. Advanced Frequency Domain Algorithm Following is a step-by-step instruction on how the advanced frequency domain algorithm works. Embedding Process 1) Transform the image into the frequency domain. The image I is transformed into the frequency domain using the 2-D DCT. 2) Scan the image into a vector. The transformed image is then scanned using the zigzag scan commonly used in JPEG compression algorithms. 3) Obtain vector T. The first L+M coefficients of the zigzag scan are obtained to produce vector T. T {t1 , t2 , 4) , t L , t L1 , , tL M } Embed the watermark. Randomly generated watermark vector, X {x1 , x2 , M elements of vector T using the formula: 31 , xM } , is embedded to the last tL' i tLi tLi xi , i = 1…M 5) Transform the watermarked image back to the spatial domain. Vector T’ is then reinserted into the zigzag scan. Once the altered DCT is obtained, the inverse DCT is performed to obtain the watermarked image. Detection Process 1) Transformation into the freqyency domain. The watermarked image (Iw) is transformed into the frequency domain using the 2-D DCT. 2) The zigzag scan. The transformed image is then scanned using the zigzag scan. 3) Generate vector T’. The vector T’ is generated from the (L+1)th element to the (L+M)th element of the zigzag scan. 4) Calcualte correlation. Linear correlation is calculated using the T’ vector. Linear correlation (Zlc) is calculated as: Z lc W T ' M where W is the watermark. 5) Determine the presence of the watermark. If Zlc > t (tolerance) then the watermark is present else watermark is not present. Advanced Wavelet Domain Algorithm Following is a step-by-step instruction on how the advanced wavelet domain algorithm works. Embedding Process The image I is transformed into the wavelet domain using a three level 2-D DWT with a Daubechies 8-tab filter. The resulting transformed image (I’) will be the same size as I. Create a watermark W, randomly generated gussian noise that is the same dimensions as I. For the watermarking process ignore the low pass sub-band of IDWT. Embed the watermark into all coefficients that are grater than T 1: I i'' I i' I i' Wi 32 where I runs over all DWT coefficients > T 1. Note that not all elements of the generated watermark are embedded within the image. Once the watermark W is embedded simply take the inverse discrete wavelet transform (IDWT) to get the watermarked image Iw. Detection Process ' For the detection process transform Iw to I w using a three level 2-D DWT with a Daubechies 8-tab filter. As with the embedding process ignore the low pass sub-band of the transformed image. Use linear correlation formula to find the correlation between the watermark and all coefficients of the transformed image grater than T 2, where T2 > T1. Mathematically: Z 1 MN I ' wi Wi i where i runs over all coefficients grater than T 2 and the dimensions of the image Iw is M by N. As with the previous algorithms if Z > t the tolerance the watermark is present else the watermark is not present. Wavelet-Frequency Domain Algorithm Following is a step-by-step instruction on how the wavelet frequency domain algorithm works. Embedding Process 1) Transform the image into the wavelet domain. Transform the image (I) using a level one DWT with a Haar filter. Call the resulting image IDWT, which is the combination of the 4 sub-bands (LL, HL, LH, HH). 2) Transform each of the 4 bands from the DWT into the frequency domain. Transform each of the 4 bands of the IDWT to the frequency using the DCT, to obtain LL HL LH HH I DCT , I DCT , I DCT and I DCT . 3) Generate the watermark. Watermark (W) is a randomly generated gaussian noise of dimension 1 by M. The value of M will depend on the image size, in this implementation M = 20000. 4) Scan the transformed images. LL HL LH HH Scan I DCT , I DCT , I DCT and I DCT using the zigzag scan to obtain T LL, THL, TLH and THH. 33 5) Embed the watermark. Watermark (W) is embedded into the vectors TLL, THL, TLH and THH using the formula: ti' ti ti wi where 5000<i<20001, 6) t {TLL , THL , TLH , THH } , 0.1 for TLL and 0.2 for the rest. Obtain the watermarked image Iw by taking the IDCT and IDWT. Detection Process 1) Transform the image (I) into the wavelet domain by using a level one DWT with a Haar filter. Call the resulting image IDWT, which is the combination of the 4 sub-bands (LL, HL, LH, HH). 2) LL HL Transform each of the 4 bands of the IDWT to the frequency using the DCT, to obtain I DCT , I DCT , LH HH I DCT and I DCT . 3) LL HL LH Scan elements 5000 to 20001, exclusive, from the transformed image I DCT , I DCT , I DCT and HH I DCT using the zigzag scan to obtain T LL, THL, TLH and THH. 4) Calculate the correlation value (Z) by averaging the linear correlation value from the vectors T LL, THL, TLH and THH. 5) If Z>t (tolerance) then watermark is present else watermark is not present. 34 Appendix B – MATLAB Code Basic Spatial Domain Algorithm function [Iw] = E_BASIC1(image, seed, alpha) [M, N] = size(image); % create random watermark based on seed randn('state', seed); W = randn(M, N); % add watermark to spatial domain with strength alpha Iw = double(image) + alpha*W; Iw = uint8(Iw); function Z = D_BASIC1(Iw, seed) Iw = double(Iw); [M,N] = size(Iw); randn('state', seed); W = randn(M,N); Z = (1/(M*N))*sum(dot(Iw, W)); Basic Frequency Domain Algorithm function [Iw] = E_BASIC2(image, seed, alpha) [M, N] = size(image); I = dct2(image); % create random watermark based on seed randn('state', seed); W = randn(M, N); % add watermark to frequency domain with strength alpha Iw = I + alpha*W; Iw = idct2(Iw); Iw = uint8(Iw); function Z = D_BASIC2(Iw, seed) [M,N] = size(Iw); Iw = dct2(Iw); randn('state', seed); W = randn(M,N); Z = (1/(M*N))*sum(dot(Iw, W)); Basic Wavelet Domain Algorithm function [Iw] = E_BASIC3(image, seed, alpha) dwtmode('per'); % Get size of image 35 [M, N] = size(image); % perform a level-3 DWT with Daubechies 8-tap filter [C, S] = wavedec2(image, 3, 'db8'); % get the Horizontal, Vertical and Diagonal components at level 3 [H, V, D] = detcoef2('all', C, S, 3); % create random watermark randn('state', seed); W = randn(1, (M*N-prod(size(H)))); lowpass = C(1:prod(size(H))); rest = C(prod(size(H))+1:end); w_rest = rest + alpha*W; Iw = [lowpass w_rest]; Iw = waverec2(Iw,S,'db8'); Iw = uint8(Iw); function Z = D_BASIC3(Iw, seed) dwtmode('per'); % Get size of image [M, N] = size(Iw); % perform a level-3 DWT with Daubechies 8-tap filter [C, S] = wavedec2(Iw, 3, 'db8'); % get the Horizontal, Vertical and Diagonal components at level 3 [H, V, D] = detcoef2('all', C, S, 3); % create random watermark randn('state', seed); W = randn(1, (M*N-prod(size(H)))); Iw = C(prod(size(H))+1:end); Z = (1/(M*N))*sum(dot(Iw, W)); Advanced Spatial Domain Algorithm % Algorithm #2 based on the paper: % % I Pitas. A method for signature casting on digital images. % In Proc. of the IEEE Int. Conf. on Image Processing, pages 215--218, % Lausanne, Switzerland, September 1996. http://citeseer.nj.nec.com/pitas96method.html % Follwoing is the watermark embedder for Algorithm #2 % requires random2.m file function [Iw] = E_ALG2(image, seed, t) Id = double(image); [M N] = size(Id); P = M*N/2; W = random2(M, N, seed); temp = -1*ones(M, N); W_opp = abs(W+temp); A = Id.*W; B = Id.*W_opp; %calculate means meanA = sum(sum(A))/P; meanB = sum(sum(A))/P; %calculate sample variance temp = A - meanA*W; temp = temp.*temp; 36 temp = sum(sum(temp)); sample_var_A = temp/(P-1); temp = B - meanB*W_opp; temp = temp.*temp; temp = sum(sum(temp)); sample_var_B = temp/(P-1); sig_w = sqrt((sample_var_A*sample_var_A+sample_var_B*sample_var_B)/P); k = ceil(2*sig_w*t); C = k*W + A; Is = C + B; Iw = uint8(Is); % requires random2.m file function [q] = D_ALG2(image, seed) Is = double(image); [M N] = size(Is); P = M*N/2; W = random2(M, N, seed); temp = -1*ones(M, N); W_opp = abs(W+temp); C = Is.*W; B = Is.*W_opp; meanC = sum(sum(C))/P; meanB = sum(sum(B))/P; meanW = meanC - meanB; temp = C - meanC*W; temp = temp.*temp; temp = sum(sum(temp)); sample_var_C = temp/(P-1); temp = B - meanB*W_opp; temp = temp.*temp; temp = sum(sum(temp)); sample_var_B = temp/(P-1); sig_w = sqrt((sample_var_C*sample_var_C+sample_var_B*sample_var_B)/P); q = meanW/sig_w; function W = random2(M, N, seed) W = randint(M, N, [0 1], seed); onesNeeded = round(M*N/2); onesActual = sum(sum(W)); diff = onesNeeded - onesActual; x = randint(1, 1, [0 2], N); if diff ~= 0 if diff > 0 for i = 1:+x:M for j = 1:+x:N if W(i,j) == 0 if diff ~= 0 W(i,j) = 1; diff = diff - 1; end end end end else 37 for i = 1:+x:M for j = 1:+x:N if W(i,j) == 0 if diff ~= 0 W(i,j) = 0; diff = diff + 1; end end end end end end Advanced Frequency Domain Algorithm % Algorithm #4 based on the paper: % % A. Piva, "A DCT-Domain Watermarking System for Copyright Protection of Digital Images" % PhD Thesis in Computer Science and Telecommunications Engineering, % University of Florence, December 1998. http://lci.die.unifi.it/~piva/mycv.html#PAPERS % Follwoing is the watermark embedder for Algorithm #4 % requires piva_embed.m file function [Iw] = E_ALG4(image, seed, alpha, start_element, num_element) I = dct2(image); % create the watermark based on seed randn('state', seed); W = randn(1, num_element); % embed watermark iw = piva_embed(I, start_element, num_element, alpha, W); % ouput watermarked image Iw = idct2(iw); Iw = uint8(Iw); % requires zigzag.m file function [z] = D_ALG4(image, seed, start_element, num_element) Iw = dct2(image); % get the zig-zag scaned vector containing the watermark zig = zigzag(Iw, start_element, num_element); % the watermark that is belived to be in the image randn('state', seed); W = randn(1, num_element); % calculate linear corrilation z = dot(W,zig)/num_element; function [I] = piva_embed(I, start_element, num_element, alpha, w) end_element = start_element + num_element; [max_row max_col] = size(I); % current location on the image of the zig-zag scan is stored in y, x x = 1; y = 1; % current element on the zig-zag scan t =1; % current element in watermark vector to be embeded 38 tt = 1; direction = 0; %0 down, 1 up % skip as many elements as possible at the begening % ie will start much closer to start_element if (start_element>0) % solve the arithmetic series for n, start_element is the sum in the series n = floor((-1 + sqrt(1+8*start_element))/2); % ensure that picture size has not been exceeded if (n > min(max_row, max_col)) n = min(max_row, max_col); end % determine wether to start on row 1 or row n if (mod(n,2) == 0) y = n; x = 1; else x = n; y = 1; end end % scan in a zig-zag patter and alter the required elements while (x>0 & x<=max_col & y>0 & y<=max_row & (x*y)<(max_col*max_row) & t <= end_element) if (x==1 & y==1) if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; end if (x == max_col) y = y+1; direction = 0; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; elseif (y==max_row) x = x+1; direction = 1; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; elseif (y==1) x = x+1; direction = 0; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end 39 t = t+1; elseif (x == 1) y = y+1; direction = 1; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; end if (direction == 0 & (y+1)<=max_row) x = x-1; y = y+1; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; elseif (direction == 1 & (x+1)<=max_col) x = x+1; y = y-1; if (t > start_element & t <=end_element) %alter I(y,x) I(y,x) = I(y,x) + alpha*abs(I(y,x))*w(1,tt); tt = tt+1; end t = t+1; end end function [zig] = zigzag(I, start_element, num_element) zig = zeros(1, num_element); end_element = start_element + num_element; [max_row max_col] = size(I); zig = zeros(1,num_element); x = 1; y = 1; t =1; tt = 1; direction = 0; %0 down, 1 up k = 0; if (start_element>0) n = floor((-1 + sqrt(1+8*start_element))/2); if (n > min(max_row, max_col)) n = min(max_row, max_col); end if (mod(n,2) == 0) y = n; x = 1; else x = n; y = 1; end end 40 while (x>0 & x<=max_col & y>0 & y<=max_row & (x*y)<(max_col*max_row) & t <= end_element) if (x==1 & y==1) if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; end if (x == max_col) y = y+1; direction = 0; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; elseif (y==max_row) x = x+1; direction = 1; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; elseif (y==1) x = x+1; direction = 0; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; elseif (x == 1) y = y+1; direction = 1; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; end if (direction == 0 & (y+1)<=max_row) x = x-1; y = y+1; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end t = t+1; elseif (direction == 1 & (x+1)<=max_col) x = x+1; y = y-1; if (t > start_element & t <=end_element) zig(1,tt) = I(y,x); tt = tt+1; end 41 t = t+1; end end Advanced Wavelet Domain Algorithm Algorithm #1 based on the paper: % % R. Dugad, Krishna Ratakonda, Narendra Ahuja, "A New Wavelet Based Scheme for Watermarking Images", % University of Illinois at Urbana-Champaign http://citeseer.nj.nec.com/97595.html % Follwoing is the watermark embedder for Algorithm #1 function [Iw] = E_ALG1(image, seed, T1, alpha) dwtmode('per'); % Get size of image [M, N] = size(image); numPixel = M*N; % perform a level-3 DWT with Daubechies 8-tap filter [C, S] = wavedec2(image, 3, 'db8'); % get the Horizontal, Vertical and Diagonal components at level 3 [H, V, D] = detcoef2('all', C, S, 3); lowpassEnd = prod(size(H))+1; % create random watermark randn('state', seed); W = randn(1, numPixel); for i = lowpassEnd:numPixel if C(i) > T1 C(i) = C(i) + alpha*abs(C(i))*W(i); end end Iw = waverec2(C,S,'db8'); Iw = uint8(Iw); function [z] = D_ALG1(image, T2, seed) product = 0; gt2 = 0; [M, N] = size(image); numPixel = M*N; [C, S] = wavedec2(image, 3, 'db8'); [H, V, D] = detcoef2('all', C, S, 3); lowpassEnd = prod(size(H))+1; % create random watermark randn('state', seed); W = randn(1, numPixel); for i = lowpassEnd:numPixel if C(i) > T2 product = product + C(i)*W(i); gt2 = gt2+1; end end z = product/gt2; 42 Wavelet-Frequency Combination Algorithm function [Iw] = E_ALG3(image, seed, alphaLL, alphaR, start_element, num_element) dwtmode('per'); [C, S] = wavedec2(image, 1, 'haar'); A = appcoef2(C, S, 'haar', 1); [H, V, D] = detcoef2('all', C, S, 1); [M, N] = size(H); a = dct2(A); h = dct2(H); v = dct2(V); d = dct2(D); % create the watermark based on seed randn('state', seed); W = randn(1, num_element); % embed watermark aw = piva_embed(a, start_element, num_element, alphaLL, W); hw = piva_embed(h, start_element, num_element, alphaR, W); vw = piva_embed(v, start_element, num_element, alphaR, W); dw = piva_embed(d, start_element, num_element, alphaR, W); a = idct2(aw); h = idct2(hw); v = idct2(vw); d = idct2(dw); NC = [(a(1:M,1))']; for i = 2:N NC = [NC (a(1:M,i))']; end for i = 1:N NC = [NC (h(1:M,i))']; end for i = 1:N NC = [NC (v(1:M,i))']; end for i = 1:N NC = [NC (d(1:M,i))']; end Iw = waverec2(NC,S,'haar'); Iw = uint8(Iw); function [Z] = D_ALG3(Iw, seed, start_element, num_element) [C, S] = wavedec2(Iw, 1, 'haar'); A = appcoef2(C, S, 'haar', 1); [H, V, D] = detcoef2('all', C, S, 1); [M, N] = size(H); a = dct2(A); h = dct2(H); v = dct2(V); d = dct2(D); % the watermark that is belived to be in the image randn('state', seed); W = randn(1, num_element); zig = zigzag(a, start_element, num_element); za = dot(W,zig)/num_element; zig = zigzag(h, start_element, num_element); 43 zh = dot(W,zig)/num_element; zig = zigzag(v, start_element, num_element); zv = dot(W,zig)/num_element; zig = zigzag(d, start_element, num_element); zd = dot(W,zig)/num_element; Z = (za+zh+zv+zd)/4; Frequency-Spatial Combination Algorithm % use the D_ALG4 decoder function [Iw, G] = E_ALG5(image, seed, alpha, start_element, num_element) Iw = E_ALG4(image, seed, alpha, start_element, num_element); [M, N] = size(Iw); G = zeros(M, N); I = double(image); Iw = double(Iw); for i = 1:M for j = 1:N if (j>4 & i>4 & j<(N-3) & i<(M-3)) a = I((i-4):(i+4),(j-4):(j+4)); elseif (j<=4 & i<=4) a = I(1:(i+4),1:(j+4)); elseif (j<=4 & i>4 & i<(M-3)) a = I((i-4):(i+4),1:(j+4)); elseif (i<=4 & j>4 & j<(N-3)) a = I(1:(i+4),(j-4):(j+4)); elseif (i>=(M-3) & j>=(N-3)) a = I((i-4):M,(j-4):N); elseif (i>=(M-3) & j>4 & j<(N-3)) a = I((i-4):M,(j-4):(j+4)); elseif (j>=(N-3) & i>4 & i<(M-3)) a = I((i-4):(i+4),(j-4):N); elseif (j<4 & i>=(M-3)) a = I((i-4):M,1:(j+4)); elseif (i<4 & j>=(N-3)) %else a = I(1:(i+4),(j-4):N); end MU = sum(sum(a))/prod(size(a)); [x, y] = size(a); %a = a - ones(x, y)*MU; a = a.*a/prod(size(a)); a = sum(sum(a)); a = a - MU*MU; G(i, j) = a; end end Mmax = max(max(G)); G = G/Mmax; Iw = (ones(M,N)-G).*I + G.*Iw; Iw = uint8(Iw); 44 Reference [1] A. Piva, A DCT-Domain Watermarking System for copyright Protection of Digital Images. PhD Thesis in Computer Science and Telecommunications Engineering, University of Florence, December 1998. [2] D. Kundur, D. Hatzinakos. A robust digital image watermarking method using wavelet-based fusion. In International Conference on Image Processing, pages 544--547, Santa Barbara, California, USA, October 1997. IEEE. http://citeseer.nj.nec.com/kundur97robust.html [3] D. Kundur D. Hatzinakos. Digital watermarking using multiresolution wavelet decomposition. In International Conference on Acoustic, Speech and Signal Processing (ICASP), volume 5, pages 2969--2972, Seattle, Washington, USA, May 1998. IEEE. http://citeseer.nj.nec.com/kundur98digital.html [4] D. Lowe and A. Ginige, " Image Quality Assessment using an Image Activity Weighting and the HVS Response ", Image and Vision Computing New Zealand - IVCNZ '93, Auckland, New Zealand, 17 - 18 August 1993. http://www.eng.uts.edu.au/~dbl/dblpubls.htm [5] I. J. Cox, M. L. Miller, J. A. Bloom, Digital Watermarking, Morgan Kaufman Publishers, 2002 [6] I Pitas. A method for signature casting on digital images. In Proc. of the IEEE Int. Conf. on Image Processing, pages 215--218, Lausanne, Switzerland, September 1996. http://citeseer.nj.nec.com/pitas96method.html [7] J. Bloom, Private Communication [8] J. Fridrich, "Combining Low-frequency and Spread Spectrum Watermarking", Proc. SPIE Int. Symposium on Optical Science, Engineering, and Instrumentation, San Diego, July 19-24, 1998. http://citeseer.nj.nec.com/fridrich98combining.html 45 [9] M. Kutter, F. A. P. Petitcolas, "A fair benchmark for image watermarking systems," in Proc. SPIE Security and Watermarking of Multimedia Contents, San Jose, CA, USA, Jan. 1999, vol. 3657, pp. 226--239. http://citeseer.nj.nec.com/article/kutter99fair.html [10] R. Dugad, K. Ratakenda, and N. Ahuja, "A new waveletbased scheme for watermarking images," Proc. IEEE Int. Conf. on Image Processing, vol.II, TA10.07, Oct. 1998. [11] S. Titov "Perceptually Based Image Comparison Method", 2000. http://graphics.cs.msu.su/en/publications/ [12] V. Fotopoulos, A. N. Skodras, A Subband DCT approach to image watermarking, X European Signal Processing Conference, September 4 - 8, 2000, Tampere, Finland 46