{"id":4981,"date":"2020-04-20T16:32:28","date_gmt":"2020-04-20T07:32:28","guid":{"rendered":"http:\/\/aval-global.com\/?p=4981"},"modified":"2022-11-16T10:12:38","modified_gmt":"2022-11-16T01:12:38","slug":"c-fourier-transform-fft-dft-program","status":"publish","type":"post","link":"https:\/\/aval-global.com\/?p=4981","title":{"rendered":"[C#] Fourier transform (FFT, DFT) Program"},"content":{"rendered":"<p>Using MS Excel\u2019s Macro function allows an automatic transformation of Fast Fourier Transform(FFT) and Discrete Fourier Transform (DFT) of individual data, however, users may find it difficult to use sometimes, as it takes much of data when using MS Excel, therefore, I would like to show how to make a program using a library (*.dll\uff09 for Fourier Transform part with C#.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/29155364\/73358968-1aa12800-42e3-11ea-8593-6f51882e0779.png\" alt=\"2020-01-26_22h18_33\" \/><\/p>\n<p>Run program can be downloaded by clicking right link\u00a0<a href=\"https:\/\/imagingsolution.net\/wordpress\/wp-content\/uploads\/2020\/01\/FourierTransform.zip\"><strong>FourierTransform.zip<\/strong><\/a><strong>. &lt;- Click<br \/>\n<\/strong>All the source code is released in the below GitHub link.<br \/>\n<a href=\"https:\/\/github.com\/ImagingSolution\/FourierCSharp\" target=\"_blank\" rel=\"noopener\"><strong>https:\/\/github.com\/ImagingSolution\/FourierCSharp<\/strong><\/a><\/p>\n<p>Please see below on how to use this program.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Program running<\/strong><\/h2>\n<p>By unzipping the above .zip file, you will find the files named as below. Then, double click FourierTransform.exe to run the program.<\/p>\n<ul>\n<li>FourierTransform.exe<\/li>\n<li>FourierCSharp.dll<\/li>\n<li>sampledata<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><strong>Data format that allows Fourier Transform<\/strong><\/h2>\n<p>Data is composed of 1 data per row in .CSV file format.<\/p>\n<p>Sample 01)<\/p>\n<p>1<br \/>\n1.30939551<br \/>\n1.59096344<br \/>\n1.820538079<br \/>\n1.980767038<br \/>\n2.06331351<br \/>\n2.069803727<br \/>\n2.01139008<br \/>\n1.906994542<br \/>\n1.780482109<br \/>\n1.65716389<br \/>\n1.560123288<br \/>\n1.506883103<br \/>\n1.506883103<br \/>\n1.560123288<\/p>\n<p>In case there include real and imaginary numbers in the input data, it becomes <strong>real number part and imaginary number part<\/strong> per row.<\/p>\n<p>Sample 02)<\/p>\n<p>50, 0<br \/>\n0, -25<br \/>\n0, 0<br \/>\n0, -12.5<br \/>\n0, 0<br \/>\n0, 0<\/p>\n<p>Please refer to the sample data saved as .CSV file format inside sampldata folder of the .zip file.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Data Acquisition<\/strong><\/h2>\n<p>Clicking File \u2192 LoadData and designating .CSV file allows data acquisition and shows the result of Fourier Transform (magnitude of each frequency after Fourier Transform).<br \/>\nFourier Transform runs FFT (in case the number of data is 2 to the n) and DFT (all other cases).<\/p>\n<p><img decoding=\"async\" class=\"size-800 wp-image-4983 alignnone\" src=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-800x580.jpg\" alt=\"\" width=\"800\" height=\"580\" srcset=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-200x145.jpg 200w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-300x218.jpg 300w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-400x290.jpg 400w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-600x435.jpg 600w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-768x557.jpg 768w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en-800x580.jpg 800w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/Graph_en.jpg 859w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Transform to DFT or IDFT<\/strong><\/h2>\n<p>In menu, clicking Fourier direction \u2192 Forward or Backward allows to transform to DFT or IDFT.<\/p>\n<p>DFT and IDFT are calculated as below formula.<\/p>\n<div id=\"attachment_4974\" style=\"width: 277px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4974\" class=\"wp-image-4974 size-full\" src=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/dft.png\" alt=\"\" width=\"267\" height=\"100\" srcset=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/dft-200x75.png 200w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/dft.png 267w\" sizes=\"(max-width: 267px) 100vw, 267px\" \/><p id=\"caption-attachment-4974\" class=\"wp-caption-text\">DFT Formula<\/p><\/div>\n<div id=\"attachment_4975\" style=\"width: 277px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4975\" class=\"wp-image-4975 size-full\" src=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/idft.png\" alt=\"\" width=\"267\" height=\"95\" srcset=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/idft-200x71.png 200w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/idft.png 267w\" sizes=\"(max-width: 267px) 100vw, 267px\" \/><p id=\"caption-attachment-4975\" class=\"wp-caption-text\">IDFT Formula<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Window function<\/strong><\/h2>\n<p>Clicking one of the following Window\u2192 Hamming, Hanning, Blackman allows you to apply each window function.<br \/>\nPlease note that once you apply window function, you are not able to retrieve the original data.<br \/>\nTherefore, if you need the original data, please recall the data again.<\/p>\n<div id=\"attachment_4972\" style=\"width: 412px\" class=\"wp-caption alignnone\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4972\" class=\"wp-image-4972 size-full\" src=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang.png\" alt=\"\" width=\"402\" height=\"234\" srcset=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang-200x116.png 200w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang-300x175.png 300w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang-400x233.png 400w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang.png 402w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><p id=\"caption-attachment-4972\" class=\"wp-caption-text\">before window function<\/p><\/div>\n<div id=\"attachment_4973\" style=\"width: 412px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4973\" class=\"wp-image-4973 size-full\" src=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang2.png\" alt=\"\" width=\"402\" height=\"234\" srcset=\"https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang2-200x116.png 200w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang2-300x175.png 300w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang2-400x233.png 400w, https:\/\/aval-global.com\/wp-content\/uploads\/2020\/04\/chang2.png 402w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><p id=\"caption-attachment-4973\" class=\"wp-caption-text\">after window function<\/p><\/div>\n<h2><strong>[Caution]<\/strong><\/h2>\n<p>All programs disclosed here can be used freely, however, please be careful to use them, as we are not held responsible for the problems caused by the program bugs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using MS Excel\u2019s Macro function allows an automatic transformation of [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":4983,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[242],"tags":[253],"class_list":["post-4981","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en","tag-c"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4981"}],"version-history":[{"count":5,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4981\/revisions"}],"predecessor-version":[{"id":8923,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4981\/revisions\/8923"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/media\/4983"}],"wp:attachment":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}