1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
int row,col,i,i1,j,j1;
    int Temp,Size=7; //마스크 크기 조절
    double Sum;
    unsigned char *Result;
    Result=(unsigned char*)calloc(Width*Height,sizeof(char));
 
    for(row=0;row<Height;row++)
    {
        for(col=0;col<Width;col++)
        {
            Sum=0.0;
            for(i=0;i<Size;i++)
            {
                i1=row+i-(int)((Size-1)/2);
                if(i1<0) i1=0;
                if(i1>Height-1) i1=Height-1;
                for(j=0;j<Size;j++)
                {
                    j1=col+j-(int)((Size-1)/2);
                    if(j1<0) j1=0;
                    if(j1>Width-1) j1=Width-1;
                     Sum+=Orig[i1*Width+j1];
                }
            }
 
            Temp=(int)(Sum/(Size*Size)+0.5);
            if(Temp<0) Temp=0;
            if(Temp>255) Temp=255;
            Result[row*Width+col]=(unsigned char)Temp;
        }
    }
    return Result;
<SPAN id=tx_marker_caret></SPAN>



마스크를 3 5 7 세가지로 조절했을때도 결과 값은 다르다 (소스참고)

Posted by 코딩하는 야구쟁이
,