Chpater 1 Introduction
1.5 Thesis Organization
In the remainder of this thesis, the proposed high-capacity and distortion-free method for hiding data in GIF images is described in Chapter 2. In Chapter 3, the proposed method for hiding data in PNG images and gray-level images is described.
In Chapter 4, a fast image search method via the hidden messages in images is described. Experimental results are shown at the end of each chapter. Finally, some conclusions and suggestions for future works appear in Chapter 5.
Chpater 2
A High-capacity and Distortion-free Data Hiding Method for GIF Images
2.1 Introduction
Nowadays, data hiding in images has become more and more popular and drawn lots of attention. This technique has been used in various areas, such as digital watermarking, secret transmission, secret sharing, and so on. Nevertheless, most of the existing data hiding methods introduce some noise after embedding. Though the noise is usually not imperceptible by human eyes, in some fields, such as military and medical ones, the quality of the stego-image is a critical issue. A malpractice will happen if there exist some unknown artifacts produced after hiding.
Since the GIF image will be used as the cover image for hiding data in this study, some properties and usages of the GIF image will be described in the rest of this section. In Section 2.2, the data hiding and extracting methods for GIF images will be described. In Section 2.3, some experimental results of applying the proposed methods will be illustrated. At last in Section 2.4, some discussions and the summary of the proposed method will be made.
2.1.1 Usages of GIF Images
GIF is the abbreviation of Graphics Interchange Format which was developed by CompuServe Inc. in 1987. Since it’s widely supported by its portability and web browsers, it has become one of the most famous image formats on the World Wide
Web. GIFs are suitable for sharp-edged art that is of a limited number of colors. The most representative sharp-edged art is logo. The reason why GIFs are suitable for logos is that the lossless compression method used for creating the GIF image preserves sharp edges. This is an obvious advantage, as compared with JPEGs.
GIFs are also useful for short animations and low-resolution film clips. The GIF format allows a user to combine several GIFs into a single one to create animations.
However, this has two drawbacks. One is that the GIF format applies no compression between the image frames of an animation so that if several larger GIFs are combined into one, a large-sized animation will be created. This contradicts one of the objectives of GIF development: being small in size. The other drawback is that no control interface exists, and the animation will play automatically, when downloaded, even if the user does not want the play. What even worse is that if looping is enabled, the animation will continue to play again and again. Actually the animation functionality of it is seldom used in a meaningful way and usually a disturbance to readers.
2.1.2 Properties of GIF Images
Each GIF image has a palette containing numerous squares and each of which has a color from the 24-bit RGB color space. The number of squares of a GIF image is a power of two and the maximum of it is 256. Besides the palette, a GIF image file also contains a two-dimensional index array in which each element is a number ranging from 0 to the size of the palette. Each pixel is associated with an index in the array and each index points to a color in the palette. So pixels with the same index values have the same color.
GIFs apply the LZW(Lempel Zev Welch) compression method that compresses an image without losing data and distorting the image itself. It is the method that best
compresses images with large fields of homogeneous colors. Less efficiency appears when a picture is of many colors and complex textures. It can be improved by reducing the number of colors in a GIF to be as small as possible. This is achieved by removing stray colors that are not required to represent the image, hence shrinking the size of it.
Another feature of the GIF file format is that the user is able to decide whether an image is interlaced or not. It means that if a GIF image is interlaced, supporting browsers display it in a low-to-high order of resolution, or if this is not the case, they do it in a raster order. This not only has the “fuzzy-to-sharp” effect that attracts the reader but gives the reader a preview of the full version of the image also. The feature is much more suitable for displaying larger GIF images since when displayed, a smaller interlaced one consumes more time than one without the interlacing feature.
And generally speaking, the interlacing feature has little effect on the size of GIF images.
The last feature introduced here is free control of its transparency. This allows the users to pick colors in the palette of a GIF image to be transparent. Usually the background colors are selected for transparency when the image is to be displayed as a foreground. Unfortunately, if a color is chosen to be transparent, all of the pixels with that color will become transparent. So if a foreground pixel happens to have the same color as a background one, the foreground pixel will become transparent, which is usually undesired.
2.2 Proposed Data Hiding Method
2.2.1 Principle of Proposed Method
As mentioned above, the palette consists of several squares and each pixel has an index associated with a color square in the palette. We denote the “index-and-square”
pair as (index, square). For example, we denote the color a pixel has as (5, square5) if and only if the index of the pixel is 5. So if two different squares are of the same RGB value, the pixels associated with either one of the squares will have the same color.
That is, if square5=square6 (meaning that the two squares in the palette are of the same color), those pixels with index values 5 and 6 will have the same color when displayed. It means that if we change a pixel’s value from 5 to 6, no change will be introduced into the image. We can take advantage of this property to achieve high-capacity and distortion-free data hiding, as done in this study.
Plenty of 8-bit GIF images do not use all of the squares in the palette [18]. We name such squares unused squares. The principle of the proposed data hiding algorithm is to duplicate colors appearing in used squares and fill them into the unused squares. But not all of the used squares are duplicated; only those colors with high appearance frequencies will be duplicated and we call them “copy colors.”
Suppose that one of the copy colors is A and its index-and-square pair is (A, squareA) and the duplicated color is B and its index-and-square pair is (B, squareB).
When embedding certain given secret data, we first conduct raster scanning and let the pixel currently being scanned be denoted as p. The scan is to check which pixel in the index array of a given cover image is of color value A. Then the data embedding rule proposed in this study goes as follows:
regard bit 0 being embedded at p if p has color A;
regard bit 1 being embedded at p if p has color B.
Since SquareB is duplicated from SquareA (so the colors in squares A and B are
identical), we know that the stego-image will appear to be completely the same as the cover image no matter how many As are modified to be Bs.
An example is given here. Suppose color A is in the ith square of the color palette, and let it be copied into the jth square of the palette and named color B. So we have two identical colors A and B in the palette with indices i and j, respectively. Now, to embed a bit 0 in the currently-scanned pixel p, we just associate the index i with p, and to embed 1, associate the index j with p.
The following section discusses how “high capacity” is achieved in this study. It is inspired from the previous section that if we duplicate a square more and more times, that copy color can hide more bits every time it appears. For example, if the copy color A is duplicated three times and the copy colors are named B, C, and D respectively. When embedding secret data, we can first find which pixel value is A and then embed secret bits as follows:
regard “00” being embedded in p if p(x, y) = A;
regard “01” being embedded in p if p(x, y) = B;
regard “10” being embedded in p if p(x, y) = C;
regard “11” being embedded in p if p(x, y) = D;
The same principle applies when a copy color is to be used to embed more bits.
That is, if we duplicate a copy color seven times so that the copy color repeats eight times in the palette, the copy color and each duplicated color can hide three bits. The data extraction process is the same as described previously.
To maximize the data hiding capacity, we have to choose appropriate colors as the copy colors. The copy colors are chosen to be the most frequently appearing ones in the cover image. Basically the more times a copy color appears, the more unused squares are allocated to it. But consider the following case: the palette of a cover
image is of the size 256 and there are 3 unused squares. And we also assume that the top three frequently appearing colors are A, B, and C, and the times they appear in the cover image are 200, 150, and 100, respectively. If we allocate all 3 unused squares to A, it means A is used for hiding 2 bits and the hiding capacity will be 2*200=400 bits totally. However, this allocation is not optimal. The maximum data hiding capacity can be achieved when we allocate each color a square such that each color can hide only 1 bit. In such a case the total data hiding capacity becomes 200*1+150*1+100*1
= 450 bits, which is larger than the previous one. So we can only grantee that a color with a higher appearing frequency will not be assigned fewer squares than a color with a lower appearing frequency. To find out which assignment is optimal, we use a brute-force method in this study to enumerate all possible frequency-bit combinations.
This process seems time-consuming. But actually since the size of the palette is at most 256, the process will not take too long. And since the data embedding process need not be conducted in real time in most applications, the waiting time for using the above-mentioned brute-force method to select the best color copying way is acceptable.
Before the secret messages are really embedded, we have to do a preprocessing to prevent the secret messages from being dismissed by the reordering of the palette.
This preprocessing also makes it clear that the bit pattern that a color hides. We use an example to illustrate this. Let A be the copy color with index 10 in the palette and B, C, and D be A’s duplicated color with index 11, 12, and 13 in the palette, respectively.
The preprocessing is that on scanning the index array, we change the index values of the first four pixels whose color is A. We keep the 1st pixel’s index unchanged and modify the 2nd, 3rd, and 4th pixels’ to be 11, 12, and 13, respectively. Note this preprocessing does no data hiding. It just means that indices A, B, C, and D are used for hiding bit patterns 00, 01, 10, and 11, respectively. With this preprocessing, if the
palette is reordered such that the indices of A, B, C, and D in the palette become 4, 3, 2, and 1, respectively, we can still know the bit pattern that A, B, C, or D hide. It is due to the fact that we will first meet index 4 on scanning, which means we can extract 00 from every pixel with index 4 on the rest of the scanning. If we do not do the preprocessing, we will not be able to know which bit pattern that a color hides since we will not be able to know which color is the copy color and which are duplicated colors on decoding.
The data extraction process is intuitive. The first thing we have to do is to scan the palette of the stego-image to see how many copy colors are used. Then we construct a decoding table by recording the indices of colors that appear more than once in the palette. During decoding, we scan the stego-image’s index array in the raster scan order and look up the decoding table. If the index value being scanned is in the decoding table, several bits will be extracted. The number of bits each time we can extract depends on the appearing times of that copy color in the palette. If the index value being scanned is not in the decoding table, we will just continue to scan the next pixel.
2.2.2 Data Embedding Process
We describe the data embedding process step by step as follows according to the previous discussions.
Algorithm 1. Hiding secret messages in a GIF cover image.
Input: A given GIF cover image I and given binary secret messages.
Output: A stego-image S.
Steps:
1. Check the palette of I and count how many squares are used and unused. Record the indices of used squares and unused squares, respectively. Also record the times
each index (pointing to a used square) appears in I.
2. Apply the above-mentioned brute-force method to calculate the maximum data hiding capacity and decide how many bit(s) each copy color can hide.
3. Construct an encoding table with each element of it being the index of a copy color or the index of a duplicated color.
4. Hide the secret message into the image pixels by the principle described in Section 2.2.1 in a raster scan order to obtain S.
2.2.3 Data Extraction Process
We describe the data extraction process step by step as follows.
Algorithm 2. Extracting secret messages from a given stego-image.
Input: A stego-image S.
Output: Binary secret messages.
Steps:
1. Analyze the palette of S to see how many copy colors exist by examining the repetitions of each color. Then calculate the bits each copy color can hide and record them. Also determine and record the bit pattern that a copy or a duplicated color can be extracted by looking up the first n pixels (which are of the same color as that of copy or duplicated color) if the color repeats n times in the palette.
2. Construct a decoding table and assign each element of it the index of a copy color or a duplicated color.
3. Start to extract secret bits in a raster scan order. If the index happens to be one of the index values in the decoding table, several bits can be extracted according to the record we made in Step 1. If this index is not one of the indices in the decoding table, do nothing but go forward to the next index until the end of the index array.
4. Obtain the binary secret messages.
2.3 Experimental Results
In this section, we show the experimental results on several images in Table 2.1 and the comparison before and after data hiding in
Table 2.2. Note that the file size of the stego-images is slightly larger than that of cover images. This is due to the compression method used on GIFs. Since the method proposed in this study is distortion-free, the experimental results focus on the data hiding capacity.
Table 2.1 Characteristics of tested images and their hiding capacity
File Name File Size(KB) Resolution Capacity(KB) Icon
50years 32.8 355x217 31.35
bbb 2.07 85x28 0.91211
book 41.6 751x440 157.53
ipod 71.3 500x532 151.65
leo 44.9 450x437 105.01
ship 15.3 300x247 13.819
Table 2.2 The comparison of cover images and stego-images.
File Name
Cover Image File Size
(KB)
Stego-im age File Size
(KB)
Cover Image Stego-image
50years 32.8 32.9
bbb 2.07 2.16
book 41.6 41.6
ipod 71.3 71.5
leo 44.9 44.9
ship 15.3 15.3
2.4 Discussion and Summary
In this chapter, a high-capacity, adaptive, and distortion-free data hiding method has been proposed. As shown in the previous sections, some images can even have data hiding capacities larger than the file sizes of themselves. And the proposed adaptive approach yields the maximum data hiding capacity. Since this method establishes a relationship between the palette and the pixel values carrying secret bits, the reordering of the palette does not destroy the secret messages. Although the proposed method is of several advantages, it has a shortcoming on security. A malicious attacker can easily detect the existence of secret messages by simply examining the palette to see if there are identical colors in it. To improve the security is a future work of this research.
Chpater 3
Data Hiding by Stacking Up Two PNG Images
3.1 Introduction
3.1.1 Uses of PNG Images
PNG is the abbreviation of Portable Network Graphics. It is a format of images.
As its name suggests, one of its two uses is on the World Wide Web. Since the patent of the LZW (Lempel-Ziv-Welch) lossless data compression algorithm had been enforced by Unisys, the PNG format which uses a non-patented compression method was first developed in early 1995 for replacing the GIF format. Besides the patent-free advantage, PNGs have three other advantages over GIFs: the alpha channel, the gamma correction option, and the two-dimensional interlacing progressive display capability. PNGs that have alpha channels are of variable transparency while GIFs are only of single-level transparency, namely, fully transparent or opaque. As to the progressive display capability, PNGs are superior to GIFs since users can see the complete PNG image earlier than the GIF image when they are loaded at the same time. Details of the display method of PNGs on the Internet will be described in the following section.
The other use of PNG is image editing. PNG is a useful format for the storage of intermediate stages of editing. This benefits from PNG’s lossless data compression and its support of up to 48-bit truecolors or 16-bit graylevels. This means that saving, restoring, or re-saving will not degrade its quality, unlike the standard JPEG. Like GIF,
PNG is a raster format, which means that it represents an image as a two-dimensional array of pixels. PNG is not explicitly a vector format which allows users to store shapes (lines, boxes, etc.) and can be scaled arbitrarily without any loss of quality.
3.1.2 Properties of PNG Images
The fundamental building block of PNG images is ‘chunk.’ With the exception of the first 8 bytes in the file, a PNG image consists of nothing but chunks. Every chunk has the same structure: a 4-byte length, a 4-byte chunk type, a 4-byte cyclic redundancy check value (CRC). The simplest PNG file contains three chunks. They are the image header chunk, IHDR; the image data chunk, IDAT; the end-of-image chunk, IEND. An IHDR must be the first chunk in a PNG image, and it includes all of the details about the type of the image: its height and width, pixel depth, compression and filtering methods, interlacing method, whether it has an alpha (transparency) channel, and whether it is a truecolor, grayscale, or palette image. An IDAT contains all of the image’s compressed pixel data. Each IDAT can contain at most 2 gigabytes of compressed data. An IEND is the simplest chunk of all. It contains no data, and just
The fundamental building block of PNG images is ‘chunk.’ With the exception of the first 8 bytes in the file, a PNG image consists of nothing but chunks. Every chunk has the same structure: a 4-byte length, a 4-byte chunk type, a 4-byte cyclic redundancy check value (CRC). The simplest PNG file contains three chunks. They are the image header chunk, IHDR; the image data chunk, IDAT; the end-of-image chunk, IEND. An IHDR must be the first chunk in a PNG image, and it includes all of the details about the type of the image: its height and width, pixel depth, compression and filtering methods, interlacing method, whether it has an alpha (transparency) channel, and whether it is a truecolor, grayscale, or palette image. An IDAT contains all of the image’s compressed pixel data. Each IDAT can contain at most 2 gigabytes of compressed data. An IEND is the simplest chunk of all. It contains no data, and just