coloria-dev / coloria

:rainbow: Tools for color research
385 stars 31 forks source link

Errors with plot_rgb_gamut() #145

Closed 1ogic closed 3 years ago

1ogic commented 3 years ago

HSL and HSV don't have attributes from_xyz100 causing an error when using with plot_rgb_gamut().

Using CIECAM02 and CAM16 with plot_rgb_gamut() causes a ValueError at line 48 in _rgb_gamut.py. At some point it makes an array with shape (140688,7) when it should be (X,3).

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    p = colorio.plot_rgb_gamut(colorspace, n=51, show_grid=True)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/colorio/_rgb_gamut.py", line 48, in plot_rgb_gamut
    grid = pv.UnstructuredGrid(cells.ravel(), celltypes, cs_coords)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyvista/core/pointset.py", line 593, in __init__
    self._from_arrays(None, args[0], args[1], args[2], deep)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyvista/core/pointset.py", line 698, in _from_arrays
    points = pyvista.vtk_points(points, deep=deep)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyvista/utilities/helpers.py", line 270, in vtk_points
    raise ValueError('Points array must contain three values per point. '
ValueError: Points array must contain three values per point. Shape is (140608, 7) and should be (X, 3)

using XYY and CIELUV shows some runtime warnings

Edit, here's the code I used to test it:


import math
import colorio
color_spaces = []

color_spaces.append(colorio.cs.XYZ(100))
color_spaces.append(colorio.cs.XYY(100))
#color_spaces.append(colorio.SrgbLinear()
#AttributeError: module 'colorio' has no attribute 'SrgbLinear'
color_spaces.append(colorio.cs.HSL())
color_spaces.append(colorio.cs.HSV())
color_spaces.append(colorio.cs.OsaUcs())
color_spaces.append(colorio.cs.CIELAB())
color_spaces.append(colorio.cs.CIELUV())
color_spaces.append(colorio.cs.RLAB())
color_spaces.append(colorio.cs.DIN99())
color_spaces.append(colorio.cs.ICtCp())
color_spaces.append(colorio.cs.IPT())

L_A = 64 / math.pi / 5
color_spaces.append(colorio.cs.CIECAM02(0.69, 20, L_A))
color_spaces.append(colorio.cs.CAM02("UCS", 0.69, 20, L_A))
color_spaces.append(colorio.cs.CAM16(0.69, 20, L_A))
color_spaces.append(colorio.cs.CAM16UCS(0.69, 20, L_A))

color_spaces.append(colorio.cs.JzAzBz())
color_spaces.append(colorio.cs.OKLAB())
color_spaces.append(colorio.cs.PROLAB())

for i in range(0,len(color_spaces)):
    try:
        p = colorio.plot_rgb_gamut(color_spaces[i], n=51, show_grid=True)
        p.show()
    except Exception as e:
        print(color_spaces[i])
        print(e)
nschloe commented 3 years ago

To reproduce the issue, I need a minimal working (or rather not-working) example (MWE). Please add the code, and make sure I can just copy and paste it to reproduce the error.

nschloe commented 3 years ago

Feel free to reopen with an MWE.