answersLogoWhite

0


Best Answer

/* Discrete Fourier Transform and Power Spectrum Calculates Power Spectrum from a Time Series Copyright 1985 Nicholas B. Tufillaro */ #include #include #define PI (3.1415926536) #define SIZE 512 double ts[SIZE], A[SIZE], B[SIZE], P[SIZE]; main() { int i, k, p, N, L; double avg, y, sum, psmax; /* read in and scale data points */ i = 0; while(scanf("%lf", &y) != EOF) { ts[i] = y/1000.0; i += 1; } /* get rid of last point and make sure # of data points is even */ if((i%2) == 0) i -= 2; else i -= 1; L = i; N = L/2; /* subtract out dc component from time series */ for(i = 0, avg = 0; i < L; ++i) { avg += ts[i]; } avg = avg/L; /* now subtract out the mean value from the time series */ for(i = 0; i < L; ++i) { ts[i] = ts[i] - avg; } /* o.k. guys, ready to do Fourier transform */ /* first do cosine series */ for(k = 0; k <= N; ++k) { for(p = 0, sum = 0; p < 2*N; ++p) { sum += ts[p]*cos(PI*k*p/N); } A[k] = sum/N; } /* now do sine series */ for(k = 0; k < N; ++k) { for(p = 0, sum = 0; p < 2*N; ++p) { sum += ts[p]*sin(PI*k*p/N); } B[k] = sum/N; } /* lastly, calculate the power spectrum */ for(i = 0; i <= N; ++i) { P[i] = sqrt(A[i]*A[i]+B[i]*B[i]); } /* find the maximum of the power spectrum to normalize */ for(i = 0, psmax = 0; i <= N; ++i) { if(P[i] > psmax) psmax = P[i]; } for(i = 0; i <= N; ++i) { P[i] = P[i]/psmax; } /* o.k., print out the results: k, P(k) */ for(k = 0; k <= N; ++k) { printf("%d %g\n", k, P[k]); } }

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: You want the code of Discrete fourier transform in C language for your image processing program using a filter function to enhance the tiff image.?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the definition of discrete function?

A relation that is defined for each element in its domain and for each input there is one and only one output.A discrete function is either equivalent to infinite sequences (if aperiodic) or to finite sequences, n-tuples (if periodic). In engineering language, it is the same as the term "sampled function".References: Fischer, J.V. On the Duality of Discrete and Periodic Functions. Mathematics 2015, 3, 299-318.


What is the function of the broca's and wernicke's areas?

Broca's area is responsible for speech production and language processing, while Wernicke's area is involved in language comprehension and understanding. Together, they play a crucial role in language processing and communication.


What is language processing activities?

what is the netural language processing


What is a sentence using the word discrete?

A relation that is defined for each element in its domain and for each input there is one and only one output.A discrete function is either equivalent to infinite sequences (if aperiodic) or to finite sequences, n-tuples (if periodic). In engineering language, it is the same as the term "sampled function".References: Fischer, J.V. On the Duality of Discrete and Periodic Functions. Mathematics 2015, 3, 299-318.


When was Information Processing Language created?

Information Processing Language was created in 1954.


What has the author A H Land written?

A. H. Land has written: 'Fortran codes for mathematical programming: linear, quadratic and discrete' -- subject(s): Data processing, FORTRAN (Computer program language), Programming (Mathematics)


What is the function of the singulate gyrus?

A region of the inferior parietal lobe of the brain that is involved in the processing of auditory and visual input and in the comprehension of language.


What is active language?

what is the netural language processing


What are the phases and passes of a general language processor?

Language processor consist of two phases 1.Analysis phase 2.Synthesis phase Language processor pass is the processing of every statement in a source program, or its equivalent representation to preform language processing function pass 1-It analyses the source program and notes relevant information. pass 2- It synthesizes the target program


What is the function of the syntax tree component in a language processing system?

The syntax tree component in a language processing system represents the hierarchical structure of a program's syntax. It is used to analyze and understand the relationships between different parts of the code, aiding in tasks such as parsing, semantic analysis, and code generation.


What has the author Huanye Sheng written?

Huanye Sheng has written: 'International workshop ILT&amp;CIP on innovative language technology and Chinese information processing' -- subject(s): Congresses, Natural language processing (Computer science), Computational linguistics, Data processing, Chinese language


What enables the computer to communicate with the user in the user's native language?

Natural Language Processing