Hello, how can I load an external picture/image file to screen? I want to use locator() then to get coordinates of that picture... ...in other words I want to use R to do some measurements on a picture. Therefore I need to load the image into R display, and that displaying needs to work together with locator(). How to do it best? At the moment I need to be able to read in *.png files, but if *.jpeg or other formats also will be supporttzed, this would be fine.
baptiste auguie
2010-Jun-06 12:44 UTC
[R] Loading an image/picture (png/jpeg/...) to screen...
Hi, Try this, library(png) example(readPNG) HTH, baptiste On 6 June 2010 13:46, oliver <oliver at first.in-berlin.de> wrote:> Hello, > > > how can I load an external picture/image file to screen? > > I want to use locator() then to get coordinates of that picture... > ...in other words I want to use R to do some measurements on a picture. > > Therefore I need to load the image into R display, > and that displaying needs to work together with locator(). > > > How to do it best? > > At the moment I need to be able to read in *.png files, > but if *.jpeg or other formats also will be supporttzed, this would be fine. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Once you have your image displayed in a plot, look at the updateusr function in the TeachingDemos package for a way to modify the coordinate system to what you want so that using locator() gives the results that you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of oliver > Sent: Sunday, June 06, 2010 5:46 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Loading an image/picture (png/jpeg/...) to screen... > > Hello, > > > how can I load an external picture/image file to screen? > > I want to use locator() then to get coordinates of that picture... > ...in other words I want to use R to do some measurements on a picture. > > Therefore I need to load the image into R display, > and that displaying needs to work together with locator(). > > > How to do it best? > > At the moment I need to be able to read in *.png files, > but if *.jpeg or other formats also will be supporttzed, this would be > fine. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.