fourier | Fast Fourier transforms in Rust | Video Utils library

 by   calebzulawski Rust Version: Current License: Non-SPDX

kandi X-RAY | fourier Summary

kandi X-RAY | fourier Summary

fourier is a Rust library typically used in Video, Video Utils applications. fourier has no bugs, it has no vulnerabilities and it has low support. However fourier has a Non-SPDX License. You can download it from GitHub.

[Rust Documentation] Fast Fourier transforms (FFTs) in Rust.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              fourier has a low active ecosystem.
              It has 212 star(s) with 16 fork(s). There are 10 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 11 open issues and 4 have been closed. On average issues are closed in 26 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of fourier is current.

            kandi-Quality Quality

              fourier has 0 bugs and 0 code smells.

            kandi-Security Security

              fourier has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              fourier code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              fourier has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              fourier releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fourier
            Get all kandi verified functions for this library.

            fourier Key Features

            No Key Features are available at this moment for fourier.

            fourier Examples and Code Snippets

            Inverse Fourier Transform .
            pythondot img1Lines of Code : 118dot img1License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def inverse_stft(stfts,
                             frame_length,
                             frame_step,
                             fft_length=None,
                             window_fn=window_ops.hann_window,
                             name=None):
              """Computes the inverse [Short-time Fourier Transf  
            Compute the Fourier Transform .
            pythondot img2Lines of Code : 57dot img2License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def stft(signals, frame_length, frame_step, fft_length=None,
                     window_fn=window_ops.hann_window,
                     pad_end=False, name=None):
              """Computes the [Short-time Fourier Transform][stft] of `signals`.
            
              Implemented with TPU/GPU-compatible op  
            r Solve the Fourier transform .
            pythondot img3Lines of Code : 13dot img3License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def _solve(self, rhs, adjoint=False, adjoint_arg=False):
                rhs = linalg.adjoint(rhs) if adjoint_arg else rhs
                spectrum = _to_complex(self.spectrum)
                if adjoint:
                  spectrum = math_ops.conj(spectrum)
            
                rhs, spectrum = self._broadcast_bat  

            Community Discussions

            QUESTION

            Using FFT to approximate the CDF for an aggregate loss random variable
            Asked 2022-Apr-03 at 14:31

            Below you will find my python code for a class assignment I was given a couple weeks ago which I have been unable to successfully debug. The problem is about finding the value at risk (i.e., the p% quantile) for an aggregate loss random variable, using FFT. We are given a clear mathematical procedure by which we can gain an estimation of the discretized CDF of the aggregate loss random variable. My results are, however, seriously off and I am making some kind of mistake which I have been unable to find even after hours of debugging my code.

            The aggregate loss random variable S is given such that S=sum(X_i for i in range(N)), where N is negative binomially distributed with r=5, beta=.2, and X_i is exponentially distributed with theta=1. The probability generating function for this parametrization is P(z)=[1-\beta(z-1)]^{-r}.

            We were asked to approximate the distribution of S by

            1. choosing a grid width h and an integer n such that r=2^n is the number of elements to discretize X on,
            2. discretizing X and calculating the probabilities of being in equally spaced intervals of width h,
            3. applying the FFT to the discretized X,
            4. applying the PGF of N to the elements of the Fourier-transformed X,
            5. applying the inverse FFT to this vector.

            The resulting vector should be an approximation for the probability masses of each such interval for S. I know from previous methods that the 95% VaR ought to be ~4 and the 99.9% VaR ought to be ~10. But my code returns nonsensical results. Generally speaking, my index where the ECDF reaches levels >0.95 is way too late, and even after hours of debugging I have not managed to find where I am going wrong.

            I have also asked this question on the math stackexchange, since this question is very much on the intersection of programming and math and I have no idea at this moment whether the issue is on the implementation side of things or whether I am applying the mathematical ideas wrong.

            ...

            ANSWER

            Answered 2022-Apr-03 at 14:31

            Not sure about math, but in snippet variable r gets overrided, and when computing f_tilde_vec_fft function PGF uses not 5 as expected for r, but 1024. Fix -- change name r to r_nb in definition of hyperparameters:

            r_nb, beta, theta = 5, .2, 1

            and also in function PGF:

            return (1 - beta * (z - 1)) ** (-r_nb)

            After run with other parameters remain same (such as h, n etc.) for VaRs I get [4.05, 9.06]

            Source https://stackoverflow.com/questions/71675713

            QUESTION

            Equivalent to torch.rfft() in newest PyTorch version
            Asked 2022-Mar-18 at 15:12

            I want to estimate the fourier transform for a given image of size BxCxWxH

            In previous torch version the following did the job:

            ...

            ANSWER

            Answered 2022-Mar-18 at 15:12

            A few issues

            1. The dim argument you provided is an invalid type, it should be a tuple of two numbers or should be omitted. Really PyTorch should raise an exception. I would argue that the fact this ran without exception is a bug in PyTorch (I opened a ticket stating as much).
            2. PyTorch now supports complex tensor types, so FFT functions return those instead of adding a new dimension for the real/imaginary parts. You can use torch.view_as_real to convert to the old representation. Also worth pointing out that view_as_real doesn't copy data since it returns a view so shouldn't slow things down in any noticeable way.
            3. PyTorch no longer gives the option of disabling one-sided calculation in RFFT. Probably because disabling one-sided makes the result identical to torch.fft.fft2, which is in conflict with the 13th aphorism of PEP 20. The whole point of providing a special real-valued version of the FFT is that you need only compute half the values for each dimension, since the rest can be inferred via the Hermition symmetric property.

            So from all that you should be able to use

            Source https://stackoverflow.com/questions/71515439

            QUESTION

            Missalgined circles in Fourier Series/Transform using Python and Tkinter
            Asked 2022-Mar-06 at 07:02

            I made a Fourier Series/Transform Tkinter app, and so far everything works as I want it to, except that I am having issues with the circles misaligning. Here is an image explaining my issue (the green and pink were added after the fact to better explain the issue):

            I have narrowed down the problem to the start of the lines, as it seems that they end in the correct place, and the circles are in their correct places. The distance between the correct positions and the position where the lines start seems to grow, but is actually proportional to the speed of the circle rotating, as the circle rotates by larger amounts, thus going faster.

            Here is the code:

            ...

            ANSWER

            Answered 2022-Mar-05 at 20:55

            The main problem that you are facing is that you receive floating point numbers from your calculations but you can only use integers for pixels. In the following I will show you where you fail and the quickest way to solve the issue.

            First your goal is to have connected lines and you calculate the points here:

            Source https://stackoverflow.com/questions/71271840

            QUESTION

            rotation in frequency domain - question about question 64441200
            Asked 2022-Mar-02 at 16:43

            Following : How to rotate a non-squared image in frequency domain

            I just ran this exact code (copy pasted from the author's code with just an additional normalization of the resulting image between 0 an 255 as shown) ... but I get horrible "aliasing" artifacts ... How is this possible ? I see that the OP shows nice unartifacted images from the rotation in frequency space... I would be very curious to know how to obtain that, surely you did not show all your code?

            ...

            ANSWER

            Answered 2022-Mar-02 at 16:43

            The DFT imposes a periodicity to the image in both the frequency and the spatial domain (some people disagree with this, but still agree that this view is a good way to explain just about everything that happens in the DFT...). So imagine that your input is not the Shepp-Logan phantom, but an infinite repetition of it. When manipulating the data in the frequency domain, you affect not just the one copy of the image you see, but all of them, and not always in intuitive ways.

            One of the consequences is that neighboring copies of your image in the spatial domain rotate, but also expand and come into you image.

            The simplest way to avoid this is to pad the image with zeros to double its size.

            Source https://stackoverflow.com/questions/71325255

            QUESTION

            Plotting two variables against each other but getting two lines instead of just one
            Asked 2022-Feb-27 at 14:24

            For my physics Research Practicum I'm analyzing the resonance frequency of a wine glass, which involves importing an audio file and taking its Fourier transform (using scipy.fftpack). So everything is going well, but when I plot the Fourier transform, I get two lines: one is the plot you would expect, but the other one is a horizontal line (see picture). I've looked into the variables I'm plotting but nothing seems out of the ordinary there.

            Here's the code (you'll need this .wav file (watch out for your ears, headphone users!)):

            ...

            ANSWER

            Answered 2022-Feb-27 at 14:04

            This is how the plot of Fourier_x alone looks like:

            Source https://stackoverflow.com/questions/71285284

            QUESTION

            mapping colors to amplitude
            Asked 2022-Feb-14 at 16:47

            I am working on a music visualizer and I am hoping for the colors on the spectrum to gradually change from green to red based on the amplitude. Here are the instructions given:

            Change the colour of each bar such that it gradually changes from green to red based on the amplitude value [2 marks]. For example

            An amplitude value of 0 the colour values are R:0, G:255 and B:0. An amplitude value of 127 colour values are R:127, G:127 and B:0 An amplitude value of 255 colour values are R:255, G:0 and B: 0

            Here is my code:

            ...

            ANSWER

            Answered 2022-Feb-14 at 16:47

            what you have there are specific points in a function, but you've defined those points for entire ranges. What you should do is write a function that outputs these values in a smooth fashion.

            So let's look at your first number, which I assume is the R (red) value. if(spectrum[i] > 200) red = 255; if(spectrum[i] > 100 && spectrum[i] < 200) red = 127; else red = 0; What if instead of outputting single values, you made a function to map the amplitude directly to a Red value? To start with, make it really simple:

            Source https://stackoverflow.com/questions/71115211

            QUESTION

            Round trip through cv::dft() and cv::DFT_INVERSE leads to doubling magnitude of 1d samples
            Asked 2022-Feb-13 at 22:31

            I'm playing with some toy code, to try to verify that I understand how discrete fourier transforms work in OpenCV. I've found a rather perplexing case, and I believe the reason is that the flags I'm calling cv::dft() with, are incorrect.

            I start with a 1-dimensional array of real-valued (e.g. audio) samples. (Stored in a cv::Mat as a column.)

            I use cv::dft() to get a complex-valued array of fourier buckets.

            I use cv::dft(), with cv::DFT_INVERSE, to convert it back.

            I do this several times, printing the results. The results seem to be the correct shape but the wrong magnitude.

            Code:

            ...

            ANSWER

            Answered 2022-Feb-13 at 22:31

            The inverse DFT in opencv will not scale the result by default, so you get your input times the length of the array. This is a common optimization, because the scaling is not always needed and the most efficient algorithms for the inverse DFT just use the forward DFT which does not produce the scaling. You can solve this by adding the cv::DFT_SCALE flag to your inverse DFT.

            Some libraries scale both forward and backward transformation with 1/sqrt(N), so it is often useful to check the documentation (or write quick test code) when working with Fourier Transformations.

            Source https://stackoverflow.com/questions/71104954

            QUESTION

            A problem with sound producing: How to make sound with Fourier coefficients
            Asked 2022-Feb-04 at 23:39

            I'm trying to create a sound using Fourier coefficients.

            First of all please let me show how I got Fourier coefficients.

            (1) I took a snapshot of a waveform from a microphone sound.

            • Getting microphone: getUserMedia()
            • Getting microphone sound: MediaStreamAudioSourceNode
            • Getting waveform data: AnalyserNode.getByteTimeDomainData()

            The data looks like the below: (I stringified Uint8Array, which is the return value of getByteTimeDomainData(), and added length property in order to change this object to Array later)

            ...

            ANSWER

            Answered 2022-Feb-04 at 23:39

            In golang I have taken an array ARR1 which represents a time series ( could be audio or in my case an image ) where each element of this time domain array is a floating point value which represents the height of the raw audio curve as it wobbles ... I then fed this floating point array into a FFT call which returned a new array ARR2 by definition in the frequency domain where each element of this array is a single complex number where both the real and the imaginary parts are floating points ... when I then fed this array into an inverse FFT call ( IFFT ) it gave back a floating point array ARR3 in the time domain ... to a first approximation ARR3 matched ARR1 ... needless to say if I then took ARR3 and fed it into a FFT call its output ARR4 would match ARR2 ... essentially you have this time_domain_array --> FFT call -> frequency_domain_array --> InverseFFT call -> time_domain_array ... rinse N repeat

            I know Web Audio API has a FFT call ... do not know whether it has an IFFT api call however if no IFFT ( inverse FFT ) you can write your own such function here is how ... iterate across ARR2 and for each element calculate the magnitude of this frequency ( each element of ARR2 represents one frequency and in the literature you will see ARR2 referred to as the frequency bins which simply means each element of the array holds one complex number and as you iterate across the array each successive element represents a distinct frequency starting from element 0 to store frequency 0 and each subsequent array element will represent a frequency defined by adding incr_freq to the frequency of the prior array element )

            Each index of ARR2 represents a frequency where element 0 is the DC bias which is the zero offset bias of your input ARR1 curve if its centered about the zero crossing point this value is zero normally element 0 can be ignored ... the difference in frequency between each element of ARR2 is a constant frequency increment which can be calculated using

            Source https://stackoverflow.com/questions/70974735

            QUESTION

            python scipy.fft huge y scale of Fast Fourier Transform
            Asked 2022-Jan-21 at 07:55

            I have a working python script for Fast Fourier Transform (fft) signal which plots the graph and fft correctly, I am fetching data from postgre so I ommited that code. And due to limit of paste i pasted shorter version of signal, but the signal is preatty much the similar on longer timeframe.

            The x scale of fft is fine, but what i get is a large y scale which i do not understand.

            I have an fft processed by machine directly that looks correct and i have another measurement done by hand held machine. The ffts look almost identical on x scale and relative sizes on y scale, but the actual calculated y scale differ a lot.

            data

            plot from python

            from device

            In script data_step is in micro second between two timestamps. The n and datastep cant be wrong since the x axis is fine. From the data i get:

            ...

            ANSWER

            Answered 2022-Jan-21 at 07:55

            The value of rfft is proportional both to the magnitude of the data and the number of points. So you should expect the values in yf to be large.

            Compare:

            Source https://stackoverflow.com/questions/70797544

            QUESTION

            Output of fft.fft() for magnitude and phase (angle) not corresponding the the values set up
            Asked 2022-Jan-18 at 21:18

            I set up a sine wave of a certain amplitude, frequency and phase, and tried recovering the amplitude and phase:

            ...

            ANSWER

            Answered 2022-Jan-18 at 21:18
            • You need to normalize the fft by 1/N with one of the two following changes (I used the 2nd one):
              S = np.fft.fft(s) --> S = 1/N*np.fft.fft(s)
              magnitude = np.abs(S[index[0]]) --> magnitude = 1/N*np.abs(S[index[0]])
            • Don't use index, = np.where(np.isclose(frequency, f0, atol=1/(T*N))), the fft is not exact and the highest magnitude may not be at f0, use np.argmax(np.abs(S)) instead which will give you the peak of the signal which will be very close to f0
            • np.angle messes up (I think its one of those pi,pi/2 arctan offset things) just do it manually with np.arctan(np.real(x)/np.imag(x))
            • use more points (I made N higher) and make T smaller for higher accuracy
            • since a DFT (discrete fourier transform) is double sided and has peak signals in both the negative and positive frequencies, the peak in the positive side will only be half the actual magnitude. For an fft you need to multiply every frequency by two except for f=0 to acount for this. I multiplied by 2 in magnitude = np.abs(S[index])*2/N

            Source https://stackoverflow.com/questions/70759395

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install fourier

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/calebzulawski/fourier.git

          • CLI

            gh repo clone calebzulawski/fourier

          • sshUrl

            git@github.com:calebzulawski/fourier.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Video Utils Libraries

            obs-studio

            by obsproject

            video.js

            by videojs

            ijkplayer

            by bilibili

            FFmpeg

            by FFmpeg

            iina

            by iina

            Try Top Libraries by calebzulawski

            multiversion

            by calebzulawskiRust

            cotila

            by calebzulawskiC++

            generic-simd

            by calebzulawskiRust

            hippo

            by calebzulawskiC++

            symbol-slasher

            by calebzulawskiC++