Discrete cosine transform

Source: Internet
Author: User
Tags cos

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Drawing;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceDFT9 {Ten     classFFT One     { A         intRow; -         intCol; -         Double[,] FM; the         Double[,] FN; -         Double[,] X; -         Double[,] Original; -          PublicFFT (String name) +         { -Bitmap Bitmap =NewBitmap (name); +              This. Col =bitmap. Width; A              This. Row =bitmap. Height; atOriginal=New Double[Row,col]; -fm=New Double[Row,row]; -fn=New Double[Col,col]; -x=New Double[Row,col]; -              for(inti =0; i < row; i++) -             { in                  for(intj =0; J < Col; J + +) -                 { toOriginal[i, j] = (bitmap. GetPixel (j,i). R + bitmap. GetPixel (j,i). G + bitmap. GetPixel (j,i). B)/3; +                 } -             } the initfmn (); *  $         }Panax Notoginseng          Public Double[,] Getfft () -         { theX =martiply (martiply (FM, Original), T (FN)); +             returnX; A         } the  +          Public Double[,] Getifft () -         { $             returnmartiply (martiply (T (FM), X), FN); $         } -         Private Double[,] TDouble[,] a) -         {  the             intAwidth = A.getlength (0); -             intAheight = A.getlength (1);Wuyi             Double[,] reutrnt =New Double[Aheight, awidth]; the              for(inti =0; i < awidth; i++) -             { Wu                  for(intj =0; J < Aheight; J + +) -                 { AboutReutrnt[j, I] =A[i, j]; $                 } -             } -             returnreutrnt; -         } A         Private Double[,] martiply (Double[,]a,Double[,]b) +         { the             intAwidth = A.getlength (0); -             intAheight = A.getlength (1); $             intBheight = B.getlength (1); the             Double[,] Returnmaxtrix =New Double[Awidth, bheight]; the              for(inti =0; i < awidth; i++) the             { the                  for(intj =0; J < Bheight; J + +) -                 { in                      for(intK =0; K < Aheight; k++) the                     { theReturnmaxtrix[i, j] + = A[i, K] *B[k, j]; About                     } the                 } the             } the             returnReturnmaxtrix; +         } -         Private voidinitfmn () the         {Bayi             DoubleFirstm =1/math.sqrt (row); the             DoubleFIRSTN =1/math.sqrt (col); the              for(inti =0; i < row; i++) -             { -                  for(intj =0; J < Row; J + +) the                 { the                     if(i = =0) the                     { theFm[i, J] =firstm; -                     } the                     Else  the                     { theFm[i, J] = Math.sqrt (2.0/row) * Math.Cos (i * j * Math.PI/row);94                     } the                 } the             } the              for(inti =0; I < col; i++)98             { About                  for(intj =0; J < Col; J + +) -                 {101                     if(i = =0)102                     {103Fn[i, J] =firstn;104                     } the                     Else106                     {107Fn[i, J] = Math.sqrt (2.0/col) * Math.Cos (i * j * Math.PI/col);108                     }109                 } the             }111         } the     }113}

Discrete cosine 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.