/*% cyntax % -lfb && cc -go # % -lfb * 3x3 median filter */ #include #include #include #include unsigned char inline[3][8192*8]; unsigned char outline[8192*8]; void input(PICFILE *in, unsigned char *l, unsigned char *m){ int i; if(!picread(in, (char *)l)){ memcpy((char *)l-PIC_NCHAN(in), (char *)m-PIC_NCHAN(in), PIC_NCHAN(in)*(PIC_WIDTH(in)+2)); return; } m=l+PIC_NCHAN(in)*PIC_WIDTH(in); for(i=0;i!=PIC_NCHAN(in);i++,l++,m++){ l[-PIC_NCHAN(in)]=l[0]; m[0]=m[-PIC_NCHAN(in)]; } } void medians(unsigned char *l0, unsigned char *l1, unsigned char *l2, int nchan, int npix){ unsigned char xx[9]; int t, j, k; unsigned char *op=outline; npix*=nchan; if(npix==0) return; do{ xx[0]=l0[-nchan]; xx[1]=l0[0]; xx[2]=l0[nchan]; xx[3]=l1[-nchan]; xx[4]=l1[0]; xx[5]=l1[nchan]; xx[6]=l2[-nchan]; xx[7]=l2[0]; xx[8]=l2[nchan]; for(j=0;j!=5;j++) for(k=j;k!=9;k++) if(xx[j]