[멀티미디어공학]Simple Dithering
日新又日新 | 2008. 10. 11. 05:44
#1. Simple Dithering

 1: //------------------[simple dither algorithm start]--------------------
 2:// input : in_img,        output : out_img
 3:int pixel_x, pixel_y;
 4:int level;
 5:int simplematrix[4][1] = { {0}, {3}, {2}, {1} };
 6:int i, j;
 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] / 52;
10:        for ( i = 0 ; i < 2 ; i++) {
11:            for ( j = 0 ; j < 2 ; j++) {
12:                if ( level == 0 ) {
13:                    out_img[pixel_x * 2 + i][pixel_y * 2 + j] = 0;
14:                } else {
15:                    if ( level <= simplematrix[i][j] ) {
16:                        out_img[pixel_x * 2 + i][pixel_y * 2 + j] = 0;
17:                    } else {
18:                        out_img[pixel_x * 2 + i][pixel_y * 2 + j] = 255;
19:                    }
20:                }
21:            }
22:        }
23:    }
24:}
25:    //------------------[simple dither algorithm end]--------------------


5: Dither Matrix 설정
7~8 : 각 픽셀에 대해서
9 : 레벨값(255)을 5단계로 나눔
10~11 : 한 픽셀을 4픽셀로 표현
13 : 나눠진 레벨값이 0이면 0
14~19: 나눠진 레벨값이 0이 아니면 Dither Matrix와 비교해서 작은 곳은 백색, 큰 곳은 흑색


 
 
 
트랙백 | 댓글



위치로그 : 태그 : 방명록 : 관리자
이우성's Blog is powered by Daum / Designed by SSen
관리자  |  글쓰기
BLOG main image
전, 이우성입니다. ( I am Woosung, Lee. ) ""
 Category
 Media
 TAGS
 Recent Entries
 Recent Comments
 Calendar
 Archive
 Link Site
 Visitor Statistics
+ Total :
+ Today :
+ Yesterday :
카피
rss