AlloSphere-Research-Group / AlloSystem

AlloSystem is a cross-platform suite of C++ components for building interactive multimedia tools and applications.
http://mat.ucsb.edu/allosphere/software.php
BSD 3-Clause "New" or "Revised" License
65 stars 22 forks source link

Perceptually Linear Color Spaces #30

Closed owengc closed 10 years ago

owengc commented 10 years ago

I have implemented a number of C.I.E. color spaces, including XYZ, Lab, Luv, and the corresponding cylindrical representations of Lab and Luv, which I've called HCLab and HCLuv, respectively. All changes should be found in al_Color.hpp and al_Color.cpp. The new classes are all modeled after the original color space classes Lance authored and therefore have similar interfaces and operator overloads. I'd be happy to answer any questions any of you might have about how I've implemented them or how to use them. Thanks!

grrrwaaa commented 10 years ago

I’d just like to say a big +1 for this — I’m a big fan of the HCL color spacea and I recommend everyone to use them for anything in which colors are to be interpolated.

The code looks great to me in general.

Perhaps the new #include dependencies (al_Mat, ) could be moved to the .cpp file? It doesn’t look as if they are needed in the header.

In RGB::operator= (const XYZ& v) and XYZ::operator= (const RGB& v), the transformMatrix variables could be made static const perhaps?

Have you tested the conversions? I tried porting some existing Lab/XYZ/HCL code from JS to Lua last year, and found that the math was wrong; the color conversions didn’t correspond to the theory (i.e. I had been working from a bad JS library…)

Nice work!

On May 7, 2014, at 8:50 AM, owengc notifications@github.com wrote:

I have implemented a number of C.I.E. color spaces, including XYZ, Lab, Luv, and the corresponding cylindrical representations of Lab and Luv, which I've called HCLab and HCLuv, respectively. All changes should be found in al_Color.hpp and al_Color.cpp. The new classes are all modeled after the original color space classes Lance authored and therefore have similar interfaces and operator overloads. I'd be happy to answer any questions any of you might have about how I've implemented them or how to use them. Thanks!

You can merge this Pull Request by running

git pull https://github.com/owengc/AlloSystem master Or view, comment on, or merge it at:

https://github.com/AlloSphere-Research-Group/AlloSystem/pull/30

Commit Summary

• initial commit. starting to paste OGC color classes into al_Color.hpp and adding supported methods to Color, Colori, RGB, and HSV classes • commented things out in order to start introducing new functions one by one • nearly done. need more testing • preparing for pull request to main codebase File Changes

• M allocore/allocore/types/al_Color.hpp (1305) • M allocore/src/types/al_Color.cpp (282) Patch Links:

https://github.com/AlloSphere-Research-Group/AlloSystem/pull/30.patchhttps://github.com/AlloSphere-Research-Group/AlloSystem/pull/30.diff — Reply to this email directly or view it on GitHub.

owengc commented 10 years ago

Thanks for the feedback, Graham! I did do a good amount of testing to verify that the color conversions were working properly. The only anomalies I found were some very minor floating point discrepancies after converting from, for example, RGB -> XYZ -> Lab -> XYZ -> RGB. However, these differences were far too small to be noticeable visually. I'm moving this request to the devel branch.

DrewRWx commented 10 years ago

Re-submitted against devel in #31 .