1function [] =PicSmooth0 (A, s)2%PicSmooth0 here to show a summary of this function3%picsmooth0 (A,s) A is the image matrix S3 Transformation Matrix4%detailed instructions are shown here5[m,n,a]=size (A);6 ifA = =37b=Rgb2gray (A);8 Else9b=A;Ten End Oneb=Double(B); % prevent overflow Ap=zeros (m,n); -k=0; -sum=0; the[m,n]=size (s); - if(m~=3|| n~=3) -fprintf ('Please enter the correct 3*3 spatial domain smoothing template'); - Else + forI=1:3 - forj=1:3 +sum=sum+s (i,j); A End at End - - forI=1: M - forj =1: N -k=0; - if((0<i-1&&i-1<=M) && (0<j-1&&j-1<=N)) inK=k+s (1,1) *b (I-1, J-1); - End to if(0<i&&i<=m &&0<j-1&&j-1<=N) +K=k+s (2,1) *b (i,j-1); - End the if(0<i+1&&i+1<=m &&0<j-1&&j-1<=N) *K=k+s (3,1) *b (i+1, J-1); $ EndPanax Notoginseng - if(0<i-1&&i-1<=m &&0<j&&j<=N) theK=k+s (1,2) *b (I-1, j); + End A if(0<i&&i<=m &&0<j&&j<=N) theK=k+s (2,2)*B (i,j); + End - if(0<i+1&&i+1<=m &&0<j&&j<=N) $K=k+s (3,2) *b (i+1, j); $ End - - if(0<i-1&&i-1<=m &&0<j+1&&j+1<=N) theK=k+s (1,3) *b (I-1, j+1); - EndWuyi if(0<i&&i<=m &&0<j+1&&j+1<=N) theK=k+s (2,3) *b (i,j+1); - End Wu if(0<i+1&&i+1<=m &&0<j+1&&j+1<=N) -K=k+s (3,3) *b (i+1, j+1); About End $P (I,J) =K; - End - End - End Ap=p/sum; +p=uint8 (P); theb=uint8 (B); - $ Figure ; the imshow (B); the Figure ; the imshow (P); the -End
Reprint please indicate source
[Digital Image processing]3*3 template gray image spatial domain transform