JErnestoMtz / rapl

Rank Polymorphic array library for Rust.
103 stars 3 forks source link

FFT #22

Closed JErnestoMtz closed 1 year ago

JErnestoMtz commented 1 year ago

This issue is for raking the implementation for FFT.

Now that we have Complex Numbers, Fast Fourier Transform is one of may logical steps forward, I also think that neither ndarray nor nalgebra has FFT as a built in feature, therefore it would provide a lot of value to have a simple to use 1D and 2D FFT with similar API as numpy.

DeliciousHair commented 1 year ago

Very logical, but I would suggest that since you have such an effective tool here anyway, it may be better to jump straight into a little more "fully featured" version a-la what scipy provides. Just my two cents of course.

JErnestoMtz commented 1 year ago

What would be the main difference between Numpy and Scipy fft?, I haven't look too deep into the docs of both of them, but I have use both almost interchangeably.

JErnestoMtz commented 1 year ago

I've been laying the groundwork for the FFT implementation. First I did some file cleanup and organization. But I also added a cool new feature to open images as Ndarr, and save Ndarr as images. Here is quick example:

use rapl::*;
use rapl::utils::rapl_img;

fn main() {
    //open image as Ndarr<u8,3>
    let img: Ndarr<u8,3> = rapl_img::open_rgbu8(&"test_img.jpg").unwrap();
    //Split RGB channels by Slicing along 3'th axis and
    let channels: Vec<Ndarr<u8,2>> = img.slice_at(2);
    //select blue channel and save it as black and white image
    channels[2].save_as_luma(&"blue_channel.png", rapl_img::ImageFormat::Png);
}

This of course was mainly added to use in addition with FFT, but I think manipulating images with the simple interface of rapl turn out to be a quite pleasant experience.