Jump to content
  • Advertisement
Sign in to follow this  
stele

Selective saturation with a color matrix?

This topic is 2768 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

I'm using Haeberli's color matrix stuff to do color correction.
http://www.graficaobscura.com/matrix/index.html
Using a 4x4 matrix I've got hue rotation, general saturation, brightness, contrast, etc.

Now I need to do saturation on the r,g,b primaries. Basically we need to isolate saturation on red, green, and blue. Say you have a picture of a green lawn and a blue sky. Lowering the saturation on "green" should interpolate the green stuff toward gray, leaving the sky alone. So it's not a simple per-channel blend to gray.

I know there is probably a magical matrix solution where you rotate the matrix to get the green channel to line up somehow, then just multiply by some numbers and then rotate back (sort of like was done for the hue/saturation matrix), but the math and order of operations escapes me.

Does anyone have any insight on how this can be done, without going entirely into HSL space?

Share this post


Link to post
Share on other sites
Advertisement

use a color LUT which u create in PhotoShop?


That would require a 3D lut, and I'd need three of them (one per primary red/green/blue). I really need an algorithmic solution.

Share this post


Link to post
Share on other sites

That would require a 3D lut, and I'd need three of them (one per primary red/green/blue). I really need an algorithmic solution.


No, it would only require one 3d lut, and it's easier to implement and performs better than any of the traditional algorithmic solutions.

http://renderwonk.co...g_hoffman_b.pdf

Share this post


Link to post
Share on other sites

[quote name='Stele' timestamp='1305148453' post='4809559']
That would require a 3D lut, and I'd need three of them (one per primary red/green/blue). I really need an algorithmic solution.


No, it would only require one 3d lut, and it's easier to implement and performs better than any of the traditional algorithmic solutions.

http://renderwonk.co...g_hoffman_b.pdf
[/quote]

Yep you're absolutely right - don't know what I was thinking!

I ended up faking it with a round-trip to and from hsl with a couple of 1D luts, but a generalized 3D lut would be much better. Thanks for the pointer to the nice documentation!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!