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

Home » Public Forums » archive » 8 bit binary images
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: 8 bit binary images [message #9617 is a reply to message #9548] Wed, 23 July 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Mike Black wrote:
>
> I've just written a Fortran 77 program that was supposed to generate
> a 8 bit binary data file for PV-Wave.
>
> The file format consists of 800 rows of 1000-character-long strings, each
> character in the string meaning to represent individual pixels in an image
> as you move from left to right.
>
> I used the CHAR command to write CHAR(0) for a 'white' pixel and
> CHAR(255) for a 'black' pixel. Each row consists of 1000 of these
> CHAR(0/255) characters concatenated together with no space in between > them.
> Does anyone have any suggestions, or an explicit description of the
> necessary format required to encode the 8-bit format?

I would suggest saving the image as a BYTARR(800,1000). You could
define the array as:

CHARACTER*1 ARRAY(800,1000)

in your fortran program, define the individual pixels and then save
the array using binary I/O:

OPEN(11, FILE=FNAME, FORM='BINARY')
WRITE(11) ARRAY
CLOSE(11)

Then read the array into IDL using:

ARRAY = BYTARR(800,1000)
OPENR, UNIT, FNAME, /GET_LUN
READU, ARRAY

If you try to write the 800 rows as strings in your Fortran program
then you are bound to run into problems with new-line characters
and the like.

Also, be aware that if you are using something like:

OPEN(11, FILE=FNAME, FORM='UNFORMATTED')

to write the file in the fortran program, then you must use the
/F77_UNFORMATTED keyword in your IDL OPENR() statement. I believe
that specifying FORM='BINARY' implies direct access and makes this
keyword unnecessary.

Hope this helps.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~

"I have this theory that if we're told we're bad,
then that's the only idea we'll ever have.
But maybe if we are surrounded in beauty,
someday we will become what we see." - Jewel Kilcher
[Message index]
 
Read Message
Read Message
Previous Topic: Object graphics bug?
Next Topic: FFT: How to select BW and frequency

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

Current Time: Fri Oct 10 13:27:50 PDT 2025

Total time taken to generate the page: 1.76008 seconds