0
$\begingroup$

Suppose I have 2 (or more) Image3D graphics:

redCubes = Image3D[RandomInteger[1, {3, 3, 3}],
  ColorFunction -> (If[# == 1, Red, Transparent] &)]

enter image description here

greenCubes = Image3D[RandomInteger[1, {3, 3, 3}],
  ColorFunction -> (If[# == 1, Green, Transparent] &)]

enter image description here

How can I show them together, or make a new Image3D out of them? If I simply do Show[], the green/red cubes are kind of shadowed/dimmed, for instance:

Show[redCubes, greenCubes]

enter image description here

Importantly, how to deal with overlaps? I'd like to do some sort of color mix, say the overlaps colored in some red+green; although in my real application I can have more than 2 colors.

Edit: I'd really prefer to work within Image3D[] rather than Graphics3D[], but definitely open to different approaches.

Thanks!

$\endgroup$

2 Answers 2

2
$\begingroup$

The simple way to desired mix of im3d is following:

redCubes = RandomInteger[1, {3, 3, 3}]
greenCubes = RandomInteger[-1, {3, 3, 3}]

cbs = Evaluate@(redCubes + greenCubes) /. {1 -> Red,-1 -> Green,0 -> Transparent}

enter image description here

$\endgroup$
0
1
$\begingroup$

Use Graphics3Dfor your purpose. Then create some positions where you want to place red and green cubes:

datr = RandomInteger[{0, 5}, {50, 3}];
datg = RandomInteger[{0, 5}, {50, 3}];

Then determines the overlap and subtract the overlap:

overlap = Intersection[datr, datg];
datr0 = Complement[datr, overlap];
datg0 = Complement[datg, overlap];

Finally draw the cubes and give the overlap e.g. the color brown:

Graphics3D[{{Red, Cube[#, 1] & /@ datr0}, {Green, 
   Cube[#, 1] & /@ datg0}, {Brown, Cube[#, 1] & /@ overlap}}]

enter image description here

$\endgroup$
0

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.