0
$\begingroup$

I have a few Mathematica notebooks that have Image3D volumetric images in them. If I try to print a hardcopy of the notebook, Mathematica freezes up (or, perhaps it isn't really frozen, but it takes so long attempting to process the document that it gives me the impression that the printing operation is not going to complete during my lifetime). I'm using Mathematica 10.0.2.0 on 64-bit Windows 7. It doesn't seem to matter if I am trying to print to a network printer or printing to PDF.

If I go through the document and manually delete all the Out[] cells containing Image3D objects, then the document prints just fine. But, of course, that's no help when I want the images to print.

Is there a fix or a better workaround available for this problem?

$\endgroup$
  • $\begingroup$ Have you tried to use Rasterize? $\endgroup$ – C. E. Jan 5 '15 at 23:53
  • 1
    $\begingroup$ Don't try to print directly from Mathematica. Instead, while in the notebook, go to File -> Save as... and then save the notebook as a .pdf file. Then print that file from your desktop. $\endgroup$ – David G. Stork Jan 5 '15 at 23:59
  • $\begingroup$ @Pickett Rasterize would likely be ok if I had only one or two Image3D panels that I wanted to save as figures for a paper, but unless there is an easy way to Rasterize a whole notebook all at once I don't see this as a suitable approach. $\endgroup$ – Matt Jan 6 '15 at 14:51
  • $\begingroup$ @DavidG.Stork I tried this last night. It has similar performance problems, but it does at least complete eventually. I computed the total processing time from the PDF file creation and modification timestamps: 37.4 minutes to process a 10-page document. So far, this seems like the best available option. $\endgroup$ – Matt Jan 6 '15 at 15:04
  • $\begingroup$ @Matt Does it take a long time to generate the images, or would it be feasible to reevaluate the notebook? $\endgroup$ – C. E. Jan 6 '15 at 15:14
3
$\begingroup$

The Villegas-Gayley pattern can be used to modify the definition of Image3D so that it outputs rasterized images. This won't help you if you have a bunch of images that you have already generated, but if you have the time to reevaluate the notebook this might be useful. It allows you to get rasterized images without having to change your code.

Unprotect[Image3D];
Image3D[args___] := Block[{$inMsg = True, result},
   Rasterize@Image3D[args]
   ] /; ! TrueQ[$inMsg]
Protect[Image3D];

You have to restart the kernel to get back the original definition of Image3D. Alternatively you can apply the Villegas-Gayley pattern again:

Unprotect[Image3D];
Image3D[args___] := Block[{$inMsg = True, result},
   Image3D[args]
   ] /; ! TrueQ[$inMsg]
Protect[Image3D];
$\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.