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

Home » Public Forums » archive » Re: Integer Array into Binary Array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Integer Array into Binary Array [message #67024 is a reply to message #67023] Thu, 25 June 2009 10:48 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Jun 25, 6:32 pm, Vikram <vikramivat...@gmail.com> wrote:
> On Jun 25, 1:16 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>> Vikram writes:
>>> I have made use of Dr. Fanning's BINARY.PRO and I have written
>>> something:
>
>>> img = read_tiff('Resol_Test2C.tiff')
>
>>> target = lonarr(4,1280,1024)
>
>>> bin = where(img gt 0.0)
>>> num = n_elements(bin)
>>> target[bin] = img[bin]
>
>>> num = n_elements(target)
>
>>> output = lonarr(4,5,5)
>
>>> test = [343,494]
>
>>> for x=0, n_elements(test)-1  do begin
>>>    output[x] = binary(test[x],/color)
>>> endfor
>
>>> ---------
>>> But if I do a print,output I can only get the binary for the 494, not
>>> both 343 and 494 in the same array. Any ideas?
>
>> BINARY produces string output. Maybe you want this:
>
>> IDL> test = [343,494]
>> IDL> print, test, format='(b24)'
>>                101010111
>>                111101110
>
>> Cheers,
>
>> David
>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> Ok, that makes sense. Is there a way of saving this binary into an
> array? Or is the only way just printing it to the screen?
>
> Thanks,
> Vikram

Hi Vikram,

just use the 'string' function.

a=indgen(12)
b=string(a,format='(b024)')
print,transpose(b)

Have a look at the helpfile on format codes. I know I have to read it
again every time I want to figure out which format code I need *this*
time! :-)

Cheers,
Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Integer Array into Binary Array
Next Topic: Saving XYOUTS

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

Current Time: Thu Oct 09 08:29:27 PDT 2025

Total time taken to generate the page: 0.95362 seconds