A very long time ago I used Mathematica for a few months and found it very intuitive. Now for my work I use MATLAB. I was just trying some stuff out with Mathematica again and there is something I cannot quite get the hang of.

I import a stack of images. Then I want to know the dimensions of my stack, but when I use Length or Dimensions, it only lists the number of images. Also when I use ? it not only shows me information, but it also plots every single "image" in it, which takes very long.

My question here is how to get the image size(s) for the imported stack of images?

  • $\begingroup$ An example (test file) illustrative of your set of images would be helpful. Also see ref/format/DICOM $\endgroup$ – rm -rf Sep 21 '13 at 18:34
  • 1
    $\begingroup$ Hmm first I didnt understand what you meant by ref/format/DICOM and googling it even took me to MatLab for some reason. But now that I found this link its really useful. You want me to show some images here? $\endgroup$ – Leo Sep 21 '13 at 19:14
  • $\begingroup$ @rm-rf Thanks for your help. I added examples to the question. I cant upload actual files as its sensitive data. $\endgroup$ – Leo Sep 21 '13 at 19:35
  • $\begingroup$ Yes, the link that you found is the one that I was referring to. If you just pasted what I wrote in Mathematica's documentation, it would've given you the same page. Thanks for the example :) $\endgroup$ – rm -rf Sep 21 '13 at 19:54
  • $\begingroup$ Your question really is broad. Could you possibly narrow it down to fit the title? $\endgroup$ – Yves Klett Sep 21 '13 at 20:22

You can use ImageDimensions for this purpose (in this case for a multi-frame DICOM):

imagestack = 



ImageDimensions /@ imagestack

(* 16 *)

(* {{256, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 

  256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 

  256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}, {256, 256}} *)


Mathematica graphics

| improve this answer | |
  • $\begingroup$ While the above is probably the most practical approach (+1), it might be worth noting that the dimensions are available in the "MetaInformation", at least for the example file: {"FrameCount", "Rows", "Columns"} /. Import["http://www.barre.nom.fr/medical/samples/files/MR-MONO2-8-16x-heart.gz", "MetaInformation"] --> {16, 256, 256}. $\endgroup$ – Michael E2 Sep 22 '13 at 18:15
  • $\begingroup$ @MichaelE2 please do post another answer, that is very useful information. $\endgroup$ – Yves Klett Sep 22 '13 at 19:41

One can get information about the images in a file from the metadata, provided it is there in the first place.

For example, in Yves Klett's example file, the "MetaInformation" contains information about "FrameCount", "Rows", and "Columns". These can be obtained as follows:

{"FrameCount", "Rows", "Columns"} /.
(* {16, 256, 256} *)

One can get the image dimensions of the frames from the element "ImageSize", too:

(* {256, 256} *)
| improve this answer | |

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.