Skip to content

Commit

Permalink
Handle singularities in colour_visuals.VisualRGBColourspace2D class.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed May 18, 2024
1 parent b0d076d commit 9a99a48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions colour_visuals/rgb_colourspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,12 @@ def update(self):

XYZ_to_ij = METHODS_CHROMATICITY_DIAGRAM[self._method]["XYZ_to_ij"]

primaries = self._colourspace.primaries

primaries[primaries == 0] = EPSILON

ij = XYZ_to_ij(
xy_to_XYZ(self._colourspace.primaries + EPSILON),
xy_to_XYZ(primaries),
plotting_colourspace.whitepoint,
)

Expand All @@ -180,9 +184,7 @@ def update(self):
)

if self._colour is None:
RGB = XYZ_to_RGB(
xy_to_XYZ(self._colourspace.primaries), plotting_colourspace
)
RGB = XYZ_to_RGB(xy_to_XYZ(primaries), plotting_colourspace)
colour_g = np.array([RGB[0], RGB[1], RGB[1], RGB[2], RGB[2], RGB[0]])
else:
colour_g = np.tile(self._colour, (positions.shape[0], 1))
Expand Down

0 comments on commit 9a99a48

Please sign in to comment.