#2. Ordered Dithering
1://------------------[simple dither algorithm start]--------------------
2:// input : in_img, output : out_img
3:int pixel_x, pixel_y;
4:int i, j;
5:int level;
6:int ordermatrix[4][4] = {{0, 8, 2, 10}, {12, 4, 14, 6}, {3, 11, 1, 9}, {15, 7, 13, 5} };
7:for ( pixel_x = 0 ; pixel_x < XSIZE ; pixel_x++ ) {
8: for ( pixel_y = 0 ; pixel_y < YSIZE ; pixel_y++ ) {
9: level = in_img[pixel_x][pixel_y] / 16;
10: i = pixel_x % 4;
11: j = pixel_y % 4;
12:
13: if ( level > ordermatrix[i][j] ) {
14: out_img[pixel_x][pixel_y] = 255;
15: } else {
16: out_img[pixel_x][pixel_y] = 0;
17: }
18: }
19:}
20://------------------[simple dither algorithm end]--------------------
Simple Dithreing에 비해서 레벨 0일 때의 처리가 없음.
10~11 : Dither Matrix에서 비교할 대상 설정
13~17 : 현재 나눠진 레벨값을 Dither Matrix에서 비교대상과 비교하여 흑/백 결정
-> 결과 파일에서의 픽셀크기가 변경되지 않음