Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
814 views
in Technique[技术] by (71.8m points)

iphone - iOS: Values for CIFilter (Hue) from Photoshop

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...