<p>The direct answer to your question is yes: you can use glsl to convert a pixel value between different color models such as RGB and CIELAB, although you have to consider how your RGB space matches to XYZ tristimulus values, but that's a bit outside the scope of this question.</p>
<p>Basically, as long as you have a closed function to convert between color models, you can leverage a GPU to do this for you, and you can use GLSL to do so.</p>
<p>Ultimately, whether or not it makes sense to do this with a GPU, and which type of shader stage to use, is up to what you want to do with the conversion.</p>
<p>If you simply want to convert one file from one model to another, you should consider using existing software such as Photoshop or Gimp. If you need to convert many files, these tools have methods for automating the conversion process.</p>
<p>Alternatively you can make a regular program, for example in C# to do transformations as needed. I particularly like using the System.Drawing library for manipulating images in an easy way.</p>
<p>If you want to do the conversion for drawing the image on the screen, then you can definitely leverage the graphics pipeline to help you do this. The most natural place to do this is in the fragment shader, but depending on what you're doing, you may also want to consider doing this in a compute shader. The code will basically be the same, but the code to prepare the pipeline will be different.</p>
<p>Without knowing what is it exactly that you want to do, it's quite difficult to give more concrete advice though.</p>

CC BY-SA 4.0
2022-01-28T10:32:03.540Z
2022-01-28T10:32:03.540Z
Panda Pajama
<p>It is possible to convert an image or other output to CIE Lab color model using GLSL? Does it require compute shaders or can be done using only vertex shaders?</p>

CC BY-SA 4.0
2022-01-26T17:02:01.017Z
What do you mean by "convert an image"? Are you trying to read pixels of an image, do some math on them, and write data in a different format to some other storage? Are you trying to do this in-situ within an image? Or do you want to simply do a transformation when you read a texel, then use that in some rendering operation?
Nicol Bolas
CC BY-SA 4.0
2022-01-26T20:04:33.080Z
Read pixels to change its colors.
vaunnaut
<glsl>
Convert image to CIE Lab using GLSL to change hue/chroma
vaunnaut
# Convert image to CIE Lab using GLSL to change hue/chroma

(Asked by: username_0 on 2022-01-03)

It is possible to convert an image or other output to CIE Lab color model using GLSL? Does it require compute shaders or can be done using only vertex shaders?

**Tags:** glsl

> **Comments:**
> **username_1**: What do you mean by "convert an image"? Are you trying to read pixels of an image, do some math on them, and write data in a different format to some other storage? Are you trying to do this in-situ within an image? Or do you want to simply do a transformation when you read a texel, then use that in some rendering operation?  
> **username_0**: Read pixels to change its colors.  

---

## 1 answers

### Answer by username_2 on 2022-01-28. Score: 1

The direct answer to your question is yes: you can use glsl to convert a pixel value between different color models such as RGB and CIELAB, although you have to consider how your RGB space matches to XYZ tristimulus values, but that's a bit outside the scope of this question.

Basically, as long as you have a closed function to convert between color models, you can leverage a GPU to do this for you, and you can use GLSL to do so.

Ultimately, whether or not it makes sense to do this with a GPU, and which type of shader stage to use, is up to what you want to do with the conversion.

If you simply want to convert one file from one model to another, you should consider using existing software such as Photoshop or Gimp. If you need to convert many files, these tools have methods for automating the conversion process.

Alternatively you can make a regular program, for example in C# to do transformations as needed. I particularly like using the System.Drawing library for manipulating images in an easy way.

If you want to do the conversion for drawing the image on the screen, then you can definitely leverage the graphics pipeline to help you do this. The most natural place to do this is in the fragment shader, but depending on what you're doing, you may also want to consider doing this in a compute shader. The code will basically be the same, but the code to prepare the pipeline will be different.

Without knowing what is it exactly that you want to do, it's quite difficult to give more concrete advice though.


---

