comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Loading Sorted Images into a 3D array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Loading Sorted Images into a 3D array [message #77041] Mon, 25 July 2011 01:20
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
On 21/07/11 18:21, Kenneth P. Bowman wrote:
> I am sure this can be done in IDL, but it seems to me that
> the simple solution is to rename your files ...001.png, ...002.png,
> etc. That will probably make things easier in other ways also.

Or, if the filenames are not under one's control, one could try to
parse them like this:


files = string( indgen(100), format='("asdf",i0)')
print, files
fileswrong = files[ sort( files)] ; sort lexically
print, fileswrong
nums = long( strmid( fileswrong, 4))
print, nums
filesrightagain = fileswrong[ sort( nums)]
print, filesrightagain



chl
Re: Loading Sorted Images into a 3D array [message #77050 is a reply to message #77041] Thu, 21 July 2011 19:17 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Jul 21, 12:57 pm, M R <manisha....@gmail.com> wrote:
> On Jul 21, 11:21 am, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
>
>
>
>
>
>
>
>
>
>> In article
>> < 4719e461-98c5-4792-851a-69e510229...@x10g2000vbl.googlegroup s.com >,
>>  M R <manisha....@gmail.com> wrote:
>
>>> I have a stack of 55 png images (256 X 256, 24-bit each). I am
>>> creating a 3D array and would like to load the images in an ascending
>>> order. But this is not happening since IDL is loading them
>>> 1,10,101,.....2,20,201....and so on. How so I use the SORT command for
>>> loading them in an order?
>
>>> file=file_search('filepath*.bmp',COUNT=count)
>
>>> arm=bytarr(256,256,count,/nozero)
>
>>> for i=0,count-1 do begin
>
>>>   image=read_image(file[i])
>
>>>   arm[*,*,i] = image
>
>>>   end
>>> end
>
>> I am sure this can be done in IDL, but it seems to me that
>> the simple solution is to rename your files ...001.png, ...002.png,
>> etc.  That will probably make things easier in other ways also.
>
>> Ken Bowman
>
> It worked! Thank you!

Or, sort the numbers in a numerical format (like integers) instead of
as strings.
Re: Loading Sorted Images into a 3D array [message #77055 is a reply to message #77050] Thu, 21 July 2011 09:57 Go to previous message
M R is currently offline  M R
Messages: 19
Registered: July 2011
Junior Member
On Jul 21, 11:21 am, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article
> < 4719e461-98c5-4792-851a-69e510229...@x10g2000vbl.googlegroup s.com >,
>  M R <manisha....@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>> I have a stack of 55 png images (256 X 256, 24-bit each). I am
>> creating a 3D array and would like to load the images in an ascending
>> order. But this is not happening since IDL is loading them
>> 1,10,101,.....2,20,201....and so on. How so I use the SORT command for
>> loading them in an order?
>
>> file=file_search('filepath*.bmp',COUNT=count)
>
>> arm=bytarr(256,256,count,/nozero)
>
>> for i=0,count-1 do begin
>
>>   image=read_image(file[i])
>
>>   arm[*,*,i] = image
>
>>   end
>> end
>
> I am sure this can be done in IDL, but it seems to me that
> the simple solution is to rename your files ...001.png, ...002.png,
> etc.  That will probably make things easier in other ways also.
>
> Ken Bowman

It worked! Thank you!
Re: Loading Sorted Images into a 3D array [message #77056 is a reply to message #77055] Thu, 21 July 2011 09:21 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<4719e461-98c5-4792-851a-69e510229f00@x10g2000vbl.googlegroups.com>,
M R <manisha.rkp@gmail.com> wrote:

> I have a stack of 55 png images (256 X 256, 24-bit each). I am
> creating a 3D array and would like to load the images in an ascending
> order. But this is not happening since IDL is loading them
> 1,10,101,.....2,20,201....and so on. How so I use the SORT command for
> loading them in an order?
>
> file=file_search('filepath*.bmp',COUNT=count)
>
> arm=bytarr(256,256,count,/nozero)
>
> for i=0,count-1 do begin
>
> image=read_image(file[i])
>
> arm[*,*,i] = image
>
> end
> end

I am sure this can be done in IDL, but it seems to me that
the simple solution is to rename your files ...001.png, ...002.png,
etc. That will probably make things easier in other ways also.

Ken Bowman
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: summation of bands
Next Topic: Confidence Bands

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:34:42 PDT 2025

Total time taken to generate the page: 0.00418 seconds