Giter VIP home page Giter VIP logo

coloria's People

Contributors

nschloe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coloria's Issues

Luo-Rigg data no longer missing

The Data Readme states, under missing data,

M.R. Luo and B. Rigg, Chromaticity-discrimination ellipses for surface colours, Color Res. Appl. 11(1), 25-42 (1986).

bu there is a Luo-Rigg folder with that data. Or is this another dataset from the same paper?

Readme functions missing

Basic functions described in the project readme, such as

colorio.show_xy_gamut()

are missing.

Still issue #85

Hi again,

here python3 -m pip install https://github.com/nschloe/colorio/archive/master.zip
Building wheels for collected packages: colorio
Building wheel for colorio (PEP 517) ... done
Created wheel for colorio: filename=colorio-0.6.5-py3-none-any.whl size=136229 sha256=8c36713987a67955aaedc440cfa2ec585745eaaa9898d7ba080ac8de24ba0286
Stored in directory: /private/var/folders/nm/2psc68vd333ffgf21xp05t_40000gn/T/pip-ephem-wheel-cache-q05mo9m2/wheels/ad/9a/3b/ac10b724f443945bae92086cb643df4fa29d7cac7b4dd3ad38
Successfully built colorio
Installing collected packages: colorio
Successfully installed colorio-0.6.5

then simply try:

import colorio
colorspace = colorio.OKLAB()
colorspace.show_ebner_fairchild()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.9/site-packages/colorio/_color_space.py", line 467, in show_ebner_fairchild
self.plot_ebner_fairchild()
File "/usr/local/lib/python3.9/site-packages/colorio/_color_space.py", line 489, in plot_ebner_fairchild
_plot_color_constancy_data(d, wp, self)
File "/usr/local/lib/python3.9/site-packages/colorio/_color_space.py", line 605, in _plot_color_constancy_data
k0 = colorspace.k0
AttributeError: 'OKLAB' object has no attribute 'k0'

conversion between CAM16USC and sRBG1

I want to be able to convert from CAM16-UCS to sRGB1, and sRGB1 to CAM16-UCS. This doesn't look like this is directly supported (unless I am missing something?).

Colour Difference

Hey Nico, first of all, thank you for your work. Secondly, I am a designer who lacks experience with perceptual uniform colour models (although it seems like designers should, we are rarely trained on colour appearance models). So, please forgive me if this is a stupid question.

You have mentioned the colour difference formulas for CIE76, CIE94, CIEDE2000 and CMC l:c. here but not CAM16-UCS, is there a reason for that?

Could you tell me how I can find the colour difference for the CAM16-UCS model, and the difference in lightness J′, colourfulness M′ and hue h′?

Oklab normalisation (?)

okl.from_xyz100(colorio.illuminants.whitepoints_cie1931["D65"]) gives cbrt(100) times the expected result.

Indeed, the tests compare okl.from_xyz100(colorio.illuminants.whitepoints_cie1931["D65"] / 100) to the expected result of [1, 0, 0] instead.

Why the factor 100? Isn't that at odds with the XYZ100 in the function name?

Can't get the OKLAB functions to work

Not sure what I am doing wrong... Here are the results of a couple things I used in the console. I'm not sure what the "self" arguments it wants should be.

`colorio.cs.OKLAB.from_xyz100(xyz100 = [[1.0497487, 1.0803128, 0.1222619]])
Traceback (most recent call last):

File "", line 1, in
colorio.cs.OKLAB.from_xyz100(xyz100 = [[1.0497487, 1.0803128, 0.1222619]])

TypeError: from_xyz100() missing 1 required positional argument: 'self'

colorio.cs.OKLAB.from_xyz100(xyz100 = [1.0497487, 1.0803128, 0.1222619])
Traceback (most recent call last):

File "", line 1, in
colorio.cs.OKLAB.from_xyz100(xyz100 = [1.0497487, 1.0803128, 0.1222619])

TypeError: from_xyz100() missing 1 required positional argument: 'self'`

range of JzazBz coordinates

We have encountered the following issue, which has been reproduced using a few independent RGB --> JzAzBz implementations (including colorio and https://github.com/quag/JzAzBz/blob/master/python3/srgb255ToJzAzBz.py) ---

The JzAzBz paper (https://doi.org/10.1364/OE.25.015131) seems to suggest that the coordinates should span roughly Jz in (0,1), Az in (-0.5, 0.5), Bz in (-0.5,0.5). However, when we explicitly map all RGB tuples in (0,255) x (0,255) x (0,255) to JzAzBz as follows, we find that (Jz, Az, Bz) span (0,0.167), (-0.09,1.09), (-0.156,0.115).

So we're wondering if the original paper renormalized their coordinates, or if there's a mistake on our end.

Extremely simplified code that demonstrates the basic issue:

import numpy as np
import colorio

colorspace = colorio.SrgbLinear()
colorspace2 = colorio.JzAzBz()

jzazbz_test = np.zeros((256,256,256,3))
for i in range(0,255):
    for j in range(0,255):
        for k in range(0,255):
            jzazbz_test[i][j][k] = colorspace2.from_xyz100(colorspace.to_xyz100(colorspace.from_srgb1((i/255.,j/255.,k/255.))))

print('min Jz={}'.format(np.min(jzazbz_test[:,:,:,0])))
print('max Jz={}'.format(np.max(jzazbz_test[:,:,:,0])))

print('min Az={}'.format(np.min(jzazbz_test[:,:,:,1])))
print('max Az={}'.format(np.max(jzazbz_test[:,:,:,1])))

print('min Bz={}'.format(np.min(jzazbz_test[:,:,:,2])))
print('max Bz={}'.format(np.max(jzazbz_test[:,:,:,2])))

HSL and HSV lack conversion ability

The HSL and HSV colorspaces do not have from_xyz100(xyz) and to_xyz100(vals) methods defined on them and can therefore not be used in conversions. Was this intentional?

Classes Missing 'name' Attribute

Some classes (like CAM16) are missing a 'name' attribute. This raises an error when some functions (like the addition function defined in _color_coordinates.py) calls for the 'name' of an instance.

Images missing from README

Hello. The README currently has the following line:

The images below all show the SRGB gamut in the respective color space.

… but there are no images below this. Please add the images. (Are they the same under the gh-pages branch?)

SRGB gamut clipping

Hello, I don't know if this is a bug or expected, so forgive me if it's not.

I have this oklab value: array([0.56605844, 0.22076974, 0.10449413])

Turning into RGB gives me:

v = array([0.56605844, 0.22076974, 0.10449413])
oklab = colorio.cs.OKLAB()
oklab.to_rgb1(v)
# Out[8]: array([ 0.88944356, -0.17762959,  0.09417191])

Turning that into HSL gives me:

In [9]: hsl.from_rgb1(oklab.to_rgb1(v))
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-9-dabd72bc0ca3> in <module>
----> 1 hsl.from_rgb1(oklab.to_rgb1(v))

~/.local/lib/python3.9/site-packages/colorio/cs/_hsl.py in from_rgb1(self, srgb1)
      7         orig_shape = srgb.shape
      8         srgb = srgb.reshape(3, -1)
----> 9         assert not np.any(srgb < 0.0)
     10         assert not np.any(srgb > 1.0)
     11 

AssertionError: 

Is HSV colorspace shifted?

I'm trying to convert HSV to RGB:

import numpy as np
import colorio
cs = colorio.cs.HSV()
h = np.array(0)
s, v = np.ones_like(h), np.ones_like(h)
cs.to_srgb1((h, s, v))

# array([0., 1., 0.])

With h=0 I was expecting array([1., 0., 0.]). Thus the title question...

ICtCp: calculation of "m2" is wrong.

The calculation of the constant "m2" in _ictcp.py on line 20 is wrong:

It should be
self.m2 = 2523 / 4096 * 128

instead of
self.m2 = 2523 / 4096 / 128

Divide-by-zero & NaN in RGB to HSL/HSV conversion

>>> import colorio
>>> hsl = colorio.HSL().from_srgb1([1, 1, 1])
/home/user/.local/lib/python3.6/site-packages/colorio/_hsl.py:21: RuntimeWarning: invalid value encountered in true_divide
  H[i] = 60 * (0 + (srgb[1][i] - srgb[2][i]) / diff[i])
>>> hsl
array([nan, 0., 1.0])

Is this a feature or a bug? It's true that hue is undefined if R=G=B, so returning NaN kind of makes sense. On the other hand, if this is an intentional choice, the warning should be suppressed.

ColorCoordinates - get_rgb1("clip") replacement.

Hi Nico,

First wanted to say thanks for creating and maintaining colorio. I just came across it and I think it will be extremely useful as I write my thesis on extended gamut (7-color ink sets) color stability compared to the typical 4-color (CMYK) ink sets. I opened up the create-readme-plots.py to familiarize myself with some of your tools and I came across a couple of things I'm hoping you can clarify for me.

I'm looking at lines 149-165:

# observer
srgb = colorio.cs.SrgbLinear()
xyz100 = colorio.cs.XYZ100()

cols = [
    ColorCoordinates([30.0, 0.0, 0.0], xyz100).get_rgb1("clip"),
    ColorCoordinates([0.0, 30.0, 0.0], xyz100).get_rgb1("clip"),
    ColorCoordinates([0.0, 0.0, 30.0], xyz100).get_rgb1("clip"),
]
obs = colorio.observers.cie_1931_2()
plt.plot(obs.lmbda_nm, obs.data[0], color=cols[0], label="$\\overline{x}$")
plt.plot(obs.lmbda_nm, obs.data[1], color=cols[1], label="$\\overline{y}$")
plt.plot(obs.lmbda_nm, obs.data[2], color=cols[2], label="$\\overline{z}$")
plt.xlabel("wavelength [nm]")
plt.legend()
plt.savefig("cie-standard-observer-2.svg", transparent=True, bbox_inches="tight")
plt.show()

I believe the second line here should be srgb = colorio.cs.SRGBlinear() now. It looks like RGB is now capitalized and the L is now lowercase in the src/colorio/cs/_srgb.py (link to _srgb.py) Is that a correct assumption?

Now for my question. It looks like .get_rgb1() no longer exists in _color_coordinates.py (link to _color_coordinates.py). What should I be using here instead? If I look at the History of this file it looks like it once existed, but I can't figure out what I should be using instead now.

Thanks in advance!
Matt

Gamut plot with sRGB triangle

Hi, I previously used _tools.plot_flat_gamut to draw an (x, y) gamut with the monochromatic edge and sRGB triangle indicated. I see the latter feature was removed in commits de3c7fa and da26e54. It's not immediately obvious to me why this was removed, and whether it was removed outright or simply refactored. I can see that plot_xy_gamut now does everything except the sRGB triangle.

What steps should I take to recreate the sRGB triangle? Is there a different function for this now, which I have missed?

Missing commit history

As of March 18th, it appears that there's only one file in the repository and it's the ReadMe. The commit history also appears to have disappeared (only one commit). Was this intentional? Has this project moved to another location?

JaAzBz: reverse model is wrong (X′Y′Z_D₆₅🠞XYZ_D₆₅)

when trying to re-implement the model (typos) i couldn't get the reverse model to match input unless

y = (y_ + (self.g - 1) * x) / self.g

is changed to

y = ((z_ * self.b - z_ + x_) * self.g + (y_ - z_) * self.b + z_ - x_) / (self.b * self.g)

for example

XYZ_D65 = [0.4 0.5 0.6]
b = 1.15; g = 0.66
XʹYʹZ_D65 = [
    (b * XYZ_D65[:,1] - (b - 1) * XYZ_D65[:,3])
    g * XYZ_D65[:,2] - (g - 1) * XYZ_D65[:,1]
    XYZ_D65[:,3]
]

output XʹYʹZ_D65

3-element Array{Float64,1}:
 0.37               
 0.46599999999999997
 0.6       

as in paper

XYZ_D65 = [ #=  so that may become horizontal array
       =#    (XʹYʹZ_D65[1,:] + (b-1)*XʹYʹZ_D65[3,:])/b #=
       =#    (XʹYʹZ_D65[2,:] + (g-1)*XʹYʹZ_D65[1,:])/g #=
       =#    XʹYʹZ_D65[3,:]
]

output

1×3 Array{Float64,2}:
 0.4  0.515455  0.6

CAS version

XYZ_D65 = [ #=	so that may become horizontal array
       =#	(XʹYʹZ_D65[1,:] + (b-1)*XʹYʹZ_D65[3,:])/b #=
       =#	((XʹYʹZ_D65[3,:]*b - XʹYʹZ_D65[3,:] + XʹYʹZ_D65[1,:])*g + (XʹYʹZ_D65[2,:]-XʹYʹZ_D65[3,:])*b + XʹYʹZ_D65[3,:] - XʹYʹZ_D65[1,:])/(b*g) #=
       =#	XʹYʹZ_D65[3,:]
]
1×3 Array{Float64,2}:
 0.4  0.5  0.6

CAS

algsys([X′_D₆₅=X_D₆₅*𝑏-Z_D₆₅*(𝑏-1),Y′_D₆₅=Y_D₆₅*𝑔-X_D₆₅*(𝑔-1)],[X_D₆₅,Y_D₆₅]);

outputs

[X_D₆₅=(Z_D₆₅*𝑏-Z_D₆₅+X′_D₆₅)/𝑏,Y_D₆₅=(X′_D₆₅*(𝑔-1)+Z_D₆₅*(1-𝑔)+𝑏*(Z_D₆₅*(𝑔-1)+Y′_D₆₅))/(𝑏*𝑔)]

in their defense i didn't bother to manually solve this, used a program instead
also guess this is a example where subtle things (X′_D₆₅ based on Z_D₆₅ , vs , Y′_D₆₅ based on X_D₆₅) …

unable to install colorio

I am getting the following errors when I try to install colorio on windows and ubuntu.

ERROR: Could not find a version that satisfies the requirement colorio (from versions: none)
ERROR: No matching distribution found for colorio.

Is the project discontinued? Looking forward to your reply.

With many thanks,

Divide-by-zero in cs.HSL().from_rgb1()

There's a floating-point underflow/rounding error in RGB-to-HSL conversion:

>>> colorio.cs.HSL().from_rgb1([1e-17, 0, 0])
<string>:38: RuntimeWarning: divide by zero encountered in true_divide
array([0.e+00,    inf, 5.e-18])
>>> colorio.cs.HSL().from_rgb1([1e-16, 0, 0])
array([0.00000000e+00, 9.00719925e-01, 5.00000000e-17])

Probable cause: At float64 precision, (1.0 - 1e-17) == 1.0 is True, whereas (1.0 - 1e-16) == 1.0 is False.

Possible workaround: mask out not only zeros but also near-zeros before dividing.

Errors with plot_rgb_gamut()

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)

meshio output problems

The README says:

The data can be written in all formats supported by
[meshio](https://github.com/nschloe/meshio).

However, since it is not clear that all formats are immediately supported by just doing pip install colorio, I did some further testing:

#! /usr/bin/env python3

from meshio.helpers import _extension_to_filetype
extensions = tuple(_extension_to_filetype.keys())
dependenciesForExtensions = {}
extensionsWithOtherProblems = {}
extensionsWithoutProblems = []

import colorio
cielab = colorio.CIELAB()

for ext in extensions:
    try:
        colorio.show_srgb_gamut(cielab, "out" + ext)
    except ModuleNotFoundError as e:
        moduleName = str(e).split("'")[1]
        if moduleName not in dependenciesForExtensions:
            dependenciesForExtensions[moduleName] = []
        dependenciesForExtensions[moduleName].append(ext)
    except Exception as e:
        extensionsWithOtherProblems[ext] = str(e)
    else:
        extensionsWithoutProblems.append(ext)

print("\nExtensions without problems:\n{}".format(extensionsWithoutProblems))
print("\nExtensions with dependency problems:\n{}̣".format(dependenciesForExtensions))
print("\nExtensions with other problems:\n{}".format(extensionsWithOtherProblems))

and got the output:

WARNING:root:Writing MSH4.1 unimplemented, falling back on MSH2
WARNING:root:Binary Gmsh needs 32-bit integers (got int64). Converting.
WARNING:root:Dolfin's XML is a legacy format. Consider using XDMF instead.

Extensions without problems:
['.mesh', '.msh', '.post', '.post.gz', '.dato', '.dato.gz', '.vtk', '.inp']

Extensions with dependency problems:
{'netCDF4': ['.e', '.ex2', '.exo'], 'h5py': ['.med', '.h5m'], 'lxml': ['.xml', '.vtu', '.xdmf', '.xmf', '.svg']}̣

Extensions with other problems:
{'.off': 'Can only deal with triangular faces', '.stl': 'STL can only write triangle cells.', '.mdpa': 'must be str, not bytes'}

Even after installing the extra module dependencies, trying to use SVG for output format produces the error SVG can only handle flat 2D meshes (shape: (125000, 3))

Thus the above statement in the README requires change. Specifically it would seem that:

  1. the .off, .stl, .mdpa and .svg formats aren't feasible for use with colorio (but I may be wrong), and:
  2. some formats require certain dependencies which aren't pulled in by pip install colorio

So I suggest the following replacement wording:

The data can be written in most formats supported by
[meshio](https://github.com/nschloe/meshio) (with the exception of `.off`,
`.stl`, `.mdpa` and `.svg`). However, some formats may require packages
such as LXML to be installed in addition.

Asks for license

Hello,
Importing colorio in python now gives me a warning:

Warning: Unable to find valid license in
- environment variable COLORIO_LICENSE_KEY (env var not found), or
- config file .../colorio/colorio.toml (file not found)

Is this software not open source anymore?

ModuleNotFoundError 'meshzoo' on 0.6.5

Hi,

On fresh system the Meshzoo is not installed and not in dependency.

Here the output.

import colorio
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.9/site-packages/colorio/init.py", line 3, in
from ._cam16 import CAM16, CAM16UCS
File "/usr/local/lib/python3.9/site-packages/colorio/_cam16.py", line 3, in
from ._ciecam02 import compute_from, compute_to
File "/usr/local/lib/python3.9/site-packages/colorio/_ciecam02.py", line 3, in
from ._color_space import ColorSpace
File "/usr/local/lib/python3.9/site-packages/colorio/_color_space.py", line 11, in
from ._tools import get_mono_outline_xy, get_munsell_data, spectrum_to_xyz100
File "/usr/local/lib/python3.9/site-packages/colorio/_tools.py", line 5, in
import meshzoo
ModuleNotFoundError: No module named 'meshzoo'

support oklch

Could not find color space oklch. Try one of cam02lcd, cam02scd, cam02ucs, cam16ucs, cielab, cieluv, ciehcl, cielch, din99, din99b, din99c, din99d, hdrlinear, ictcp, igpgtg, ipt, jzazbz, oklab, osaucs, prolab, rlab, srgblinear, srgb1, srgb255, srgbhex, srlab2, xyy1, xyy100, xyz1, xyz100.
Please support oklch. This will be more perfect

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.