MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

How to specify the data-range with Import

  • To: mathgroup at
  • Subject: [mg122805] How to specify the data-range with Import
  • From: Patrick Scheibe <pscheibe at>
  • Date: Fri, 11 Nov 2011 04:53:38 -0500 (EST)
  • Delivered-to:


following (old) example of a multi-image

img = ColorConvert[ExampleData[{"TestImage", "Lena"}], "Grayscale"];
Export["lena_multi.tif", Table[img, {10}], "TIFF"];

With Import one can now specify that only the "Data" of the first 3
images are required:

In[45]:= Import["lena_multi.tif", {"Data", {1, 2, 3}}] // Dimensions

Out[45]= {3, 512, 512}

works like a charm. But trying to import 50 of say 1000 images is
slightly cumbersome this way. And now the fun starts:

Import["lena_multi.tif", {"Data", Range[3]}] // Dimensions


Import::noelem: The Import element "FrameNum" is not present when
importing as TIFF. >>

maybe Import has some Hold attribute (which it *doesn't*)

Import["lena_multi.tif", Evaluate[{"Data", Range[3]}]] // Dimensions

doesn't work

With[{range = Range[3]},
 Import["lena_multi.tif", {"Data", range}] // Dimensions

doesn't work. And so on and so on.. Luckily, we this very intuitive

In[50]:= Release[
  Hold[Import["tmp/lena_multi.tif", {"Data", range}]] /. 
   range -> Range[3]] // Dimensions

Out[50]= {3, 512, 512}

Please, could someone enlighten me?


PS: My system here is Linux-x86-64 with Ubuntu 10.04 and Mathematica 8.0.4

  • Prev by Date: Re: Keeping track of variables used in Mathematica
  • Next by Date: Re: nested findroot
  • Previous by thread: Re: FindRoot with algebraic expressions
  • Next by thread: Re: How to specify the data-range with Import