get.stencil | R Documentation |
A stencil defines a neighbourhood in an image (for example, the four nearest neighbours in a 2d image). This function centers the stencil at a certain pixel and returns the values of the neighbourhing pixels.
get.stencil(im, stencil, ...)
im |
an image |
stencil |
a data.frame with values dx,dy,[dz],[dcc] defining the neighbourhood |
... |
where to center, e.g. x = 100,y = 10,z=3,cc=1 |
pixel values in neighbourhood
Simon Barthelme
#The following stencil defines a neighbourhood that
#includes the next pixel to the left (delta_x = -1) and the next pixel to the right (delta_x = 1)
stencil <- data.frame(dx=c(-1,1),dy=c(0,0))
im <- as.cimg(function(x,y) x+y,w=100,h=100)
get.stencil(im,stencil,x=50,y=50)
#A larger neighbourhood that includes pixels upwards and
#downwards of center (delta_y = -1 and +1)
stencil <- stencil.cross()
im <- as.cimg(function(x,y) x,w=100,h=100)
get.stencil(im,stencil,x=5,y=50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.