need the dimensions of an array [message #38748] |
Fri, 26 March 2004 05:13  |
Thomas Nehls
Messages: 24 Registered: March 2004
|
Junior Member |
|
|
Hi,
using read_tiff I Read an image into a variable lets say pixel
interleaved (channels, columns, rows)
now I need the number of columns and the number of rows
like that:
img = READ_TIFF(file)
num_col = ?(img[1])
num_rows= ?(img[2])
I tried SIZE(img,/Dimensions) which returns: 3, 385, 345
very nice! I need only the Number "385" and the "345" respectively
Do you understand what I want to say?
Thanks
Tom
|
|
|
Re: need the dimensions of an array [message #38796 is a reply to message #38748] |
Mon, 29 March 2004 09:32  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
<wmc@bas.ac.uk> wrote in message news:4067deaf@news.nwl.ac.uk...
> Thomas Nehls <thomas.nehls@tu-berlin.de> wrote:
>> Thank you very much for your help, unfortunately and because of the
Time
>> shifting between you and me, I needed to find a solution somehow and
now
>> this works:
>
>> col = LONG(N_ELEMENTS(img[0,*,0]))
>> row = LONG(N_ELEMENTS(img[0,0,*]))
>
> This is what I use, its easier than remembering how size works...
Do remember, though, that simply doing this subscripting can use up a
lot of time and memory:
http://www.dfanning.com/misc_tips/submemory.html
How about this:
col = (Size(img, /Dimensions))[1]
row = (Size(img, /Dimensions))[2]
Cheers,
--
-Dick
Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
|
|
|
Re: need the dimensions of an array [message #38802 is a reply to message #38748] |
Mon, 29 March 2004 01:30  |
wmconnolley
Messages: 106 Registered: November 2000
|
Senior Member |
|
|
Thomas Nehls <thomas.nehls@tu-berlin.de> wrote:
> Thank you very much for your help, unfortunately and because of the Time
> shifting between you and me, I needed to find a solution somehow and now
> this works:
> col = LONG(N_ELEMENTS(img[0,*,0]))
> row = LONG(N_ELEMENTS(img[0,0,*]))
This is what I use, its easier than remembering how size works...
-W.
--
William M Connolley | wmc@bas.ac.uk | http://www.antarctica.ac.uk/met/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
I'm a .signature virus! copy me into your .signature file & help me spread!
|
|
|
Re: need the dimensions of an array [message #38803 is a reply to message #38748] |
Sun, 28 March 2004 23:55  |
Thomas Nehls
Messages: 24 Registered: March 2004
|
Junior Member |
|
|
M. Katz wrote:
> Thomas Nehls <thomas.nehls@tu-berlin.de> wrote in message news:<c41a69$pvv$1@mamenchi.zrz.TU-Berlin.DE>...
>
>> Hi,
>>
>> using read_tiff I Read an image into a variable lets say pixel
>> interleaved (channels, columns, rows)
>>
>> now I need the number of columns and the number of rows
>>
>> like that:
>> img = READ_TIFF(file)
>> num_col = ?(img[1])
>> num_rows= ?(img[2])
>>
>> I tried SIZE(img,/Dimensions) which returns: 3, 385, 345
>> very nice! I need only the Number "385" and the "345" respectively
>> Do you understand what I want to say?
>> Thanks
>> Tom
>
>
> Since SIZE(img, /Dimensions) returns an array, you are looking to
> extract single values from the array. If you're always reading
> 3-dimensional arrays, you can do this
>
> s = SIZE(img, /Dimensions)
> width = s[1]
> height = s[2]
> depth = s[0].
>
> Or in one less step, treat the values returned by the SIZE function
> like this
> width = (SIZE(img, /Dimensions))[1]
> height = (SIZE(img, /Dimensions))[2]
> depth = (SIZE(img, /Dimensions))[0]
>
> You could also have a 2-element size array
> Nxy = (SIZE(img, /Dimensions))[1:2]
> and then access Nxy[0] for the width and Nxy[1] for the height.
>
> M. Katz
Thank you very much for your help, unfortunately and because of the Time
shifting between you and me, I needed to find a solution somehow and now
this works:
col = LONG(N_ELEMENTS(img[0,*,0]))
row = LONG(N_ELEMENTS(img[0,0,*]))
Bye
Tom
|
|
|
Re: need the dimensions of an array [message #38806 is a reply to message #38748] |
Sun, 28 March 2004 15:53  |
pissulla
Messages: 1 Registered: March 2004
|
Junior Member |
|
|
Thomas Nehls <thomas.nehls@tu-berlin.de> wrote in message news:<c41a69$pvv$1@mamenchi.zrz.TU-Berlin.DE>...
> Hi,
>
> using read_tiff I Read an image into a variable lets say pixel
> interleaved (channels, columns, rows)
>
> now I need the number of columns and the number of rows
>
> like that:
> img = READ_TIFF(file)
> num_col = ?(img[1])
> num_rows= ?(img[2])
>
> I tried SIZE(img,/Dimensions) which returns: 3, 385, 345
> very nice! I need only the Number "385" and the "345" respectively
> Do you understand what I want to say?
> Thanks
> Tom
Hi Tom,
I'm not sure if I understand your problem, but why don't you use
img = READ_TIFF(file)
info = SIZE(img,/DIMENSIONS)
num_col = info[1]
num_rows = info[2]
now num_col should have the value 385 and num_rows 345.
Cheers, Darius
|
|
|
Re: need the dimensions of an array [message #38807 is a reply to message #38748] |
Sun, 28 March 2004 15:30  |
MKatz843
Messages: 98 Registered: March 2002
|
Member |
|
|
Thomas Nehls <thomas.nehls@tu-berlin.de> wrote in message news:<c41a69$pvv$1@mamenchi.zrz.TU-Berlin.DE>...
> Hi,
>
> using read_tiff I Read an image into a variable lets say pixel
> interleaved (channels, columns, rows)
>
> now I need the number of columns and the number of rows
>
> like that:
> img = READ_TIFF(file)
> num_col = ?(img[1])
> num_rows= ?(img[2])
>
> I tried SIZE(img,/Dimensions) which returns: 3, 385, 345
> very nice! I need only the Number "385" and the "345" respectively
> Do you understand what I want to say?
> Thanks
> Tom
Since SIZE(img, /Dimensions) returns an array, you are looking to
extract single values from the array. If you're always reading
3-dimensional arrays, you can do this
s = SIZE(img, /Dimensions)
width = s[1]
height = s[2]
depth = s[0].
Or in one less step, treat the values returned by the SIZE function
like this
width = (SIZE(img, /Dimensions))[1]
height = (SIZE(img, /Dimensions))[2]
depth = (SIZE(img, /Dimensions))[0]
You could also have a 2-element size array
Nxy = (SIZE(img, /Dimensions))[1:2]
and then access Nxy[0] for the width and Nxy[1] for the height.
M. Katz
|
|
|