The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: HG | June 14, 2010 @ 9:31pm
C Code
[
Download
]
gint fp_median_nxn_filter_process(guchar *src, guchar *dest, gint srcW, gint srcH, gint srcChannels, gint srcRowstride, ...) { //Checks g_return_val_if_fail(src!=NULL, -1); g_return_val_if_fail(dest!=NULL, -2); //Window gint N, offset; //Arguments va_list flags; va_start(flags, srcRowstride); N = va_arg(flags, gint); va_end(flags); offset = N/2; if(N%2==0) printf("WARN: Asymmetric window.\n"); //Proper int x, y, nx, ny, accum_r, accum_g, accum_b, dpix, winsize=N*N; guchar *s; for(x=0;x<srcW;x++) for(y=0;y<srcH;y++) { if(x<=N||y<=N||x>=srcW-N||y>=srcH-N)continue; //FIXME: Ignore borders. accum_r=accum_g=accum_b=0; for(nx=0;nx<N;nx++) for(ny=0;ny<N;ny++) { s=src+(srcChannels*(x-offset+nx))+(srcRowstride*(y-offset+ny)); accum_r+=s[0]; accum_g+=s[1]; accum_b+=s[2]; } dpix=srcChannels*x+y*srcRowstride; dest[dpix ]=accum_r/winsize; dest[dpix+1]=accum_g/winsize; dest[dpix+2]=accum_b/winsize; } return 0; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.68 / 8
37 Votes
http://codebin.yi.org/690
page generated in 0.00 seconds