Grokbase Groups R r-help March 2002
FAQ
Hi all,

Although R seems to have jpeg() and png() functions that converts data into
jpeg and png formated files, it
doesn't have functions the other way around.
Does one of R contributed packages have gif, jpeg and png image readers? I
did help.search() but no luck

Regards,
Jonathan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

  • Roger Peng at Mar 12, 2002 at 1:43 am
    The pixmap package has functions for reading pnm (portable anymap) files,
    but you still need an outside software to convert (like ImageMagick).

    -roger
    _______________________________
    UCLA Department of Statistics
    rpeng at stat.ucla.edu
    http://www.stat.ucla.edu/~rpeng
    On Mon, 11 Mar 2002, jonathan_li at agilent.com wrote:

    Hi all,

    Although R seems to have jpeg() and png() functions that converts data into
    jpeg and png formated files, it
    doesn't have functions the other way around.
    Does one of R contributed packages have gif, jpeg and png image readers? I
    did help.search() but no luck

    Regards,
    Jonathan
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Jonathan Q. Li at Mar 12, 2002 at 5:39 pm
    Yah, but what if I need to write a package in R that reads these images?
    It's
    too much manual trouble to use outside software. It's especially infeasible
    if
    these become a routine task with many images.
    I think that here may be a place to make an improvement to R.
    I, for one, can certainly appreciate the use of such reader functions. Are
    there any one else
    who felt the same way?

    Jonathan

    -----Original Message-----
    From: Roger Peng [mailto:rpeng at stat.ucla.edu]
    Sent: Monday, March 11, 2002 5:43 PM
    To: jonathan_li at agilent.com
    Cc: r-help at stat.math.ethz.ch
    Subject: Re: [R] gif, jpeg and png image files reader


    The pixmap package has functions for reading pnm (portable anymap) files,
    but you still need an outside software to convert (like ImageMagick).

    -roger
    _______________________________
    UCLA Department of Statistics
    rpeng at stat.ucla.edu
    http://www.stat.ucla.edu/~rpeng
    On Mon, 11 Mar 2002, jonathan_li at agilent.com wrote:

    Hi all,

    Although R seems to have jpeg() and png() functions that converts data into
    jpeg and png formated files, it
    doesn't have functions the other way around.
    Does one of R contributed packages have gif, jpeg and png image readers? I
    did help.search() but no luck

    Regards,
    Jonathan
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
    _._
    >

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Jason Turner at Mar 12, 2002 at 9:17 pm

    One quick point ... On Tue, Mar 12, 2002 at 09:39:28AM -0800, Jonathan Q. Li wrote:
    Yah, but what if I need to write a package in R that reads these images?
    It's
    too much manual trouble to use outside software. It's especially infeasible
    if
    these become a routine task with many images. ...
    -----Original Message-----
    From: Roger Peng [mailto:rpeng at stat.ucla.edu]
    Sent: Monday, March 11, 2002 5:43 PM
    To: jonathan_li at agilent.com
    Cc: r-help at stat.math.ethz.ch
    Subject: Re: [R] gif, jpeg and png image files reader


    The pixmap package has functions for reading pnm (portable anymap) files,
    but you still need an outside software to convert (like ImageMagick).
    -------
    The ImageMagick suite Roger Peng was refering to can be run from the
    command line, so automating this with a wrapper in R isn't too hard
    (though tricky to do in a portable way). There are also C, C++, Perl,
    and Java interfaces to ImageMagick, so you could do it the more
    robust and secure way (what's below is quick and dirty, though
    it works for me).

    You can get ImageMagick from http://www.imagemagick.org/

    This works so far on my Linux box. I've tried it for gif, jpg, png,
    xpm, and postscript images. Convert will handle many more formats too.
    Just give it the filename of the image, optionally the path to the
    "convert" command, and any additional arguments to "convert" - rarely
    needed, as convert is *extremely* clever at working out image formats.

    ###BARELY TESTED CODE!!! PROBABLY HAS BUGS!!!
    ## requires the "convert" program from ImageMagick
    ##to be available to the user. ImageMagick can be
    ##obtained from http://www.imagemagick.org/

    read.image <- function(file, imdir="/usr/X11R6/bin/",...) {

    if(!require(pixmap)) stop("library pixmap required and not found\n")

    newfile <- tempfile() ##note the race condition on this line and next
    cmd <- paste(sep="",imdir,"convert ", ... ," ",file," pnm:",newfile)

    retval <- system(cmd)
    if(retval != 0) {
    errmsg <- paste("system command",cmd,"failed with error code",
    retval,"\n")
    stop(errmsg)
    }
    p1 <- read.pnm(newfile)
    unlink(newfile)
    p1
    }

    Also, IIRC, R has specific instructions on startup on how to deal with
    things if the above isn't enough.... lesse here.... ah, yes:
    "R is a collaborative project with many contributors."
    Or, to (mis?) quote Ghandi: "Be the change you seek in the world."

    Cheers

    Jason
    --
    Indigo Industrial Controls Ltd.
    64-21-343-545
    jasont at indigoindustrial.co.nz
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Agustin Lobo at Mar 13, 2002 at 10:53 am
    Jonathan,

    Although I see your point, perhaps developing a
    comprehensive package in R for image processing would not be
    the best solution. We cannot expect R to do
    everything. From my point of view, a transparent
    link to other gnu software might be better. This is
    also the case for GIS, which although very useful
    in combination with R, is not really statistics.
    R is already very large, so much that we are all
    beginers as soon as we move a bit from what we
    normally do. I'd be careful at increasing
    heterogeneity too much, because maintenace, management,
    documentation... might become impossible. The
    R team, to whom all R users must be thankful, already
    has a phenomenal task.

    If you need to import many images, you can use
    packages that transform from the command
    line, so you can make an R function that
    transforms the images to pnm using system(), and
    then use the pixmap functions.

    I've made some functions to have a minimal
    functionality in R to display and explore
    matrices as images (grey and rgb). Let me
    know if these could help you.

    A better approach might be using the
    new RPy, as Python has an image processing
    library (PIL). It used to have as well an
    extensive image processing add-on, called
    PythonMagick, but I think that this
    is no longer available.

    Agus


    Dr. Agustin Lobo
    Instituto de Ciencias de la Tierra (CSIC)
    Lluis Sole Sabaris s/n
    08028 Barcelona SPAIN
    tel 34 93409 5410
    fax 34 93411 0012
    alobo at ija.csic.es

    On Tue, 12 Mar 2002, Jonathan Q. Li wrote:

    Yah, but what if I need to write a package in R that reads these images?
    It's
    too much manual trouble to use outside software. It's especially infeasible
    if
    these become a routine task with many images.
    I think that here may be a place to make an improvement to R.
    I, for one, can certainly appreciate the use of such reader functions. Are
    there any one else
    who felt the same way?

    Jonathan

    -----Original Message-----
    From: Roger Peng [mailto:rpeng at stat.ucla.edu]
    Sent: Monday, March 11, 2002 5:43 PM
    To: jonathan_li at agilent.com
    Cc: r-help at stat.math.ethz.ch
    Subject: Re: [R] gif, jpeg and png image files reader


    The pixmap package has functions for reading pnm (portable anymap) files,
    but you still need an outside software to convert (like ImageMagick).

    -roger
    _______________________________
    UCLA Department of Statistics
    rpeng at stat.ucla.edu
    http://www.stat.ucla.edu/~rpeng
    On Mon, 11 Mar 2002, jonathan_li at agilent.com wrote:

    Hi all,

    Although R seems to have jpeg() and png() functions that converts data into
    jpeg and png formated files, it
    doesn't have functions the other way around.
    Does one of R contributed packages have gif, jpeg and png image readers? I
    did help.search() but no luck

    Regards,
    Jonathan
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
    _._
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Anthony Rossini at Mar 12, 2002 at 5:51 pm
    Great, Jonathan. We are looking forward to your contributions! I'm glad you've volunteered to take on such a pressing task, since of course, scripting with another language isn't quite so elegant.

    (on a serious note, I've needed to do such, and scripting with other languages (Python, but I'm sure Perl would do) sufficed; while it is a place that could use improvement, I don't think it is nearly as pressing, since tools are freely available for solving the general problem).

    best,
    -tony

    On Tue, 12 Mar 2002, Jonathan Q. Li wrote:

    Yah, but what if I need to write a package in R that reads these images?
    It's
    too much manual trouble to use outside software. It's especially infeasible
    if
    these become a routine task with many images.
    I think that here may be a place to make an improvement to R.
    I, for one, can certainly appreciate the use of such reader functions. Are
    there any one else
    who felt the same way?

    Jonathan

    -----Original Message-----
    From: Roger Peng [mailto:rpeng at stat.ucla.edu]
    Sent: Monday, March 11, 2002 5:43 PM
    To: jonathan_li at agilent.com
    Cc: r-help at stat.math.ethz.ch
    Subject: Re: [R] gif, jpeg and png image files reader


    The pixmap package has functions for reading pnm (portable anymap) files,
    but you still need an outside software to convert (like ImageMagick).

    -roger
    _______________________________
    UCLA Department of Statistics
    rpeng at stat.ucla.edu
    http://www.stat.ucla.edu/~rpeng
    On Mon, 11 Mar 2002, jonathan_li at agilent.com wrote:

    Hi all,

    Although R seems to have jpeg() and png() functions that converts data into
    jpeg and png formated files, it
    doesn't have functions the other way around.
    Does one of R contributed packages have gif, jpeg and png image readers? I
    did help.search() but no luck

    Regards,
    Jonathan
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
    _._
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    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
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedMar 11, '02 at 11:29p
activeMar 13, '02 at 10:53a
posts6
users5
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase