Jump to content
• Advertisement

# Efficient 24/32-bit sRGB to linear float image conversion on CPU

This topic is 1283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Does anyone know of some efficient ways of converting 24/32-bit sRGB to linear floating point on the CPU? I haven't got access to a CPU with AVX2 instructions yet, but I am intrigued by the new gather instructions. I was thinking that these could possibly be used for this type of conversion, such as in this example below. The LUT would be 256x4 bytes, so I imagine it would fit entirely into L1 data cache.

__m256 RGBA8toRGBA32F(const char* pixel_data, const float* LUT)
{
return _mm256_i32gather_ps(LUT, _mm256_cvtepu8_epi32(_mm_load_si128((__m128i*)pixel_data)), 4);
}

Edited by Chris_F

#### Share this post

##### Share on other sites
Advertisement

for a given sRGB (sR,sB,sG) and Gamma the RGB(R,G,B) will be :

R=pow(sR,1/Gamma)

G=pow(sG,1/Gamma)

B=pow(sB,1/Gamma)

but I don't think you can do this with AVX2's functions

#### Share this post

##### Share on other sites

for a given sRGB (sR,sB,sG) and Gamma the RGB(R,G,B) will be :

R=pow(sR,1/Gamma)

G=pow(sG,1/Gamma)

B=pow(sB,1/Gamma)

but I don't think you can do this with AVX2's functions

sRGB isn't a gamma, see: http://entropymine.com/imageworsener/srgbformula/

#### Share this post

##### Share on other sites

"Unlike most other RGB color spaces, the sRGB gamma cannot be expressed as a single numerical value. The overall gamma is approximately 2.2, consisting of a linear (gamma 1.0) section near black, and a non-linear section elsewhere involving a 2.4 exponent and a gamma (slope of log output versus log input) changing from 1.0 through about 2.3."

in http://en.wikipedia.org/wiki/SRGB 2nd paragraph well it says that sRGB is not using a single gamma and gpu uses a table to change the out put RGB to sRGB and the link you sent itself uses 2.4 as gamma

Edited by IYP

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5
• Advertisement

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632917
• Total Posts
3009200
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!