[R] Clip contour or image
Pierre Kleiber
pkleiber at honlab.nmfs.hawaii.edu
Mon Mar 19 20:26:08 CET 2001
I was going to suggest masking the ouside of a selected contour
line using the function antipolygon(), which I have written. However,
I see that contour() in R does not have the ability to return contour
lines as x, y vectors as it does in Splus. This is a feature I found
useful before I switched to R. Question for the R gurus... Would it
be difficult to add this feature to R's version of coutour()?
By the way... this is my antipolygon function:
antipolygon <- function(x,y,col=0){
u <- par("usr")
x <- c(x,x[1],u[1],u[1],u[2],u[2],u[1])
y <- c(y,y[1],u[3],u[4],u[4],u[3],u[3])
polygon(x,y,border=col,col=col)
box()
}
But I should add that it has not been thoroughly tested.
Cheers, Pierre
Thomas Petzoldt wrote:
>
> Han Lai schrieb:
> >
> > Hi,
> >
> > I am almost new to R. Would any one show me (please include an example)
> > how to clip a contour or image figure so that I only see the image or
> > lines inside a selected area?
>
> Hi,
>
> I had a similar problem some weeks before. My problem was to clip an
> interpolated (kriged) surface image of a lake to its _irregular_shaped_
> shoreline. My solution was some kind of "image manipulation". I
> "stamped" the shoreline into the image matrix and filled the region
> outside with the help of the seedfill algorithm, which I implemented as
> an external shared library (runs as Win32-DLL and .so on Linux).
>
> You will need the compiled C library and some R functions. If you or
> another one who would be interested on my R and C functions, I can give
> it to you.
>
> Maybe it would be worth to create a package with "basic image
> manipulation procedures" for matrices. If there is anybody, who has a
> better (or easier) solution, I would be interested too.
>
> Thomas Petzoldt
>
> --
> Thomas Petzoldt (Limnology and Ecological Modelling)
> Institute for Hydrobiology http://www.tu-dresden.de/fghhihb/
> Dresden University of Technology
> mailto:petzoldt at rcs.urz.tu-dresden.de
> 01062 Dresden
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
-----------------------------------------------------------------
Pierre Kleiber Email: pkleiber at honlab.nmfs.hawaii.edu
Fishery Biologist Tel: 808 983-5399/737-7544
NOAA FISHERIES - Honolulu Laboratory Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396
-----------------------------------------------------------------
"God could have told Moses about galaxies and mitochondria and
all. But behold... It was good enough for government work."
-----------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list