title: Core Image CIColorControls brightness filter creates wrong effect. How do I change my image's luminance?
body: <p>I'm creating a color picker for iOS. I would like to enable the user to select the brightness (luminance) and have the color wheel reflect this change. I'm using Core Image to modify the brightness with the CIColorControls filter. Here's my code:</p>
  
  <pre><code>-(CIImage *)oldPhoto:(CIImage *)img withBrightness:(float)intensity
  {
      CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"];
      [lighten setValue:img forKey:kCIInputImageKey];
      [lighten setValue:@((intensity * 2.0) - 1.0) forKey:@"inputBrightness"];
      return lighten.outputImage;
  }
  </code></pre>
  
  <p>Here's how the color wheel looks with intensity = 0.5 (inputBrightness = 0):</p>
  
  <p><img src="https://i.stack.imgur.com/68GAj.png" alt="My image with inputBrightness = 0"></p>
  
  <p>The problem is that the color wheel looks wrong when intensity &lt; 0.5. For example, here's how it looks with intensity = 0.3 (inputBrightness = -0.4):</p>
  
  <p><img src="https://i.stack.imgur.com/bjloP.png" alt="My image with inputBrightness = -0.4"></p>
  
  <p>Notice that there's a black circle in the middle, and the rest of the image hasn't been darkened correctly either. This is supposed to be an HSL color wheel, so I guess that what I actually want to change is the luminance, not the brightness.</p>
  
  <p>First, can anyone explain why the image looks like this? I'm not an expert on color; it seems odd that the center of the circle quickly clips to black while the edges of it don't darken much.</p>
  
  <p>Second, how can I achieve the effect I want?</p>
  
  <p>Here's how I actually WANT the image to look:</p>
  
  <p><img src="https://i.stack.imgur.com/7Uor3.png" alt="Image with luminance = 0.3, generated with HSL function on CPU (too slow)"></p>
  
  <p>This was created with a custom HSL function and luminance = 0.3. This runs on the CPU, so it's far too slow for my needs. I'd be happy to post the code for this HSL function, but I didn't include it because it didn't seem immediately relevant. If you want to see it, just ask.</p>
  
  <p>Please let me know if you have any questions, or if anything seems unclear. Thanks!</p>