3

I like to have images in between code and text cells. Whether they are pasted (in a default Input cell) or generated (in an Output cell), they slow down the front end considerably. When part of an image is visible, scrolling is noticeably choppy; as soon as it goes out of view, scrolling is fast.

If the notebook is exported as a PDF, a PDF reader renders the document quickly; presumably it loads all assets in memory so that there is no compute cost for showing images or rendered text. I want similar behavior in a notebook.

Question

How can I save an image in a notebook that doesn't slow down the front end?
  • Is there a magic set of cell options (I tried fiddling with editable/evaluatable)?
  • Are there cell types that don't let their contents be unloaded from memory?
  • Does a plain Image do continual processing that leads to sluggishness?
  • Is there a different Head or wrapper for Image that is more 'passive'?

Here's a weird way of viewing memory over time; it sort of supports the idea that the images are unloaded (though that's not really the main issue). The plot itself contributes to memory, so it's a pretty bad way of measuring.

i = 1;l = 1 + 0 Range@400;
Dynamic[Refresh[
  l[[i]] = MemoryInUse@$FrontEnd;
  i = 1 + Mod[i, Length@l]; 
  ListLinePlot[Log10@l, PlotRange -> {8, 10}],
UpdateInterval -> .1]]

I'm on 12.1.1 on OSX. I'll post a video of the choppiness in a couple hours.

Adam
  • 3,937
  • 6
  • 22
  • This question https://mathematica.stackexchange.com/questions/127523/ui-performance-with-large-image-data is not relevant; my question concerns static images. Even the sped up answer is choppy on my system. – Adam May 27 '23 at 23:31
  • I don't know how to test any ideas. This might work, but it seems cumbersome: Iconize[e, Rasterize[e]]. Could be done automatically through $PrePrint I suppose. – Michael E2 May 28 '23 at 00:00
  • After two years in vs 11 and 13 trying to use the nice Mathematica environment for complex ancient photo restauration I gave up. In Windows 10 the ffmpeg engine seems to be involved. Images slow down the interaction with the GUI kernel. BW images converted to Grayscale work wrapped as images, color images or full rasters of some MP simply dont work. On Linux the graphics subsystem seems to be better implemented and faster. Your example just worked when the notebook shut down occured. To get it reanimated was a little adventure. There was a question window hidden behind the notebook window. – Roland F May 28 '23 at 07:26
  • 1
    I recall there being a performance issue with large (much larger than the results from Rasterize[Plot[]]) images in the 12.x series. The only "workaround" is to avoid them. – ihojnicki May 28 '23 at 12:51
  • 1
    @RolandF, I'm surprised to hear you say that. The 13 Windows FrontEnd uses DirectX, so I would double check to make sure your graphics card driver is up to date and fully functional. – ihojnicki May 28 '23 at 12:53
  • 1
    Thats all checked. Its a notebook with intel UHD plus an NVIDIA MX150. Since I never get activity of the NVIDIA I switched off the Intel. No difference. After some search I concluded that the real capabilities of the graphics card are used only by special software. games of course. The Windows Dircect X is abstinent. For the ffmpeg engine to use the card it has to be loaded with CUDA switch on. This is not the case for the Intel machines for the Windows 10 photo and video environment. So I decided to build an AMD system for grandson who complained about miserable perfomance of notebook. – Roland F May 30 '23 at 04:31

0 Answers0