-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More color matching functions. #45
Conversation
I’m working on the same cmf’s, too. I took mine from cvrl as well. I guess they are perfectly fine. |
Sorry to duplicate effort. Since you have more CMFs implemented, should I close this PR, or would you rather I merge and let you add your code on top? Either ways is fine with me. |
Merge your CMFs and I’ll add what I have/what is missing. |
More color matching functions.
Just to support the cause, I am very happy to see these implemented. These are standard data sets for use in colour vision research. Depending on whether you are interested in physiological or psychophysical aspects of colour, most people will use either the Smith & Pokorny cone fundamentals, the CIE 2°, 10°, or 2006 observer, or Stockman and Sharpe's cone fundamentals that form the foundation of the CIE 2006 standard observer. Andrew Stockman of the Stockman and Sharpe cone fundamentals is the principal maintainer of http://www.cvrl.org/ and he is an active and important researcher in colour vision, so you can trust what you find there. Now that these functions are available (thanks @dcjones and @m-lohmann and whoever else was involved in the earlier work!), we are set to implement some important physiological and psychophysical quantities that are frequently used in colour vision research, including two very important colour spaces (the MacLeod & Boynton chromaticity diagram 1 and the Derrington, Krauskopf, and Lennie (DKL) colour space 2). I already have these implemented in Matlab (as well as most of the DKL routines in Julia for my daily work) and should have time this weekend to port them over to Julia for easy use in this package. Actually, this raises a question. In colour vision research, it is becoming more and more frequent to transform a complete RGB image into an LMS (cone space) or DKL (second-stage mechanisms - retinal ganglion cell/LGN - space) image, and perform subsequent analysis. I have fast functions for the DKL transformations already implemented, but since they are designed for images, they probably fit better in the Images.jl package? cc: @timholy Awesome, |
I'm unfamiliar with DKL, but might I infer that the transformation involves a neighborhood of pixels around a point? If so, then Images seems appropriate. If it really is pixel-local, then I'd recommend Color.jl. But others might see things differently. |
@rennis250 I guess that transformation into cone space should be possible either via transformation matrices or by implementing the LMS functions directly which would be even faster, I guess. |
@m-lohmann Yes, that was my intention. Most people use transformation matrices, but functions sound more appropriate, especially if you want to specialise for extracting single cone values. Will do! :) @timholy DKL is heavily used in colour psychophysics and physiology, especially when one wants to relate visual psychophysics to the underlying physiology that mediates a given task (such as detection of small deviations from a given a colour). It doesn't really see use in industry or even computer vision. It's mainly used among the small group of human colour vision researchers. Actually, MacLeod & Boynton designed the original space, and DKL gave it a more selective "luminance" axis, so a small group of colour researches tend to call it the MBDKL space, although it is much more often referred to as the DKL space in the literature. It's power derives from it's specially chosen three axes. Each axis of the space selectively stimulates a given retinal ganglion cell channel, each of which has (ideally) independent activity and each of which acts as a main input to the visual cortex. One typically does a pixel-local operation to convert to LMS and DKL coordinates, even though the visual system technically performs a neighbourhood operation at the level of the retina (although, there are very interesting models for achieving sub-ganglion cell resolution from this encoding scheme and plenty of psychophysical evidence for it, but the actual physiological basis is a bit tricky). Anyway, I'll submit a pixel-wise conversion to Color.jl, but I've found the pixel-wise form that I have to be very slow for typical images that are used in the field (12-bit and 16-bit images of 30MB and greater). Usual practice is to take an RGB triplet and apply a conversion matrix to get the LMS or DKL coordinates. Applying this pixel by pixel can be slow and individuals will usually reshape an image to be a 3x(m*n) array, apply the 3x3 conversion matrix, and reshape back to the original image size, which is very fast. I picked up the approach from Thorsten Hansen of University of Giessen, who used it to improve the rgb2lms conversion functions of the McGill Calibrated Colour Image Database: http://tabby.vision.mcgill.ca Perhaps, the function approach that @m-lohmann suggests for the LMS conversion would be just as fast. I'll test it out and let you know. Thanks & Best, |
Color is indeed quite slow currently on 3x3 operations. A way forward was sketched out in #48. Although we could also define conversion operations for Arrays of ColorValues that would essentially do your reshape variant and use BLAS for the multiplication. I don't think that's being done now. |
I was looking into implementing the color vision deficiency simulation that @m-lohmann found in #43. That uses the Smith-Pokorny cone fundamentals, which according to this page is defined in terms of the Judd-Vos adjusted color matching function.
In this PR I've implemented more a general purpose color matching function to replace
cie_color_match
, calledcolormatch
which works like:colormatch(λ)
: evaluate CIE 1931 CMF (likecie_color_match
)colormatch(CIE1931_CMF, λ)
: evaluate CIE 1931 2-deg CMF (same ascolormatch(λ)
)colormatch(CIE1964_CMF, λ)
: evaluate CIE 1964 10-deg CMFcolormatch(CIE1931J_CMF, λ)
: Judd's adjustmentcolormatch(CIE1964JV_CMF, λ)
: Judd-Voss adjustmentSomeone else should sanity check this, since I didn't even know about these other color matching functions before yesterday. I got the data from http://www.cvrl.org/, it's in varying resolution, e.g. the Judd data is 10nm increments. If there's a higher resolution version somewhere, or other important CMFs that should be added, let me know.