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

Home » Public Forums » archive » Interleaving separate arrays..
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Interleaving separate arrays.. [message #19774] Thu, 13 April 2000 00:00
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
Hmm, this talk about the interleaving of Leon Majewski's data reminded
me of a question that Ricardo Fonseca had quite a while ago.. It was
about converting an 8-bit image into a 24-bit image plus an alpha
channel, interleaving the colors in the first dimension.

Struan Gray suggested using the
[red(image),green(image),blue(image),alphachan] method, then reform &
transpose. (He also pointed out that this was often not necessary,
though, since the INTERLEAVE/TRUE keywords can be used in many cases
to indicate which dimension is interleaved)

I wrote a reply to this, but as I've recently learned, it never made
it outside Goddard Space Flight Center.. Now, here a short summary,
sent from my old account in Oslo..:

There are constructs in IDL to concatenate arrays by expanding the
first dimension, expanding the second dimension etc.. as well as
adding a dimension at the "end" (using more and more [] brackets in
the array concatenation statements, respectively), but no syntactic
construct to interleave pixels in a new dimension *before* the
existing ones...

Re-shoveling arrays after building them is not my preferred mode of
operation, because of the inherent performance hit. Better to do it
right in the first place - but how to avoid loops? Is a DLM the
answer? Well, so I thought, until it dawned on me (5 minutes ago) that
Ricardo's original problem can be solved like this:

s = size(image)
image = reform(image,1,s[1],s[2],/overwrite)
alphachan = replicate(128b,1,s[1],s[2])
alphaimage = [red[image],green[image],blue[image],alphachan]

Presto.. Though I shrink in my chair admitting that I actually wrote a
DLM to do this (as in result = interleave(a,b,c,d,e,f,.....)). It
didn't take much time, though, and I did it to test my sanity after
keeping away from IDL for too long.. Guess I only came halfway through
the test :-)

My only consolation is that nobody else got it...

Stein Vidar
[Message index]
 
Read Message
Previous Topic: DICOM_READ fails (?!)
Next Topic: Compiling shared libraries for use with call_external on a Mac

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

Current Time: Fri Oct 10 10:58:45 PDT 2025

Total time taken to generate the page: 0.48043 seconds