I looked at
ColorConvert, but haven't found a relevant option. Is there a built-in function do this?
This is using the digital formula given at Wikipedia.
This below shows the 3 channels of each image
(for faster implementation of
Despite all the efforts of Nasser and MrWizard to make this fast, I believe the most natural way to do this is to use
the conversion is simply
This is almost twice as fast as the solution of MrWizard on my machine here (0.640s compared to 0.356s), but note that this was only tested on Mathematica 8 and 9 on Linux and MacOSX.
Furthermore, be aware that the two colour channels are in the interval
If you want to create the visualisation of the different channels, which is shown on the right side on the Wikipedia article page, you could simply use the inverse matrix. I shifted the colour channels by 0.5 here for display purposes
Regarding Mr.Wizards comment
I compared the following timings,
where first line is the method I described with the shift of
Running this code 100 times to mean out cosmic radiation, I get the following mean timings
I believe the difference in timing is purely the overhead of pattern matching and
Here is an array-optimized version of Nasser's formula. It is up to two orders of magnitude faster.
It handles data with an array depth of 1, 2, or 3, or an
A compiled version of Nasser's formula,