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

Home » Public Forums » archive » Re: 4-bit words
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: 4-bit words [message #5421 is a reply to message #5411] Thu, 21 December 1995 00:00 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <DJw3nF.D8n@rockyd.rockefeller.edu>, orbach@rockvax.rockefeller.edu (Darren Orbach) writes:
> I have a file that consists of a 256*256 array of 4-bit
> words created in another application, written as a binary
> file. I need to manipulate this array by shifting these
> 4-bit elements to the right by various amounts, and wrapping
> around to the other side of the array. However, since the
> smallest data type in WAVE or IDL is a full byte, I don't see
> a straightforward way to do this. Any suggestions?

I am assuming that your data files have the 4-bit values packed together. If so
then the following should create the array you want:

; Make a 1-D byte array big enough to hold image from disk
IDL> temp = bytarr(2L^15)
; Read in the data
IDL> readu, lun, temp
; Make new array to hold decomposed data
IDL> data = bytarr(2, 2L^15)
; Low order 4 bits in even elements
IDL> data(0,*) = (temp and '00FF'X)
; High order 4 bits in odd elements
IDL> data(1,*) = (temp/16 and '00FF'X)
; Reform into 256x256 array
IDL> data = reform(data, 256, 256)

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: roots of polynomial on a 2d grid
Next Topic: Anyone out there?

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

Current Time: Fri Oct 10 10:47:48 PDT 2025

Total time taken to generate the page: 0.24054 seconds