<p>I may be getting some details wrong (e.g. colour space vs. colour model), so please bear with me:</p>
<p>I want to represent &quot;images&quot; consisting of complex numbers i.e. for each &quot;pixel&quot; there is a complex number with a magnitude ranging from 0-1 and a phase ranging from 0 to 2*pi.</p>
<p>I have a colour map which is supposedly good for displaying phase information (the one named &quot;phase&quot; here: <a href="https://matplotlib.org/cmocean/" rel="nofollow noreferrer">https://matplotlib.org/cmocean/</a>).</p>
<p>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 &quot;fully&quot; be of the colour determined by the phase colour map (or any other suitable colour map).</p>
<p>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.</p>
<p>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 &quot;images&quot; effectively (without resorting to using separate images for the magnitude and the phase).</p>

CC BY-SA 4.0
2022-10-21T21:06:29.260Z
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
CC BY-SA 4.0
2022-10-21T21:25:15.957Z
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
CC BY-SA 4.0
2022-10-21T21:49:46.657Z
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
CC BY-SA 4.0
2022-10-21T21:58:59.080Z
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
CC BY-SA 4.0
2022-10-21T23:06:03.833Z
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
CC BY-SA 4.0
2022-10-22T06:10:29.257Z
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
CC BY-SA 4.0
2022-10-22T08:07:30.260Z
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
CC BY-SA 4.0
2022-10-22T09:00:43.183Z
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
CC BY-SA 4.0
2022-10-22T09:08:14.363Z
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
CC BY-SA 4.0
2022-10-22T09:30:01.033Z
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
CC BY-SA 4.0
2022-10-22T10:25:37.173Z
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
CC BY-SA 4.0
2022-10-22T14:00:08.847Z
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
<shader><image-processing><color-science><colorspace><human-vision>
What is the best way to display complex number "images"?
Chillpadde
# What is the best way to display complex number "images"?

(Asked by: username_0 on 2022-10-21)

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).

**Tags:** shader, image-processing, color-science, colorspace, human-vision

> **Comments:**
> **username_1**: 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.  
> **username_0**: 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.  
> **username_1**: 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).  
> **username_0**: 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.  
> **username_1**: 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$.  
> **username_0**: 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  
> **username_1**: 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.  
> **username_2**: 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.  
> **username_2**: 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.  
> **username_0**: 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?  
> **username_2**: 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.  
> **username_2**: 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.  

---

## 0 answers

