Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 20 10:00
    KelSolaar commented #486
  • Aug 20 09:59
    nick-shaw commented #486
  • Aug 20 09:58
    nick-shaw commented #486
  • Aug 20 09:10
    KelSolaar commented #486
  • Aug 18 04:22
    KelSolaar pinned #354
  • Aug 18 04:21
    KelSolaar pinned #396
  • Aug 18 04:20
    KelSolaar closed #436
  • Aug 18 04:18
    KelSolaar pinned #472
  • Aug 18 04:18
    KelSolaar unlabeled #474
  • Aug 18 03:55

    KelSolaar on develop

    Add "Code of Conduct" section t… Add "Dominik Moritz" (@domoritz… Merge branch 'feature/v0.3.14' … (compare)

  • Aug 18 03:54

    KelSolaar on v0.3.14

    Add "Dominik Moritz" (@domoritz… (compare)

  • Aug 18 03:29

    KelSolaar on v0.3.14

    Add "Code of Conduct" section t… (compare)

  • Aug 18 03:27

    KelSolaar on v0.3.14

    Add "Code of Conduct" section t… (compare)

  • Aug 17 06:33

    KelSolaar on develop

    Rename "colour.MultiSpectralDis… (compare)

  • Aug 17 06:20

    KelSolaar on v0.3.14

    Update various docstrings. Implement support for "colour.M… Merge pull request #494 from co… and 2 more (compare)

  • Aug 17 04:56

    KelSolaar on develop

    Update various docstrings. Merge branch 'feature/v0.3.14' … (compare)

  • Aug 17 04:55

    KelSolaar on multi_sds

    (compare)

  • Aug 17 04:55

    KelSolaar on log3g10_v1_v2

    (compare)

  • Aug 17 04:55

    KelSolaar on transfer_functions_naming

    (compare)

  • Aug 17 04:54

    KelSolaar on travis

    (compare)

Thomas Mansencal
@KelSolaar
I haven't tried yet though
Thomas Mansencal
@KelSolaar
@robbuckley : It should be working now, you need to grab the latest develop branch though!
robbuckley
@robbuckley
@KelSolaar thanks for that - I will try it later!
robbuckley
@robbuckley
another question - I am using colour.spectral_to_XYZ() on the 3 LED spectra which are the primaries of my display. The xy colour points are similar to what I expect. But I am trying to derive the photopic weighting R:G:B. What I mean by this is the ratio of the normalised spectrum of each primary, correlated with the Y colour matching function [which I understand to be the same as the photopic response curve].
My question is: does spectral_to_XYZ() normalise the spectrum (ie so that integral of the spectrum = 1.0), or should I do that myself?
thanks again! Here I am a little uncertain on both the API and the colour science aspects...
Thomas Mansencal
@KelSolaar
The conversion normalises the XYZ tristimulus values with a factor ksuch as k = 100 / (np.sum(y_bar * S) * dw)
where S is your illuminant values and dw your bin/interval size
so it will be dependent on whether your illuminant is normalised itself or not
but given you are computing the tristimulus values for a light source, you certainly don't want to normalise anything to preserve the ratio.
There is a highly related thread going on our Google Groups: https://groups.google.com/forum/#!topic/colour-science/AfDWfQPepfk
I would highly suggest looking at Part 2 of the Google Colab notebook I made
Thomas Mansencal
@KelSolaar
You will see how to build the corresponding RGB colourspace for your LEDs and coincidentally the RGB Luminance ratios.
Mansooriq
@Mansooriq
I was able to calculate Delta E for the RGB colors individually, how to calculate Delta E aas one number instead of 3 numbers ?
Thomas Mansencal
@KelSolaar
Sorry I'm a bit unclear, Delta E is for full Lab colours, alternatively you could pass an achromatic colour with just the Lightness value and a/b set to 0
Delta E is essentially the distance between 2 points
you need to give the 3d coordinates of those points
if you want to remove dimensions, you can set them to zero
Justin Mai
@justinTM
Hey guys, I've been using colour-science for a week now and I was wondering if I could ask some seemingly dumb questions...?
Justin Mai
@justinTM
I'm trying to plot colour-science plots as subplots on a single window, but I'm having a hard time understanding how colour-science integrates with matplotlib... How does the plot_single_sd() argument standalone work with multiple plots? What is it doing exactly?
Also, if subplots and/or multiple windows (figures) are present, where should I be calling colour-science.plotting.render() and when should I be using standalone=True?
Justin Mai
@justinTM
Really all I want to do is annotate the peak wavelength and value on a spectral distribution plot
Thomas Mansencal
@KelSolaar

Hi Justin,

The standalone=True argument will ensure the figure will be plotted directly after a call to the definition, e.g. colour.plotting. plot_single_sd, so if you want to annotate a figure with extra stuff, you need to use standalone=False when calling colour.plotting. plot_single_sd and then either call plt.show or colour.plotting.render

The latter does a few more things, e.g. setting up title, saving for file, etc...: https://github.com/colour-science/colour/blob/develop/colour/plotting/common.py#L549
The most advanced usage of Colour for plotting is here thus far: https://colab.research.google.com/drive/1bmVU8fI1Rv3GLXK8kVDovc2K2roGjW9G
You will see sub-plots & co in this notebook
Justin Mai
@justinTM
Excellent man thank you for the help.
Justin Mai
@justinTM

If I wanted to view many spectral distributions (measurements of a light source over hours) through time, what would be a good way to do that?

I was thinking about animating and plotting each one with a slider widget, do you think it would be reasonable to put plot_single_sd() into a FuncAnimation

Thomas Mansencal
@KelSolaar
Yeah that should work
you could also use the colour.plotting.plot_multi_sds() with a custom colour cycle going from white for old previous measurements to say saturated red for current.
Justin Mai
@justinTM
I wonder if I could remove certain lines and keep others? So I could plot the first SpectralDistribution and keep it, but then display only one additional (removing each previous one as it iterates along)?
Thomas Mansencal
@KelSolaar
I would need to try to see how it can be done, I haven't done much animation with MPL, one issue I can see is that the whole plot would likely to refresh atm
probably fine if you don't need realtime updating at high frequency
Thomas Mansencal
@KelSolaar
import matplotlib.pyplot as plt
import matplotlib.animation as animation

import colour
import colour.plotting

def animate_single_sd():
    figure, axes = colour.plotting.artist()


    def clear_axes():
        for patch in axes.patches:
            patch.remove()
        for line in axes.lines:
            line.remove()


    def animate(i):
        clear_axes()

        colour.plotting.plot_single_sd(
            colour.sd_constant(i + 0.01), axes=axes, standalone=False)


    a = animation.FuncAnimation(figure, animate, interval=10, blit=False)

    plt.show()

animate_single_sd()
This should work, can be made more elegant but this should plot a constant spectral distribution which has increasing power.
(the + 0.01 was just to avoid a singularity on the first plot with i=0)
Justin Mai
@justinTM
Sweet thank you for the code! It was the patch and line removal that I was missing. I’ll give this code a shot in a little bit
Justin Mai
@justinTM
@KelSolaar is there a way to plot_single_sd without the patches (ie spectral coloring)? to only print the lines? I tried doing patch.remove() in a for loop but I'm left with some strange choppy bar colors.
image.png
Thomas Mansencal
@KelSolaar
At that stage it would be more convenient to use directly the plot_multi_sds definition and only pass a single spd
would be faster since you would not have to clear the patches also
Collonville
@Collonville

@KelSolaar Hi!
When I using RGB_to_HSV function, it always gets me an error of RuntimeWarning. I've checked input RGB rang is 0 to 1 and it raises an error but it could calculate correct HSV value. I don't know this is an actual movement so could you pleased check it out?

I'm using
python version: 3.6.2
colour-science: 0.3.13

Input ndarray

[[ 0.92941176  0.10980392  0.14117647]
 [ 0.13333333  0.69411765  0.29803922]
 [ 0.24705882  0.28235294  0.8       ]
 [ 1.          1.          1.        ]]

Output of RGB_to_HSV

[[ 0.99362041  0.88185654  0.92941176]
 [ 0.38228438  0.8079096   0.69411765]
 [ 0.65602837  0.69117647  0.8       ]
 [ 0.          0.          1.        ]]

Error output

  File "A:\ドキュメント\ImageFeatureExtractor\ife\util\array.py", line 22, in convert_color_space_from_rgb
    return colour.RGB_to_HSV(np_image)
  File "C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py", line 126, in RGB_to_HSV
    delta_R = (((maximum - R) / 6) + (delta / 2)) / delta
C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py:126: RuntimeWarning: invalid value encountered in true_divide
  delta_R = (((maximum - R) / 6) + (delta / 2)) / delta
  File "A:\ドキュメント\ImageFeatureExtractor\ife\util\array.py", line 22, in convert_color_space_from_rgb
    return colour.RGB_to_HSV(np_image)
  File "C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py", line 127, in RGB_to_HSV
    delta_G = (((maximum - G) / 6) + (delta / 2)) / delta
C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py:127: RuntimeWarning: invalid value encountered in true_divide
  delta_G = (((maximum - G) / 6) + (delta / 2)) / delta
  File "A:\ドキュメント\ImageFeatureExtractor\ife\util\array.py", line 22, in convert_color_space_from_rgb
    return colour.RGB_to_HSV(np_image)
  File "C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py", line 128, in RGB_to_HSV
    delta_B = (((maximum - B) / 6) + (delta / 2)) / delta
C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py:128: RuntimeWarning: invalid value encountered in true_divide
  delta_B = (((maximum - B) / 6) + (delta / 2)) / delta
  File "A:\ドキュメント\ImageFeatureExtractor\ife\util\array.py", line 22, in convert_color_space_from_rgb
    return colour.RGB_to_HSV(np_image)
  File "C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py", line 133, in RGB_to_HSV
    H[np.asarray(H < 0)] += 1
C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py:133: RuntimeWarning: invalid value encountered in less
  H[np.asarray(H < 0)] += 1
  File "A:\ドキュメント\ImageFeatureExtractor\ife\util\array.py", line 22, in convert_color_space_from_rgb
    return colour.RGB_to_HSV(np_image)
  File "C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py", line 134, in RGB_to_HSV
    H[np.asarray(H > 1)] -= 1
C:\ProgramData\Anaconda3\envs\ImageFeatureExtractor\lib\site-packages\colour\models\rgb\deprecated.py:134: RuntimeWarning: invalid value encountered in greater
  H[np.asarray(H > 1)] -= 1
Thomas Mansencal
@KelSolaar
It should not be an issue, you end up with a zero division for [1, 1, 1], it generates NaNs and the warnings. We could probably handle them gracefully though, note that you still get the proper output:
>>> import colour
>>> colour.RGB_to_HSV([1, 1, 1])
  File "<stdin>", line 1, in <module>
  File "/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py", line 126, in RGB_to_HSV
    delta_R = (((maximum - R) / 6) + (delta / 2)) / delta
/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py:126: RuntimeWarning: invalid value encountered in double_scalars
  delta_R = (((maximum - R) / 6) + (delta / 2)) / delta
  File "<stdin>", line 1, in <module>
  File "/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py", line 127, in RGB_to_HSV
    delta_G = (((maximum - G) / 6) + (delta / 2)) / delta
/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py:127: RuntimeWarning: invalid value encountered in double_scalars
  delta_G = (((maximum - G) / 6) + (delta / 2)) / delta
  File "<stdin>", line 1, in <module>
  File "/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py", line 128, in RGB_to_HSV
    delta_B = (((maximum - B) / 6) + (delta / 2)) / delta
/Users/kelsolaar/Documents/Development/colour-science/colour/colour/models/rgb/deprecated.py:128: RuntimeWarning: invalid value encountered in double_scalars
  delta_B = (((maximum - B) / 6) + (delta / 2)) / delta
array([ 0.,  0.,  1.])
you can use colour.utilities.filter_warnings(python_warnings=True) to filter all Colour and Python warnings
Collonville
@Collonville
@KelSolaar Thanks! filter_warnings worked for me.
lkschwaller
@lkschwaller
Hi; pretty new to python and colourimetry so this may seem SUPER dumb; I do a lot of work with taking measurements of LED from a Radiant Colourimeter, which gives me chromaticity coordinates in Cie 1931; I've been hoping to improve my reports by graphing on the actual CIE space; so is it possible to use this library to graph proper CIEX and CIEY coords onto the CIE 1931 space?
Thomas Mansencal
@KelSolaar
There is no such a thing as a dumb question :)
And yes this is absolutely possible
You can run the whole notebook online too!