<<

DIGITAL HALFTONE Wayne Weiyi Chen

1.1. INTRODUCTION The final workflow of any digital photography is to print out the image. This procedure is actually very similar to what the digital display doing: both of them distribute small dots into the space with different size and density to create illusions that there is different or luminance. Digital Halftone is the method that we use to create a ready-to-print image. The basic idea behind is using different threshold to windowing the image so that the density of dots can be distinguished according to the intensity of images.

In this problem, we will investigate this procedure and implement two categories of different methods. We will briefly introduce these two categories of algorithm and then show their results, compare their performance and give a discussion on that.

Figure 1. man.raw

Page 1 of 16

1.2. METHODOLOGY

1.2.1. Dithering Matrix The idea of dithering matrix is that instead of introducing noise to the image for thresholding out different density of dots, we generate the threshold matrix with its element fluctuating in a certain range. By doing this, we are able to halftone grayscale images into binary images with different distributions of dots without adding noise.

A 2nd order Bayer index matrix is defined as

éù02 (8) I2 = êú ëû31

The higher order Bayer index matrix is recursively defined as

éù442´´IInn+ I2n = êú (9) ëû4341´IInn+´+

After a Bayer index matrix is generated, we can use it to form a threshold matrix using the formula:

Ixy( ,) + 0.5 Txy( ,) =2n ´ 255 N 2 (10) xy,Î-{ 0,1,2,...,2 n 1} where N is the size of the image. Then the grayscale image can be transferred into a using

ì1 Fij( ,mod,mod) > Ti( Nj N) Gij( , ) = í (11) î0 otherwise

In this problem, we also need to generate several index matrixes with the form being similar to

éù14 10 11 15 êú9304 A = êú (12) 4 êú8215 êú ëû13 7 6 12

This form can be illustrated as a set of increasing number spiraling out from the center of the matrix. We will discuss the performance using these different matrixes.

1.2.2. Error Diffusion Another method we want to explore is error diffusion. The basic idea of error diffusion is that we slide a window through the image with thresholding the into binary output and spread out

Page 2 of 16 the error introducing by this thresholding, adding to the current ’s future neighbors’ pixel value before thresholding them.

To be specific, firstly we normalize the pixel value from range [0, 255] to[0,1], then threshold the pixel value into either 0 or 1, calculate the error between the generated binary value and the original value:

Eij( ,,,) = Fij( ) - Gij( ) (13)

And spread this error into the neighborhood according to the error diffusion matrix, such as Floyd- Steinberg’s, Jarvis, Judice and Ninke’s (JJN) and Stucki’s error diffusion matrix showing below respectively:

éù00000 éù00000 éù000 êú00000 êú00000 1 1 êú1 êú êú007 êú00075 êú00084 (14) 16 êú 48 êú42 êú ëûêú351 êú35753 êú24842 ëûêú13531 ëûêú12421

We use a serpentine scheme when diffusing the error, that is, with even lines (i=0, 2, 4…) we use above matrixes sliding from left to right, while with odd lines (i=1, 3, 5…) we use matrixes in (15) sliding from right to left.

éù00000 éù00000 éù000 êú00000 êú00000 1 1 êú1 êú êú700 êú57000 êú48000 (15) 16 êú 48 êú42 êú ëûêú153 êú35753 êú24842 ëûêú13531 ëûêú12421

1.3. RESULTS

1.3.1. Dithering Matrix In the first part of this problem, several matrixes are created. The Bayer index matrix can be generated recursively. The 2nd, 4th and 8th order Bayer index matrix is showing below

Page 3 of 16

éù0 32 8 40 2 34 10 42 êú êú48 16 56 24 50 18 58 26 éù0 8 2 10 êú12 44 4 36 14 46 6 38 êú 02 êú éùêú12 4 14 6 êú60 28 52 20 62 30 54 22 I2 = êúI4 = I8 = (16) ëû31 êú3 11 1 9 êú3 35 11 43 1 33 9 41 êúêú ëû15 7 13 5 êú51 19 59 27 49 17 57 25 êú15 47 7 39 13 45 5 37 êú ëûêú63 31 55 23 61 29 53 21

With the scanning method mentioned above, we firstly show the result from I2 and I8 in Fig.24 and Fig.25. Due to the reason that I8 having more threshold value than I2 , its result has more delicate distribution variation and therefore a slightly better look.

Figure 2. Halftone Using Dithering Matrix I2

Page 4 of 16

Figure 3. Halftone Using Dithering Matrix I8

Besides the Bayer index matrixes, we can also employ other designs, such as A4 mentioned in the

(12). Also, we can generate a higher order matrix with similar structure with A4 :

éù60 42 43 44 45 46 47 61 êú êú41 33 24 25 26 27 34 48 êú40 23 14 10 11 15 28 49 êú 39 22 9 3 0 4 29 50 A = êú (17) 8 êú38 21 8 2 1 5 30 51 êú êú37 20 13 7 6 12 31 52 êú36 32 19 18 17 16 35 53 êú ëûêú63 59 58 57 56 55 54 62

Page 5 of 16

The results from I4 , A4 and A8 is showing below in Fig.26, Fig.27 and Fig.28 respectively. We will discuss the rationale of differences among these results with comparing the property of these two categories of dithering matrix in the discussion part.

Figure 4. Result of Dithering Matrix I4

Page 6 of 16

Figure 5. Result of Dithering Matrix A4

Page 7 of 16

Figure 6. Result of Dithering Matrix A8

Page 8 of 16

As a final part of the dithering matrix method, we want to take a look into the case where the printer is able to output FOUR levels of intensity. We still use Bayer index matrix I4 to generate dithering matrix for comparison. We will discuss our design in detail in the discussion part; here we only show the result in the Fig.29. The output result is significantly improved comparing to the ones with binary values.

Figure 7. 4-Color -Ready Output Using Bayer Dithering Matrix I4

Page 9 of 16

1.3.2. Error Diffusion As the second part of the problem, we utilize three different error diffusion schemes on the original grayscale image: Floyd-Steinberg’s, JJN’s and Stucki’s; we show their output results in Fig.30, Fig.31 and Fig.32 respectively.

Figure 8. Error Diffusion Using Floyd-Stein's Scheme

Page 10 of 16

Figure 9. Error Diffusion Using JJN's Scheme

Page 11 of 16

Figure 10. Error Diffusion Using Stucki's Scheme

Page 12 of 16

1.4. DISCUSSION

1.4.1. The Differences between Bayer Index Matrixes and A Matrixes

As we can see from formulas (12), (16) and (17), Bayer index matrix I2n has different form comparing to the A2n : I2n has a higher level of disorderly distributed indices, while A2n has its indices spiral out from small number to large number. This difference introduces a very obvious performance disparity between them: the Bayer index matrix deliver a better result.

The reason for this is because with small thresholds concentrated in the center of each window, it is easier to generate “-inside-and--outside” sub-graphs through all of the pixels in the image, results in an image obviously filled with many small black frames, shown in Fig.27 and

Fig.28. And the situation is further exacerbated when we have a higher order, as comparing A8

(Fig.28) to A4 (Fig.27).

Also we may notice that both I4 and I8 have a more delicate (therefore better) output result than

I2 do because they have a more meticulous structure of threshold; however, this difference become insignificant among the ones with higher order such as I4 , I8 , I16 and so on.

1.4.2. The Algorithms Using in the Dithering Matrix Method

Generate Bayer Index Matrix The Bayer index matrix is recursively generated in our program. The recursive function can be illustrated as following:

• Loop on index of the matrix, for each element, return its value according to its position

• If the order of the matrix is larger than 2, than divide the matrix into four sub-matrixes, and calculate the new position of the element in the sub-matrix, recursively send them to the function with matrix in half of current order.

• The recursion ends where the order of the matrix is 2, for the 4 elements, successively return 0, 3, 2 and 1.

Using this mechanism, we can easily generate a Bayer index matrix providing any given order.

4--Ready Output Method As we have seen in the Fig.29, the 4-color output of dithering matrix method is much better than the binary output. This is reasonable because more level of grayscale means we can have more delicate results.

To generate a 4-color output, we need to setup not only 1 threshold, but also another 2 of them to further distinguish which one of the 4 values the grayscale intensity should become. And also we may need to note that we should still use the dithering matrix method instead of simply establish 4 different threshold. As a result, we keep using Bayer index matrix to generate the thresholds; however, we change the scheme that transfer them to the threshold matrixes:

Page 13 of 16

Ixy( ,) + 0.5 Txy( ,) =2n ´ 127 1 N 2 Ixy( ,) + 0.5 Txy( ,) =2n ´ 127+ 64 2 N 2 Ixy( ,) + 0.5 Txy( ,) =2n ´ 127+ 128 (18) 3 N 2 xy,Î-{ 0,1,2,...,2 n 1}

Therefore we re-arrange the thresholds into new range:

T1 Î[0,127]

T2 Î[64,191] (19)

T3 Î[128,255]

Note that although there are overlaps between these ranges, for each pixel in the image we need not to worry the overlapping or interlacing of corresponding three thresholds because they are transferred from the same one Bayer index. For example, for the first element in the window, the Bayer index is 0, so the three thresholds are 0, 64 and 128 respectively. That is, for any pixel, the three thresholds are monotonically increasing with incremental 64. These three thresholds divide the range [0,255] into at most 4 sub-ranges that decide the final quadruple outputs.

1.4.3. Comparison between Error Diffusion Techniques As we can see in Fig.30, Fig.31 and Fig.32, the JJN’s and Stucki’s error diffusion methods have quite similar outputs except subtle differences, they both deliver better results than the Floyd- Steinberg’s do.

The slightly more obvious “grain” effect introduced by JJN’s and Stucki’s is due to the reason that they have a larger kernel. However, this “grain” effect looks better than Floyd-Steinberg’s “stripe” artifacts as we can clearly see, for example the man’s face, from the whole image. The similarity between JJN’s and Stucki’s is because they have the same form of kernel with slightly different elements in the matrix.

In terms of error between the original image and binary output, JJN’s and Stucki’s may have better results as they more smoothly spread the feedback into a larger neighborhood. This result is consistent with our eyes.

All of these three methods are performed in an up-to-down order with serpentine scanning. Here we propose a possible scheme to further improve the quality of these methods. Suppose the serpentine scanning scheme can deliver a better result comparing to the traditional left-to-right and up-to-down scanning, we can further disorder the scan scheme when utilize error diffusion to improve the results:

Page 14 of 16

• We may randomly pick one pixel in the image, threshold it and calculate the error use the same method, and use an error diffusion matrix such as

éù153 1 êú707 32 êú ëûêú351

to spread the error in all of the directions.

• Then randomly pick another pixel, if it has not yet been thresholded, perform the threshold and error diffusion as well.

• Repeat the error diffusion until all of the pixels in the image are threshold into binary outputs.

This scheme maybe even more time-consuming than the methods we implemented, but it is reasonable to believe that it may deliver a better performance on the final result.

1.4.4. Dithering Matrix vs. Error Diffusion Dithering Matrix Error Diffusion

Program The Bayer index matrix may Need to threshold, calculate the Complexity need a recursive method to error, calculate the error diffusion generate, which demands for and need to implement the larger size of stack, but typically serpentine scanning, more complex negligible because the order is than dithering matrix technique small.

Time-Consuming Fast, only need to threshold, Slow due to the complexity even need not to slide the window in this case if we generate a 512*512 Bayer index matrix

Visual Effect Most of the regions are Better

Artifacts Large area of grey-color-like Floyd-Steinberg’s may introduce display, such as the region of the some “stripe-like” artifacts, but can man’s face be improved by the other two

The comparison between these two techniques is shown above. From subjectively prospective, we prefer error diffusion method. This is because besides the final visual effect, the error diffusion method is an adaptive method in some sense, the error is determined by previous pixel and a feedback is send to the future processing. In the dithering matrix, the threshold is determined and unchanged once the Bayer index matrix is generated and is independent with the specific image

Page 15 of 16 information. The idea of error diffusion is more elegant and delivers a better visual effect for the outputs.

Page 16 of 16