Skip to content

Instantly share code, notes, and snippets.

@uugan
Created April 23, 2013 12:24
Show Gist options
  • Save uugan/5443142 to your computer and use it in GitHub Desktop.
Save uugan/5443142 to your computer and use it in GitHub Desktop.
/* Median filter 5x5 6<sup>th</sup> kernel */
float MedianFile5x5(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
unsigned char wind[25];
int start = GetTickCount();
int cnt=0;
for(int i=2; i< height - 2; i++)
for(int j=2; j< width - 2; j++){
cnt=0;
for(int p=-2;p<=2;p++){
for(int k=-2;k<=2;k++){
wind[cnt++]=inbuf[(i+p)*width+j+k];
}
}
sort(wind,wind+25);
outbuf[i*width+j] = wind[12]; /*get central value */
}
return (float)(GetTickCount()-start);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment