I have written an application to compute the FFT and I would like to know a good way to visualize the spectrum in color.
Unfortunately my naiive attempts have not yielded good results. I would like to achieve something like this:
I am currently using this for colorization
float r = std::log( std::abs(source[u][v]) + 1 ) * 0.2f;
float g = std::log( std::max(std::abs(source[u][v]) - 10.0f, 0.0f) + 1 ) * 0.2f;
float b = std::log( std::max(std::abs(source[u][v]) - 100.0f, 0.0f) + 1 ) * 0.2f;
I propose the following approach. First, choose a maximum value (the one to represent “red”) and scale all values in the [0, 1] interval. Next, use this value for the hue and use a HSL to RGB transformation. The Python code would look like this:
With the result: