loc trung vi
void MedianFilter(BYTE huge *Image,unsigned hangbd,unsigned cotbd, unsigned rong,unsigned cao)
{ register unsigned i,j,k,l,pixelindex;
BYTE *pixelvalues;
pixelvalues=(BYTE *)calloc(9,(unsigned)sizeof(BYTE));
if(pixelvalues==NULL)
{Error(16);
getch();exit(0);}
for(i=hangbd;i<cao-1;i++) //maxy
{
for (j=cotbd;j<rong-1;j++) //maxx
{
pixelindex= 0;
for(k=0;k<3;k++)
for(l=0;l<3;l++)
pixelvalues[pixelindex++]=ReadPixel(Image,j+k,i+l);
SortPixel(pixelvalues);//sap xep*/
WritePixel(Image,i,j,pixelvalues[5]);//doc 9 ghi 1
}
} //end of for
free(pixelvalues);
Bạn đang đọc truyện trên: Truyen247.Pro