UIColor: Getter Methods for XYZ and LAB Color Values

Originator:ViccAlexander
Number:rdar://18016356 Date Originated:14-Aug-2014 01:04 AM
Status:Open Resolved:Unresolved
Product:iOS SDK Product Version:8.0
Classification:Feature Reproducible:Not Applicable
 
Summary:
I recently had to work with distances between colors, and as it's known, the best colorspace model to use with color distance (especially with regards to human perception) is LAB. Unfortunately, as of now, the iOS SDK provides no way of retrieving XYZ or LAB values easily. 

So instead, I created my own category on UIColor and added the following methods:

- (BOOL)getValueForX:(CGFloat *)X valueForY:(CGFloat *)Y valueForZ:(CGFloat *)Z alpha:(CGFloat *)alpha;

- (BOOL)getLightness:(CGFloat *)l valueForA:(CGFloat *)a valueForB:(CGFloat *)b alpha:(CGFloat *)alpha;

I've licensed it under the MIT license and I am sure many developers that deal with color logic in their apps would love these methods. 

I also made sure to model them as close as possible to the other UIColor methods that return rgb and hsb values.

I've included a sample project with thorough explanations and steps.

Steps to Reproduce:
Not-applicable.

Expected Results:
 Not-applicable.

Actual Results:
 Not-applicable.

Version:
I tested it on iOS 6.0 and above.

Notes:
Hopefully you consider adding such functionality! I've included a sample project with thorough explanations and steps. Cheers!

Configuration:
iPhone 5

Attachments:
'ColorLab.zip' was successfully uploaded.

Attachment Link: https://www.dropbox.com/s/d10yeotxe98qv5g/ColorLab.zip

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!