[Digital Image processing]3*3 template gray image spatial domain transform

Source: Internet
Author: User

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&LT;=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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.