Interpreting magnitude of DFT results I'm working on creating a simple program to render spectrograms like this one. In this plot, the X-axis is time, the Y-axis is frequency, and the color represents the magnitude of the DFT at that frequency and time.

I have most of this working, but I'm not exactly sure how to interpret the magnitude value. I'm computing it as follows:

real * real + imaginary * imaginary

(Note that I'm not square rooting it, since Wikipedia indicates that the spectrogram should be related to the square of the magnitude.)

I've seen certain spectrograms which work with magnitude on the dBFS scale. What's the process to translate these magnitudes to this scale? Or, alternatively, is there some easier way to go about this?
One common practice is to take the log of the squared magnitude of the DFT frames, as in log(re*re+im*im), scale that, and use the scaled log as an integer index into an RGB color lookup table ("hotter" colors for larger magnitudes).  The scale is determined so that the range in your data fits within the color index table.

A log scale is used, since it's a closer match to human perception of loudness than a linear scale.

A square root is un-needed, as that's the same as adjusting the scale after the log by 0.5.