2
$\begingroup$

I have a 3d image data PlotData1, and I want to plot the Image3D with color. I tried this (Note: I don't have Plot1 in my actual case. I only have PlotData1):-

Plot1 = Import["ExampleData/CTengine.tiff", "Image3D"];
PlotData1 = ImageData@Plot1;
PlotData1Filtered = PlotData1 /. x_ /; x < 0.2 -> 0;
PlotData1Normlalized = PlotData1Filtered/Max[Flatten@PlotData1Filtered]; 
Image3D[PlotData1Normlalized, ColorFunction -> "Hue"]

But I just have the grayscale 3D without color. But I need color based on the different intensity of the pixels (i.e. voxels).

enter image description here

I also tried Image3D[PlotData1Normlalized, ColorFunction -> Function[{x, y, z, intensity}, Hue[intensity]]], but it doesn't work. What can I do?

Thanks!

$\endgroup$
0

1 Answer 1

3
$\begingroup$

The intensity is the first argument given to the color function, so you got the arguments wrong. We also need to make the background transparent. Here is an example:

Image3D[PlotData1Normlalized, ColorFunction -> (If[
     # == 0,
     Transparent,
     Hue[#, 1, 1, 0.1]
     ] &)]

Mathematica graphics

The 0.1 is the opacity. If you don't want to use opacity, you can simply use Hue[#].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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