• 沒有找到結果。

Algorithm for secret-fragment –visible mosaic image creation . 29

Chapter 3 Creation of Secret-fragment-visible Mosaic Images

3.2 Proposed Secret-fragment-visible Mosaic Image Creation Process

3.2.3 Algorithm for secret-fragment –visible mosaic image creation . 29

In this section, after discussing some problems which are encountered in the creation process of secret-fragment-visible mosaic images, we will present an algorithm to implement the process.

A. Problems of creating secret-fragment-visible mosaic images

We face two major problems in the secret-fragment-visible mosaic image creation process. One is about finding an optimal solution for fitting tile images in appropriate target blocks. Another is dealing with the situation of a database which is not large enough for selecting a sufficiently similar candidate image as a target image.

About the first problem, we can reduce it to a single-source shortest path problem. The shortest path problem is one of finding a path in a graph with the smallest sum of between-vertices edge weights. The state of fitting tile images represents the vertices of the graph. In the fitting process, we select a tile image for a target block, once a block. Therefore, the edge means the label of the tile image that we choose at the time. Then, the weight of an edge is the Euclidean distance between the selected tile image and the filled target block (defined later). Accordingly, we can build a tree structure for this problem, as shown by Figure 3.1.

In order to find an optimal solution of the single-source shortest path problem, we utilize Dijkstra's algorithm. In this algorithm, the running time of getting an

30

optimal answer is

  V

2 , where V stands for the number of vertices. According to Figure 3.1, the number of vertices in this problem is as follows:

 

used in this study. Obviously, the computation cost for getting an optimal solution for such a large N is too high. In this case, we have to find other possible solutions for fitting tile images in order to create a secret-fragment-visible mosaic image.

Figure 3.1 A tree structure of fitting tile images to target blocks.

The second problem is about how to select a sufficiently similar target image from a database which is not large enough. While we use such a database in the secret-fragment-visible mosaic creation process, the process will very likely to choose a dissimilar target image. As a result, the resulting image will look unlike the target one. In this case, we have to design a remedy method to deal with such a problem of use of a small-sized database.

B. Possible solutions for fitting tile images

……

31

One possible solution for fitting tile images is the greedy algorithm. We try to calculate the Euclidean distance between a tile image and a target block as a selection function for a greedy algorithm. However, as shown by Figure 3.3(a), the resulting image of using such a greedy algorithm for fitting tile images is incomplete with its lower part being filled with fragment pieces with inappropriate colors. This phenomenon comes from the reason that the number of tile images obtained from the secret image, Figure 3.2(a), is limited by its own size, so that the available tile images for choice to fit the target blocks in Figure 3.2(b) become less and less near the end of the fitting process. As a result, the differences in terms of the Euclidean distance between the later-fitted tile images and the target blocks become bigger and bigger than the earlier-fitted ones, resulting in the poorly-fitted bottom part of Figure 3.3(a).

To get a possible solution to this problem, we try to vary the select function for use in the greedy algorithm. After many trials, we find that the effect on the created mosaic images becomes better if the previously-proposed h-feature, instead of the Euclidean distance, is used for defining the selection function for the greedy algorithm. This feature takes the global color distribution of an image into consideration. That makes the content of a created mosaic image using the proposed creation process resemble a target image, as shown by Figure 3.3(b)

C. Remedy method for creation process

By using the greedy algorithm with the selection function defined in terms of the

h-feature, we can generate a secret-fragment-visible mosaic image successfully. Yet

we still have the small-sized database problem to deal with. While a database is not large enough, the mosaic image creation process will select from the database a candidate image dissimilar to the secret image. As shown by Figure 3.5(a) which is a created mosaic image, which is created with Figures 3.4(a) and 3.4(b) as the secret

32

and the selected target image, the major color of the created mosaic image is quite different from the selected target one.

Figure 3.2 Input images. (a) A secret image. (b) A target image.

Figure 3.3 Created mosaic images generated by a greedy algorithm. (a) Image created using Euclidean distance used to define a selection function for a greedy algorithm. (b) Image created using the h-feature to define the select function for a greedy algorithm.

To solve this problem, during the candidate image selection process, after we

(b) (a)

(b) (a)

33

compute an error between a secret image and a candidate image to measure the similarity, if the error is large, the selected target image is inappropriate for the creation process. In this case, we propose to enlarge the size of the target image. The reason is that if the size of a target image is larger than that of the secret image, the number of target blocks, or equivalently, the number of positions to fit the tile image, may be more freely chosen.

Furthermore, to deal with the surplus target blocks coming from enlargement of the target image, we fill each of them with the most similar tile image in the sense of the h-feature or with the average color of itself. More specifically, if the difference between the h-feature of the most similar tile image and that of the target block is larger than a certain threshold, then the target block is filled in the average color instead of the selected tile image. In this way, the resulting mosaic image is better than before, as shown by Figure 3.5(b).

D. Algorithm for secret-fragment-visible mosaic image creation

According to above-mentioned related processes, an algorithm for the proposed secret-fragment-visible mosaic image creation is described in the following. Basically, in the process of tile image fitting, we try to sort the h-feature values of tile images and target blocks, and then get two block-label sequences from the sorted feature values of them. By one-by-one mapping these two block-label sequences, each tile image can be fit into a most similar target block achieving the greedy search goal and decreasing the running time to

n log n

. The detailed algorithm is given as follows.

Algorithm 3.3: secret-fragment-visible mosaic image creation.

Input: a secret image S, a database DB, and a selected size Z

t of a tile image.

34

Output: A secret-fragment-visible mosaic image R.

Steps:

Stage 1 --- embedding secret image fragments into a selected target image.

Step 1. Crop S to yield an image S′ which is divisible by size Zt. Step 2. Perform following steps to select a target image T.

2.1 Select a candidate image by Algorithm 3.2 as T.

2.2 If the error e computed in Step 3.1 of Algorithm 3.2 is larger than a pre-selected threshold Th, then enlarge the size of T

  e T

h

 

times.

Step 3. Perform the following steps to obtain a block-label sequence of each of S′ and

T.

3.1 Divide S′ into a sequence QS′ of blocks S1′, S2′, …, Sn′ as tile images based on size Zt, where each block Si′ is said to have the label i.

3.2 Divide T into a sequence QT of blocks T1, T2, …, Tn as target blocks based on size Zt, where the label of Ti is similarly defined.

3.3 For each tile image of S′ and each target block of T, calculate the h-feature values of them based on Eq. (3.3).

3.4 Sort the h-feature values of all Si′ and all Ti, and re-order accordingly the blocks in QS′ and QT, respectively, to get two re-ordered block sequences

Q

S′′ and QT′.

3.5 Get the new label sequences L1 and L2 from the re-ordered block sequences QS′′ and QT′, and call them h-sorted label sequences of the resized secret image S′ and the selected target image T.

Step 4. Fit the tile images to the target blocks based on the one-to-one mappings from the ordered labels of L1 to those of L2, thus completing the embedding of all the tile images in S′ into all the target blocks of T.

35

Stage 2 --- dealing with unfilled target blocks.

Step 5. Perform the following steps to fill each of the remaining unfilled target blocks, B, if there is any.

12.1 Compute the difference e′ between the h-feature hB of B and the h-feature hA

of each of the tile images, A, by the following equation:

e′ = |h

B  hA|. (3.5)

12.2 Pick out the tile image Ao with the smallest error e′ and compare e′ with another pre-selected threshold Th′ in the following way:

A. if e′ < Th′, then fill the tile image Ao into the target block B;

B. if e′  T

h′, fill the average R, G, and B values of all the pixels in B into

B.

Stage 3 --- generating the desired mosaic image.

Step 6. Generate the desired output image R by composing all the tile images fitted at their respective positions as an image.

Figure 3.4 Example images. (a) A secret image. (b) A target image.

(b) (a)

36

Figure 3.5 Resulting mosaic images created with Figures 3.4(a) as secret image and 3.4(b) as target image. (a) Mosaic image created without the remedy method. (b) Mosaic image created with the proposed remedy method.

3.3 Experimental Results

Some created mosaic images using the above-proposed algorithms are given in Figures 3.6 through 3.9. The number of candidate target images which are stored in the database is 841. The size of the database is large enough because the remedy method is rarely used in the creation process in our experiments. By calculating the Euclidean distances between the (r, g, b) colors of all the blocks of a target image and those of all the blocks of a corresponding secret-fragment-visible mosaic image, we can get the average error at the block level in the resulting image (as the sum of all the Euclidean distances divided by the number of blocks), as shown by Table 3.1. We use this error measure instead of the peak signal-to-noise ratio (PSNR) to examine the similarity between a secret image and a selected target image. Because the visual effects of the mosaic image are based on a property of human vision that people only can see the average color of a block when it is far away from them, it is inappropriate to apply a pixel-level similarity measure for this kind of image. Therefore, we use a block-level similarity as mentioned above. The smaller the value is, the more similar

(b) (a)

37

the secret image to the target image is. Accordingly, from Table 3.1 we see that Figure 3.8(c) is the most-similar mosaic image created by the proposed method among the four of Figures3.6 through 3.9.

Figure 3.6 Experimental images. (a) A secret image. (b) A target image. (c) A secret-fragment-visible mosaic image created with (a) as a source image.

(a) (b)

(c)

38

Figure 3.7 Experimental images. (a) A secret image. (b) A target image. (c) A secret-fragment-visible mosaic image created with (a) as a source image.

(c)

(a) (b)

39

Figure 3.8 Experimental images. (a) A secret image. (b) A target image. (c) A secret-fragment-visible mosaic image created with (a) as a source image.

(a)

(b)

(c)

40

Figure 3.9 Experimental images. (a) A secret image. (b) A target image. (c) A secret-fragment-visible mosaic image created with (a) as a source image.

(a)

(c)

(b)

41

Table 3.1 The Euclidean distance at block level between target images and created mosaic images.

Figure Number Euclidean distance at block level

3.6 66.9 3.7 80.8 3.8 39.4

3.9 40