2
$\begingroup$

Consider I have a set of 6 colors in LAB colorspace.

col={LABColor[0.5, 0.2, 0.4], LABColor[0.8,0.3,0.4],LABColor[0.3, -0.2, -0.4],
     LABColor[0.2, 0.5, 0.7],LABColor[0.9, -0.5, -0.6],LABColor[0.6,-0.7, 0.4]};

I want to plot these points using ChromaticityPlot3D.

ChromaticityPlot3D[cols, "LAB", PlotStyle -> PointSize[Medium]];

Now I wish to display a sphere on top of this with a transparency.

Show[ChromaticityPlot3D[cols, "LAB", PlotStyle -> PointSize[Medium]],
     Graphics3D[{Opacity[.8], Sphere[{0.5, 0., 0.}, 0.5]}]]

Here, I am getting a problem. Firstly, the sphere is too transparent even with opacity 0.8. Secondly, I want the sphere to be colored according to the colors of the color space i.e. the color at each position of the sphere will represent the corresponding color at that location in the "LAB" color space.

$\endgroup$
  • $\begingroup$ something like this? $\endgroup$ – Jason B. Nov 13 '17 at 18:44
  • $\begingroup$ yes (if the colors of the sphere represent the colors at the corresponding position in the LAB color space). $\endgroup$ – Majis Nov 13 '17 at 18:52
3
$\begingroup$

I have this:

Show[{ChromaticityPlot3D[cols, "LAB", PlotStyle -> PointSize[Medium]],
 ContourPlot3D[
 y^2 + z^2 + (x - 0.5)^2 == 0.25, {x, -1, 1}, {y, -1, 1}, {z, -1, 
1}, ColorFunction -> Function[{x, y, z}, LABColor[x, y, z]], 
ColorFunctionScaling -> False, Mesh -> False, Boxed -> True, 
Axes -> True, ContourStyle -> Directive[Opacity[0.5]]]}, 
BoxRatios -> {1/2.4, 1, 1}, ImageSize -> Large, 
SphericalRegion -> True]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Setting PlotPoints ->100 on the contour plot improves the result $\endgroup$ – Jason B. Nov 13 '17 at 19:23
  • $\begingroup$ Yes !, thnx @JasonB. The plot even looks better with PointSize[0.01] $\endgroup$ – José Antonio Díaz Navas Nov 13 '17 at 19:28
1
$\begingroup$

Alternatively, discretize a sphere for coloring purposes:

cols = {LABColor[0.5, 0.2, 0.4], LABColor[0.8, 0.3, 0.4], LABColor[0.3, -0.2, -0.4], 
        LABColor[0.2, 0.5, 0.7], LABColor[0.9, -0.5, -0.6], LABColor[0.6, -0.7, 0.4]};
sph = DiscretizeRegion[Sphere[{1/2, 0, 0}, 1/2], MaxCellMeasure -> {1 -> 0.05}];

Show[ChromaticityPlot3D[cols, "LAB", PlotStyle -> AbsolutePointSize[6]], 
     Graphics3D[With[{pts = MeshCoordinates[sph]}, 
                     GraphicsComplex[pts, {Directive[Opacity[0.8], EdgeForm[]],
                                           MeshCells[sph, 2]}, 
                                     VertexColors -> (LABColor @@@ pts)]]],
     BoxRatios -> Automatic]

CIELAB-colored sphere

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.