Lọc Trung Vị
7.Lọc Trung Vị
int M=pDoc->biHeader.biHeight;
int N=pDoc->biHeader.biWidth;
int i,j;
int H[256];
BYTE Y[1000][1000];
int chiso,lc,k,l,K=3;
//Giu bien
for(i=0;i<M;i++)
for (j=0;j<N;j++)
Y[i][j]=pDoc->Data[i][j];
// tinh cac diem trong bien
lc=(3-1)/2;
for (i=lc;i<=M-lc;i++)
for(j=lc;j<=N-lc;j++)
{
chiso=0;
for (k=-lc;k<=lc;k++)
for (l=-lc;l<=lc;l++)
H[chiso++]=Y[i+k][j+l];
//sap xep khong giam
for (k=0;k<K*K-1;k++)
for (l=k+1;l<K*K;l++)
if (H[k]>H[l])
{ int tg=H[k];
H[k]=H[l];
H[l]=tg;
}
//TÝnh Y[i,j]
pDoc->Data[i][j]=H[K*K/2];
}
Invalidate();
}
Bạn đang đọc truyện trên: AzTruyen.Top