# Get information about a stack of images, without plotting it

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?

-
An example (test file) illustrative of your set of images would be helpful. Also see ref/format/DICOM – R. M. Sep 21 '13 at 18:34
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? – Leo Sep 21 '13 at 19:14
@rm-rf Thanks for your help. I added examples to the question. I cant upload actual files as its sensitive data. – Leo Sep 21 '13 at 19:35
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 :) – R. M. Sep 21 '13 at 19:54
Your question really is broad. Could you possibly narrow it down to fit the title? – Yves Klett Sep 21 '13 at 20:22

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

imagestack =

Import["http://www.barre.nom.fr/medical/samples/files/MR-MONO2-8-\16x-heart.gz"];

Length[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}} *)

ListAnimate[img]


-
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}. – Michael E2 Sep 22 '13 at 18:15
@MichaelE2 please do post another answer, that is very useful information. – 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"} /.
Import["http://www.barre.nom.fr/medical/samples/files/MR-MONO2-8-16x-heart.gz",
"MetaInformation"]
(* {16, 256, 256} *)


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

Import["http://www.barre.nom.fr/medical/samples/files/MR-MONO2-8-16x-heart.gz",
"ImageSize"]
(* {256, 256} *)

-