2

I have white out/black out (lighting designer features) implemented on a Color using the code below. Instead of iterating through colors in a bitmap I would like to implement this using a ColorMatrix on ImageAttributes. I have the blackout part done, basically adjusting Matrix40-42 between -1 (full blackout) and 0 (no blackout). I can also do whiteout by setting Matrix40-42 to 1 (full whiteout) and 0 (no whiteout). But I want to do them both in one shot. Here's the previous code operating on colors:

public static System.Drawing.Color AdjustColor(System.Drawing.Color input)
{
    var hsv = new HSV(input);

    // Test values for white out and black out
    double whiteOut = 0.5;
    double blackOut = 0.5;

    hsv.Saturation = hsv.Saturation + (HSV.White.Saturation - hsv.Saturation) * whiteOut;
    hsv.Value = Math.Min(1.0, hsv.Value + whiteOut) * (1 - blackOut);

    return hsv.Color;
}

The HSV helper class is just code I found online that maps the color to the HSV space, I don't think it's important for the answer to this question, but if it is I'll be happy to add references to it.

Haukman
  • 3,726
  • 2
  • 21
  • 33
  • I just want to point out that white out is not exactly the opposite of black out, if you crank up the white out then all colors will be white. But if you then increase black out then you're going towards black, but all colors are washed out, so it's gray. – Haukman Dec 29 '15 at 23:20
  • I can imagine what the HSV code looks like but not what the desired result should be. Can yu post a before&after example? – TaW Dec 30 '15 at 05:30
  • Absolutely, here's the code in a fiddler: https://dotnetfiddle.net/14ms8K – Haukman Dec 30 '15 at 08:19
  • Basically the whiteout/blackout can be considered brightness increase and decrease. I just want to combine them into one ColorMatrix if possible. But just subtracting blackout from whiteout doesn't yield the right result. – Haukman Dec 30 '15 at 08:20
  • Um, what I meant was that I really don't know what you want to achieve. Googling for whiteout&blackout brought no explanation nor any clear examples. Is it a special type of desaturation, maybe selective? Does applying the two ColorMatrices sequentially produce the right reslut? Maybe you find these links about ColorMatrix multiplication useful: [1](http://www.codeproject.com/Articles/7836/Multiple-Matrices-With-ColorMatrix-in-C), [2](http://pawjershauge.blogspot.de/2010/09/imagedrawing-extensions.html) – TaW Dec 30 '15 at 09:45
  • Yea white out and black out may not be the current term when doing image manipulations. But basically white out means bringing up brightness to max so everything is 100% white. Black out is the opposite, at 100% black out everything is black. White out is applied first, so if you bring white out to 100% and then black out to 50% everything will be 50% gray, even if you had blue, etc originally. Yes, it will be correct if I apply the ColorMatrix sequentially, so I'm basically looking for a way to merge two ColorMatrices in one shot, would multiply do that? – Haukman Dec 30 '15 at 21:51
  • But I have to apply the white out first (when doing it sequentially), otherwise it won't work. So multiplying the matrices doesn't seem to solve it. – Haukman Dec 30 '15 at 22:06
  • I'd really like to see what you want; can you post an image and its variations for 'whiteout' 'blackout' and the combination? Maybe a sharp increase on contrast along with some desaturation would do? Does the one Color (Red) in your code have some meaning? Maybe: don't touch reds??? I have tried to write a code that maximues the brightest ans minmized the darkest channel, but the result , not surprisingly, has maximum saturation.. – TaW Jan 01 '16 at 22:11
  • Sure, he's a quick and dirty .NET project that lets you move WO and BO sliders: https://github.com/HakanL/WhiteOutBlackOut – Haukman Jan 03 '16 at 20:09

0 Answers0