"colour.dominant_wavelength" definition seems to struggle with precise spectral locus CMF xy values?
See original GitHub issueIssue Description
CMFS_1931 = colour.MSDS_CMFS["CIE 1931 2 Degree Standard Observer"]
CMFS_1931_xy = colour.XYZ_to_xy(CMFS_1931.values)
whitepoint = numpy.asarray([0.3101, 0.3163])
discard, locus_1931_samples_xy, discard = \
colour.dominant_wavelength(
CMFS_1931_xy,
whitepoint,
cmfs=CMFS_1931,
)
/usr/local/lib/python3.7/dist-packages/colour/algebra/geometry.py:326: RuntimeWarning: invalid value encountered in true_divide
u_a = numerator_a / denominator
/usr/local/lib/python3.7/dist-packages/colour/algebra/geometry.py:327: RuntimeWarning: divide by zero encountered in true_divide
u_b = numerator_b / denominator
/usr/local/lib/python3.7/dist-packages/colour/algebra/geometry.py:327: RuntimeWarning: invalid value encountered in true_divide
u_b = numerator_b / denominator
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-40-2288142fce39> in <module>()
10 CMFS_1931_xy,
11 whitepoint,
---> 12 cmfs=CMFS_1931,
14 )
3 frames
/usr/local/lib/python3.7/dist-packages/colour/colorimetry/dominant.py in dominant_wavelength(xy, xy_n, cmfs, inverse)
194 xy_s = XYZ_to_xy(cmfs.values)
195
--> 196 i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, xy_s, inverse)
197 xy_cwl = xy_wl
198 wl = cmfs.wavelengths[i_wl]
/usr/local/lib/python3.7/dist-packages/colour/colorimetry/dominant.py in closest_spectral_locus_wavelength(xy, xy_n, xy_s, inverse)
117 i_wl = np.argmin(scipy.spatial.distance.cdist(xy_wl, xy_s), axis=-1)
118
--> 119 i_wl = np.reshape(i_wl, xy.shape[0:-1])
120 xy_wl = np.reshape(xy_wl, xy.shape)
121
<__array_function__ internals> in reshape(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in reshape(a, newshape, order)
297 [5, 6]])
298 """
--> 299 return _wrapfunc(a, 'reshape', newshape, order=order)
300
301
/usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
56
57 try:
---> 58 return bound(*args, **kwds)
59 except TypeError:
60 # A TypeError occurs if the object does have such a method in its
ValueError: cannot reshape array of size 6225 into shape (471,)
Issue Analytics
- State:
- Created a year ago
- Comments:18 (18 by maintainers)
Top Results From Across the Web
Dominant wavelength - Wikipedia
In color science, the dominant wavelength is a method of characterizing a color's hue. Along with purity, it makes up one half of...
Read more >Chromaticity Diagram - an overview | ScienceDirect Topics
The spectrum locus is the set of chromaticity coordinates of pure monochromatic (single-wavelength) lights. All realizable colors fall within the spectrum ...
Read more >LED Dominant vs Peak Wavelength - What is Going On?
My personal view is that dominant wavelength is a marketing-led simplification of colour specification. We go from CIE XYZ tristimulus (3 ...
Read more >colour.dominant_wavelength — Colour 0.3.14 documentation
Returns the dominant wavelength λd for given colour stimulus xy and the related xywl first and xycw second intersection coordinates with the spectral...
Read more >2.4 COLORIMETRY - 2.Concepts - Language of Light
The dominant wavelength (DW) of a colour is the wavelength of the spectrum colour whose chromaticity is on the same straight line as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nah, one liner change.
I arrived at one via Shapely. Not sure if it is relevant or if it could be viable for Colour, but it seems to work pretty well. Essentially create a Shapely polygon from the CMFS, then use the intersection to calculate.