Message Boards Message Boards

GROUPS:

Mathematica crashes when displaying more than 5 images

Posted 8 years ago
4440 Views
|
2 Replies
|
0 Total Likes
|

This code causes Mathematica 10.2 on a Mac running OS 10.10.3 to crash. If i change the 30 to 5 if works just fine. If I put a semicolon after the damages import line it works ok. but displaying the 30 images causes a repeatable crash. I've got roughly 20GB of unused RAM available.

Any ideas as to why this is happening would be appreciated. Thanks!

SetDirectory["/Great Photos 2015"];
fnames = FileNames[];
shortfnames = Part[fnames, 1 ;; 30];
shortfnames = DeleteCases[shortfnames, x_ /; StringFreeQ[x, ".jpg"]];
shortfnames = 
  Map[(FileNameJoin[{"/Great Photos 2015/", #}]) &, shortfnames];
daimages = Map[Import, shortfnames];
dacontents = Map[ImageIdentify, daimages]
POSTED BY: trinko
2 Replies

Displaying that many large images in the notebook just isn't currently feasible. From what I understand the notebook represents and renders images in a pretty simple way. The kernel however is pretty capable of handling it.

Use semicolons like you have been doing. If you want to view an image, I would recommend resizing it before displaying it in the notebook:

https://reference.wolfram.com/language/ref/ImageResize.html

ImageResize[myImage, 500]

If you are going to be working with a lot of images, you might consider adding some code so that the outputs are automatically resized:

$Post  = Function[{output}, 
  ReplaceAll[output, 
   img_Image /; (Times @@ ImageDimensions@img > 640000) :> 
    ImageResize[img, 800]]]
POSTED BY: Sean Clarke
Posted 8 years ago

Thanks for the suggestion; it appears to work.

However when the image is shown on the page the size is minuscule so I don't see why resizing helps.

In any case I'm pretty surprised that a tool as mature as Mathematica totally dies when it runs into a memory shortage. Makes me wonder if Mathematica can produce erroneous results in low memory situations without letting me know about it.

POSTED BY: trinko
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract