Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: ENVI header...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 5478 of 6454
Post > Topic >>

Re: ENVI header files in IDL

by Raghu <raghuram.narasimhan@[EMAIL PROTECTED] > Mar 10, 2008 at 07:30 PM

On Feb 27, 10:36=A0am, Jean H <jghas...@[EMAIL PROTECTED]
>
wrote:
> Raghu wrote:
> > Hi,
>
> > In IDL, i'm using filesearch function to read through files of certain
> > types.
> > Since an envi file has no specific extension, i'm not able to figure
> > out how to sort out the files.
> > Here's an example:
>
> > Say i have 2 images in ENVI format. It would look like IMAGE1,
> > IMAGE1.hdr,IMAGE2, IMAGE2.hdr.
> > As you can see, its only the header file which has the extension. When
> > i use the filesearch(image*), i am not
> > able to ignore the header files. These header files are not to be
> > processed.
>
> > Any ideas of how to choose only the images and not the header files,
> > as in this case ?
> > I guess i could convert the files to IMG so that they have an
> > extension, but there must be an easier way.
>
> > Thanks,
>
> > Raghu
>
> Hi,
> you can do a filesearch on the headers only
> filesToOpen =3D filesearch('image*.hdr') =A0 --> all that start with
'imag=
e'
> and ends with '.hdr')
> then remove the last 4 characters from the strings. Test if the file
> exists. If yes, open it. If not, try to add the common extensions (.dat,
> then .img etc). Of course, sort the order of the extensions (nothing,
> .dat etc) so that most images to process have the first extension (or
> lack of extension).
>
> here is a slightly different code that I use. The user select a file. If
> there is no extension in that file, it is open. Otherwise, the code
> looks for the file with the possible extensions.
>
> =A0 =A0 =A0 =A0 fileToOpen =3D dialog_pickFile(path =3D searchFolder,
GET_=
PATH =3D
> searchFolder, /must_exist, title =3D title)
>
> =A0 =A0 =A0 =A0 ;If the user selected a .hdr, remove the extension and
fin=
d the correct
> one.
> =A0 =A0 =A0 =A0 if (STRLOWCASE(strmid(fileToOpen,3, /REVERSE_OFFSET)) eq
'=
..hdr') or
> (STRLOWCASE(strmid(fileToOpen,3, /REVERSE_OFFSET)) eq '.aux') then begin
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fileToOpen=3D strmid(fileToOpen,
0,strlen(=
fileToOpen)-4)
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 extensionNotFound =3D 1B
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 currentExtension =3D 0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tmpFileToOpen =3D fileToOpen
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 commonExtensions =3D ['.dat','.img']
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while extensionNotFound and
currentExtensi=
on lt
> n_elements(commonExtensions) do begin
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if
FILE_TEST(tmpFileToOpen=
) eq 0 then begin
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
tmpFileToO=
pen =3D fileToOpen + commonExtensions[currentExtension]
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
currentExt=
ension +=3D1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 endif else begin
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
extensionN=
otFound =3D 0B
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
fileToOpen=
 =3D tmpFileToOpen
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 endelse
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 endwhile
>
> =A0 =A0 =A0 =A0 endif
>
> Jean- Hide quoted text -
>
> - Show quoted text -

Hi,

I got a very simple answer to my question from James Jones on the
ITTVIS usergroup.

Here it is:

images=3DFILE_SEARCH('*[^\.{hdr}]', /QUOTE)

In this case, the file_search function ignores the hdr files and reads
in only whats left.
Credit to James Jones for this.

Thanks,
Raghu
 




 6 Posts in Topic:
ENVI header files in IDL
Raghu <raghuram.narasi  2008-02-27 07:29:35 
Re: ENVI header files in IDL
David Fanning <news@[E  2008-02-27 08:39:11 
Re: ENVI header files in IDL
Bob Crawford <Snowman4  2008-02-27 09:29:07 
Re: ENVI header files in IDL
Jean H <jghasban@[EMAI  2008-02-27 10:36:33 
Re: ENVI header files in IDL
Raghu <raghuram.narasi  2008-03-10 19:30:59 
Re: ENVI header files in IDL
Jean H <jghasban@[EMAI  2008-03-11 09:16:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 13:56:15 CST 2008.