1

I may be getting some details wrong (e.g. colour space vs. colour model), so please bear with me:

I want to represent "images" consisting of complex numbers i.e. for each "pixel" there is a complex number with a magnitude ranging from 0-1 and a phase ranging from 0 to 2*pi.

I have a colour map which is supposedly good for displaying phase information (the one named "phase" here: https://matplotlib.org/cmocean/).

I can easily colour each pixel by the phase colour map, but I want to modulate the brightness (or some similar parameter) by the complex number's magnitude at each point. For a magnitude of zero, the pixel should be black and for a magnitude of 1, the pixel should "fully" be of the colour determined by the phase colour map (or any other suitable colour map).

The idea I've had is to convert the RGB triplet to a HSV triplet, and then set the V (brightness/value) value equal to the complex number's magnitude, and then I've converted it back for display. The H and S values remain unchanged.

This seems to work alright, but I've read that HSV is actually not a perceptually uniform colour space, so I'm wondering if anyone knows of a perceptually uniform colour space to use or perhaps just a better way to visualise complex number "images" effectively (without resorting to using separate images for the magnitude and the phase).

Chillpadde
  • 11
  • 2
  • Make two separate images for the phase and magnitude. I can't think of a scenario where visualising phase as an image would be helpful though. – lightxbulb Oct 21 '22 at 21:06
  • I already stated that I don't want to plot separate images. See this example (figure 13) where phase information is plotted as I described: https://doi.org/10.1017/jfm.2019.821. The phase of low amplitude pixels is not meaningful, so it needs to be removed via darkening. – Chillpadde Oct 21 '22 at 21:25
  • In the paper you cited they suggest using the cmocean colour maps that you have linked. Thus you should e.g. take the phase colour map and then multiply it by the magnitude multiplied by some constant (representing something like exposure). – lightxbulb Oct 21 '22 at 21:49
  • But this is precisely what is problematic - which colour representation would I multiply with the magnitude? Multiplying e.g. all of the RGB triplets by the factor would change the hue and who knows what else. The whole point of my question is to find a colour space where this brightness reduction operation isn't destructive. – Chillpadde Oct 21 '22 at 21:58
  • Judging by the paper you cited my guess is that they just multiplied the RGB triplets resulting from the phase colourmap with the magnitude multiplied by some constant (to account for "exposure"). Multiplying RGB triplets by a scalar $s$ changes the brightness, or what is sometimes referred to as intensity: $sI = s(R+G+B) / 3$. I don't get what you mean by destructive. It is invertible as long as $s\ne 0$. – lightxbulb Oct 21 '22 at 23:06
  • By destructive, I mean destructive to the hue and other parameters. The operation you describe is also not perceptually linear: https://stackoverflow.com/a/56678483/20305077 – Chillpadde Oct 22 '22 at 06:10
  • I highly doubt that in the paper they do anything as complex as in the stackoverfliw answer, but if you prefer the stackoverflow answer then implement it instead. – lightxbulb Oct 22 '22 at 08:07
  • Assuming phase is a circular value, i.e. 2*pi is equivalent to 0, then you could set the hue (H) to the phase, and the saturation (S) to maximimum. With the value set to magnitude this would combine both numbers in one display. It would be difficult to see the phase where the magnitude is low, but you have said that is not meaningful anyway. Multiplying each of the RGB values by the same scalar does not change the hue, unless the scalar is zero, as the hue is determined by the proportions of the RGB values. – Timothy Maguire Oct 22 '22 at 09:00
  • HSV can be done in two different ways, one where maximum saturation equals value, and one where maximimum saturation always equals one. Neither are perceptually uniform, but the underlying RGB space is not perceptually uniform to begin with. I think it would still work well enough using hue and value to display those two values. – Timothy Maguire Oct 22 '22 at 09:08
  • I understand that RGB and HSV are perceptually nonuniform - I have already said as much. Surely we must be able to traverse these spaces in a perceptually uniform way via some coordinate transform? – Chillpadde Oct 22 '22 at 09:30
  • colour perceptual uniformity is a difficult problem, CIELAB and CIECAM02 both attempt perceptual uniformity, but are more complex and there are problems. The value/brightness component is the simple part however, even sRGB uses gamma encoding such that it is perceptually uniform from black to white. I think just multiplying each of the sRGB values of the phase colour with the 0-1 magnitude value will get you the result you want. – Timothy Maguire Oct 22 '22 at 10:25
  • You can convert sRGB values to (CIE)Lab values via XYZ values, www.brucelindbloom.com has the necessary formulas under the “math” tab. You would then multiply each of the L, a, and b values by the 0-1 magnitude, and convert the new values back to sRGB, again via XYZ values. That would be the canonical way to do it with perceptual uniformity. – Timothy Maguire Oct 22 '22 at 14:00

0 Answers0