Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

gradient

int i,j,k,l;

int M=pDoc->biHeader.biHeight;

int N=pDoc->biHeader.biWidth;

int lc=1,K=3,d=100;

int L=255;

BYTE dt[1000][1000];

int hm[3][3]={{1,1,1},{0,0,0},{-1,-1,-1}};

int hn[3][3]={{1,0,-1},{1,0,-1},{1,0,-1}};

// xet cac diem phia ngoai

for(i=0;i<M;i++)

for(j=0;j<N;j++)

 if ( 2* pDoc->Data[i][j]>=d)

dt[i][j]=L;

else dt[i][j]=0;

// tinh lai cac diem phia trong

for(i=lc;i<M-lc;i++)

for(j=lc;j<N-lc;j++)

{

int tong1=0;

int tong2=0;

for( k=0;k<=2*lc;k++)

for(l=0;l<=2*lc;l++)

{

tong1+=hm[k][l]*pDoc->Data[i-k+lc][j-l+lc];

tong2+=hn[k][l]*pDoc->Data[i-k+lc][j-l+lc];

}

if( abs(tong1)+abs(tong2)>=d)

dt[i][j]=L;

else dt[i][j]=0;

}

for(i=0;i<M;i++)

for(j=0;j<N;j++)

pDoc->Data[i][j]=dt[i][j];

Invalidate();

}

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: