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

Home » Public Forums » archive » merging bands
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
merging bands [message #76521] Fri, 17 June 2011 07:33 Go to next message
beardown911 is currently offline  beardown911
Messages: 21
Registered: March 2007
Junior Member
Dear all,

I'd like to merge three individual band into one single image file.
Thing is that there are hundreds of single band files and how to find
and identify to make three band composite.

Each band is 16-bit unsigned tif format image file with 1392x1040
array size.

Folder contains hundreds of files.
File name has sequence id in number and band id.
Here is an example of a file name; 4_10_R.tif.
First two number is a sequence ID and R stands for spectral band.
So, green band has G and NIR band has N letter in the file name.

But the sequence id is not in order. Sometimes it skips.

How to pick three matching individual band and composite to a singe
three band stacked image?

Any tip would be appreciated.

Thank you,
Kim
Re: merging bands [message #76631 is a reply to message #76521] Mon, 20 June 2011 16:48 Go to previous message
Konstantinos is currently offline  Konstantinos
Messages: 29
Registered: April 2011
Junior Member
Kim,

Glad to be able to help you.

Any time,Thats wgy this forum is for.

Kostas
Re: merging bands [message #76644 is a reply to message #76521] Mon, 20 June 2011 07:52 Go to previous message
beardown911 is currently offline  beardown911
Messages: 21
Registered: March 2007
Junior Member
On Jun 18, 7:08 am, Konstantinos <moonlightsha...@hotmail.gr> wrote:
> If i understand well what you want i ll try t assist you
>
> PRO merge_files_forum
>     CD, 'c:\.........' ;full path of the directory you have your files
>     list_of_files_R=FILE_SEARCH('*R.tiff')
>     list_of_files_G=FILE_SEARCH('*G.tiff')
>     list_of_files_B=FILE_SEARCH('*B.tiff')
>     number_of_files=N_ELEMENTS(list_of_files_R)
>     image=MAKE_ARRAY(3, 1932, 1040)
>
>     FOR i=0, number_of_files-1 DO BEGIN
>          image_R=READ_TIFF(list_of_files_R[i])
>          image_G=READ_TIFF(list_of_files_G[i])
>          image_B=READ_TIFF(list_of_files_B[i])
>          image[0,*,*]=image_R[*,*]
>          image[1,*,*]=image_G[*,*]
>          image[2,*,*]=image_B[*,*]
>          ;YOU CAN GIVE ANY FILENAME YOU WANT JUST GIVING YOU THIS FOR
> EXAMPLE
>          filename=STRING(i)+'.tiff'
>          WRITE_TIFF, filename, image
>    ENDFOR
> END
>
> I think that this piece of code should work for you.
> I know that this code IS NOT WRITTEN THE BEST WAY, and it is also very
> BAD AND PRIMITIVE IDL WRITING
>
> kostas

Hi Kostas,

Thank you so much for your code.
It worked. I just modified the writing tiff part using file "basename"
function.

Thanks again and have a nice day,
Kim
Re: merging bands [message #76656 is a reply to message #76521] Sat, 18 June 2011 05:08 Go to previous message
Konstantinos is currently offline  Konstantinos
Messages: 29
Registered: April 2011
Junior Member
If i understand well what you want i ll try t assist you

PRO merge_files_forum
CD, 'c:\.........' ;full path of the directory you have your files
list_of_files_R=FILE_SEARCH('*R.tiff')
list_of_files_G=FILE_SEARCH('*G.tiff')
list_of_files_B=FILE_SEARCH('*B.tiff')
number_of_files=N_ELEMENTS(list_of_files_R)
image=MAKE_ARRAY(3, 1932, 1040)

FOR i=0, number_of_files-1 DO BEGIN
image_R=READ_TIFF(list_of_files_R[i])
image_G=READ_TIFF(list_of_files_G[i])
image_B=READ_TIFF(list_of_files_B[i])
image[0,*,*]=image_R[*,*]
image[1,*,*]=image_G[*,*]
image[2,*,*]=image_B[*,*]
;YOU CAN GIVE ANY FILENAME YOU WANT JUST GIVING YOU THIS FOR
EXAMPLE
filename=STRING(i)+'.tiff'
WRITE_TIFF, filename, image
ENDFOR
END

I think that this piece of code should work for you.
I know that this code IS NOT WRITTEN THE BEST WAY, and it is also very
BAD AND PRIMITIVE IDL WRITING

kostas
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Invoking functions by name
Next Topic: Re: Histoplot - yaxis range

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

Current Time: Wed Oct 08 15:14:13 PDT 2025

Total time taken to generate the page: 0.00500 seconds