1
$\begingroup$

I have created a image3d from which I have rotated it to create a rotating view of the object. I want to be able to render each 'frame' to a 2d image so that I can export the frame sequence to create a video using Export. Can anyone help me please?

Many thanks in advance

Alan

$\endgroup$
3
  • $\begingroup$ Take a look at Rasterize $\endgroup$
    – paw
    Commented Feb 25, 2015 at 22:15
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Commented Feb 25, 2015 at 22:20
  • $\begingroup$ Would you please include an example of the code you are using to rotate the Image3D? $\endgroup$
    – Mr.Wizard
    Commented Feb 25, 2015 at 23:45

1 Answer 1

3
$\begingroup$

You can use Rasterize[plot,"Image"] on each frame as paw suggested.

img = Image3D[RandomReal[1, {5, 10, 10}]]

imageList = 
 Most@ParallelTable[
   Rasterize[
    Image3D[img, 
     ViewPoint -> {2.5 Cos[θ], 2.5 Sin[θ], 2}, 
     ViewAngle -> 30 Degree], "Image"], {θ, 0, 2 Pi, 0.01 Pi}];
ListAnimate[imageList]

Export["animation.avi", imageList];
Export["animation.gif", imageList];

However, Export already handles animations natively! (Although not for .gif sadly.)

animation = 
  Animate[Image3D[img, 
    ViewPoint -> {2.5 Cos[θ], 2.5 Sin[θ], 2}, 
    ViewAngle -> 30 Degree], {θ, 0, 2 Pi}]

Export["animation.avi", animation];
$\endgroup$
1
  • $\begingroup$ Thank you, the above code is exactly what I was after, I had been playing with Rasterize, but I hadn't quite hit the mark. $\endgroup$ Commented Feb 26, 2015 at 13:00

Your Answer

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

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