4

I am using the Hue filter to change the hue of an image:

CIFilter* hueFilter = 
     [CIFilter filterWithName:@"CIHueAdjust" <blah blah> 
        [NSNumber numberWithFloat:hue], nil];

I have the Hue number I wish to use from Photoshop, but it doesn't correspond to the results I get from iOS.

Is there a rule to change the number in PhotoShop to the number I should use in iOS?

Ian Vink
  • 66,960
  • 104
  • 341
  • 555

1 Answers1

16

The Hue in HSL/HSV color mode is an angular coordinate. In Photoshop, it is given in degrees (-180 to +180).

In the CIHueAdjust filter, the angle is given in radians. From http://developer.apple.com/library/ios/#documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CIHueAdjust

Parameters

inputAngle

An NSNumber class whose attribute type is CIAttributeTypeAngle and whose display name is Angle.

Default value: 0.00 Minimum: 0.00 Maximum: 0.00 Slider minimum: -3.14 Slider maximum: 3.14 Identity: 0.00

The formula to go from Photoshop value (degrees) to CIHueAdjust value (radians) is a linear conversion:

filterAngle = photoshopAngle * π / 180
Community
  • 1
  • 1
LodeRunner
  • 7,975
  • 3
  • 22
  • 24
  • It's also fair to add that the given `inputAngle` is not the final hue angle value but rather the angle for which the color cube will be rotated for. That said, if initial hue is `20` and you input an angle of value `10` the resulting hue value will be `30` and not `10`. – damirstuhec Feb 24 '16 at 09:02
  • Hey @lodeRunner have you done this but with the Saturation? Thanks! – Joaquin Pereira Oct 10 '21 at 16:42