Importing a 900 MB tif file (~1800 frames) in Python takes ~9 seconds. The same file takes ~50 seconds to import in Mathematica. If the file size is ~150 MB then for Python takes ~2.5 s while MMA import it in 6 s. If I use Import[myfile, "Data"] then for the 900 MB image it takes ~100 s. Does anybody know why it is slower in MMA to import tif files. I use version 11.3.

I found two other questions going back to 6 years ago! How can I fix this problem?

Question 1

Question 2

  • 1
    $\begingroup$ Sometimes Import's extensive format and input checking may slow it down. Since you know what you want, you may be able to bypass all that and go straight to the raw importer function, which should be Image`ImportExportDump`ImageReadTIFF. Try e.g. Image`ImportExportDump`ImageReadTIFF["yourFileName.TIFF"] and see if it's any faster. $\endgroup$ – MarcoB Jun 10 '20 at 15:55
  • 2
    $\begingroup$ "Does anybody know why it is slower in MMA to import tif files." The answer is obvious: So far, nobody at WRI has bothered to link an efficient library for this. And maybe the FrontEnd is also not helpful. But IIRC, the avi or mp4 import routines have been improved recently. So you could try to use ffmpeg to convert the tiff into a video format that Mathematica is better at importing. However, ffmpeg is waaaay better suited for all tasks related to videos. So I would suggest use that in the first place. $\endgroup$ – Henrik Schumacher Jun 10 '20 at 15:55
  • $\begingroup$ @MarcoB Thanks for your suggestion. With the method you mentioned it takes to import the 900 MB file in ~40 seconds. Still it is four times slower than Python. $\endgroup$ – MOON Jun 13 '20 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.