plotting – How do I reflect changes to the intensity values in the 3D Shepp Logan data visualization?


The colors are not determined by the intensity but rather by the position of the function in the list of functions given as an argument to ParametricPlot3D. To make the colors correspond to the intensity(last column) use the option PlotStyle

Clear("Global`*")

rotz(Ω_) := {{Cos(Ω), -Sin(Ω), 
   0}, {Sin(Ω), Cos(Ω), 0}, {0, 0, 1}}
rotx(Ω_) := {{1, 0, 0}, {0, 
   Cos(Ω), -Sin(Ω)}, {0, Sin(Ω), 
   Cos(Ω)}}
roty(Ω_) := {{Cos(Ω), 0, 
   Sin(Ω)}, {0, 1, 0}, {-Sin(Ω), 0, 
   Cos(Ω)}}

Note that Ellipsoid is the name of a built-in function. User-defined functions should start with lower case letters to avoid naming conflicts with built-in names (now or in the future).

ellipsoid({x0_, y0_, z0_, a_, b_, c_, ϕ_, θ_, ψ_, ρ_})( 
  tt_, pp_) := (rotz(ϕ).roty(θ).rotz(ψ)).{a Sin(tt) Cos(pp), 
    b Sin(tt) Sin(pp), c Cos(tt)} + {x0, y0, z0}

(*   x0, y0, z0, a, b, c, ϕ, θ, ψ, ρ  *)
ellipsoids =
  {{0, 0, 0, 0.69, 0.92, 0.9, 0, 0, 0, 2.0},
   {0, 0, 0, 0.6624, 0.874, 0.88, 0, 0, 0, -0.8},
   {-0.22, 0.0, -0.25, 0.41, 0.16, 0.21, 3/5 Pi, 0, 0, -0.2},
   {0.22, 0.0, -0.25, 0.31, 0.11, 0.22, 2/5 Pi, 0, 0, -0.2},
   {0, 0.35, -0.25, 0.21, 0.25, 0.5, 0, 0, 0, 0.2},
   {0, 0.1, -0.25, 0.0460, 0.0460, 0.0460, 0, 0, 0, 0.2},
   {-0.08, -0.65, -0.25, 0.0460, 0.023, 0.02, 0, 0, 0, 0.1},
   {0.06, -0.65, -0.25, 0.0460, 0.023, 0.02, 0, 0, 0, 0.1},
   {0.06, -0.105, 0.625, 0.0560, 0.040, 0.1, Pi/2, 0, 0, 0.2},
   {0.0, 0.1, 0.625, 0.0560, 0.056, 0.1, Pi/2, 0, 0, -0.2}};

The range of intensities is

{minInt, maxInt} = MinMax(ellipsoids((All, -1)))

(* {-0.8, 2.} *)

colorGradient = "LightTemperatureMap"; 

Select color gradient from Color Schemes

g1 = ParametricPlot3D(
   ellipsoid(#)(tt, pp) & /@ ellipsoids((3 ;; 10)) // Evaluate,
   {tt, 0, Pi}, {pp, 0, 2 Pi},
   Boxed -> False,
   PlotPoints -> 50,
   ViewPoint -> {0.25, -1.15, 0.75},
   Axes -> False,
   ImageSize -> 550,
   PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}},
   Mesh -> False,
   PlotStyle -> (ColorData(colorGradient)(
        Rescale(#, {minInt, maxInt})) & /@ ellipsoids((3 ;; 10, -1))));

g2 = ParametricPlot3D(
   ellipsoid(#)(tt, pp) & /@ ellipsoids((1 ;; 2)) // Evaluate,
   {tt, Pi/2 + Pi/32, Pi}, {pp, 0, 2 Pi},
   Boxed -> False,
   PlotPoints -> 50,
   ViewPoint -> {0.25, -1.15, 0.75},
   AspectRatio -> Automatic,
   Axes -> False, Mesh -> False,
   ImageSize -> 550,
   PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}},
   PlotStyle -> (ColorData(colorGradient)(
        Rescale(#, {minInt, maxInt})) & /@ ellipsoids((1 ;; 2, -1))));

Show(g1, g2)

enter image description here

However, changing the intensities won’t change the colors if the relative intensities remain the same. The intensities used in the PlotStyle are scaled to the range {0, 1} for any range of intensities.