Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6494
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to specify the data-range with Import |
| Date | 2011-11-17 11:09 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <ja2q1k$mb3$1@smc.vnet.net> (permalink) |
| References | <201111110953.EAA08442@smc.vnet.net> |
Hi,
Jesus Hernandez and (maybe others) from the Wolfram support uncovered
the reason for this behavoir. The important detail here seems to be
whether or not the created list is a PackedArray. Since Range[5] gives a
packed array but Table[i,{i,5}] not, the following (from the example
below)
Import["lena_multi.tif", {"Data", Range[5]}] // Dimensions
does not work, while this here
Import["lena_multi.tif", {"Data", Table[i,{i,5}]}] // Dimensions
works as expected. Therefore, one has to use FromPackedArray from the
Developer package to use any arbitrarily created list of integers. For
instance
Needs["Developer`"]
Import["lena_multi.tif", {"Data",
FromPackedArray@Range[3]}] // Dimensions
Cheers
Patrick
On Fri, 2011-11-11 at 04:53 -0500, Patrick Scheibe wrote:
> Hi,
>
> 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
>
> gives
>
> 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
> construct
>
> 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?
>
> Cheers
> Patrick
>
> PS: My system here is Linux-x86-64 with Ubuntu 10.04 and Mathematica 8.0.4
>
>
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How to specify the data-range with Import Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-11-17 11:09 +0000
csiph-web