Skip to content

reading binary file

2 messages · yudi@ucd.ie, Rob Dunne

#
Accidentally this only came to me (MM).

------- start of forwarded message (RFC 934 encapsulation) -------
Actually I'm trying to read ppm image files that have a mixture of
ASCII characters (describing the content of a file) and binary values. 
Splus can do this. Maybe I have to write a C subroutine?

 Some authors also use TIF or  GIF image files; does anyone have
any experience in getting the actual pixel values so we can process
the image. Any hint is appreciated.

Thanks,
- -Yudi-

- ------------------------------
Yudi Pawitan: yudi at ucd.ie
Department of Statistics, UCD
Dublin 4, Ireland
Ph : 353-1-706 7641
Fax: 353-1-706 1186
- ------------------------------

------- end -------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I have some C functions that I call from S+ to read binary data. 
They
are bin.open.r (ie open to read), bin.read, bin.write, bin.close,
bin.open.w, bin.seek, char, uchar, short and ushort (for unpacking the
data corectly). They also handle byte swapping. 

If you want to have a go at making them work under R I
could send them to you, or I could have a go at it later in the week.

					  rob


yudi at ucd.ie writes:
 > Accidentally this only came to me (MM).
 > 
 > ------- start of forwarded message (RFC 934 encapsulation) -------
 > 
 > > >>>>> "Yudi" == Yudi Pawitan <yudi at ucd.ie> writes:
 > > 
 > >     Yudi> Is there facility in R to read binary file? In Splus scan() has
 > >     Yudi> 'width=' argument and AsciiToInt() command to translate the
 > >     Yudi> binary data. Is there something similar in R?
 > > 
 > 
 > >From  Martin Maechler <maechler at stat.math.ethz.ch>	
 > > The two simple function  pack8bit() and unpack8bit()  which are now part of
 > > the wavethresh package on CRAN {{and are applied to store the
 > > 	       		        picture of John Lennon more efficiently}}
 > > could come handy here.
 > > 
 > Actually I'm trying to read ppm image files that have a mixture of
 > ASCII characters (describing the content of a file) and binary values. 
 > Splus can do this. Maybe I have to write a C subroutine?
 > 
 >  Some authors also use TIF or  GIF image files; does anyone have
 > any experience in getting the actual pixel values so we can process
 > the image. Any hint is appreciated.
 > 
 > Thanks,
 > - -Yudi-
 > 
 > - ------------------------------
 > Yudi Pawitan: yudi at ucd.ie
 > Department of Statistics, UCD
 > Dublin 4, Ireland
 > Ph : 353-1-706 7641
 > Fax: 353-1-706 1186
 > - ------------------------------
 > 
 > ------- end -------
 > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
 > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
 > Send "info", "help", or "[un]subscribe"
 > (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
 >