common_pixsets: Various useful pixsets

common_pixsetsR Documentation

Various useful pixsets

Description

These functions define some commonly used pixsets. px.left gives the left-most pixels of an image, px.right the right-most, etc. px.circle returns an (approximately) circular pixset of radius r, embedded in an image of width x and height y Mathematically speaking, the set of all pixels whose L2 distance to the center equals r or less. px.diamond is similar but returns a diamond (L1 distance less than r) px.square is also similar but returns a square (Linf distance less than r)

Usage

px.circle(r, x = 2 * r + 1, y = 2 * r + 1)

px.diamond(r, x = 2 * r + 1, y = 2 * r + 1)

px.square(r, x = 2 * r + 1, y = 2 * r + 1)

px.left(im, n = 1)

px.top(im, n = 1)

px.bottom(im, n = 1)

px.right(im, n = 1)

px.borders(im, n = 1)

px.all(im)

px.none(im)

Arguments

r

radius (in pixels)

x

width (default 2*r+1)

y

height (default 2*r+1)

im

an image

n

number of pixels to include

Value

a pixset

Functions

  • px.circle(): A circular-shaped pixset

  • px.diamond(): A diamond-shaped pixset

  • px.square(): A square-shaped pixset

  • px.left(): n left-most pixels (left-hand border)

  • px.top(): n top-most pixels

  • px.bottom(): n bottom-most pixels

  • px.right(): n right-most pixels

  • px.borders(): image borders (to depth n)

  • px.all(): all pixels in image

  • px.none(): no pixel in image

Author(s)

Simon Barthelme

Examples


px.circle(20,350,350) %>% plot(interp=FALSE)
px.circle(3) %>% plot(interp=FALSE)
r <- 5
layout(t(1:3))
plot(px.circle(r,20,20))
plot(px.square(r,20,20))
plot(px.diamond(r,20,20))
#These pixsets are useful as structuring elements
px <- grayscale(boats) > .8
grow(px,px.circle(5)) %>% plot
#The following functions select pixels on the left, right, bottom, top of the image
im <- imfill(10,10)
px.left(im,3) %>% plot(int=FALSE)
px.right(im,1) %>% plot(int=FALSE)
px.top(im,4) %>% plot(int=FALSE)
px.bottom(im,2) %>% plot(int=FALSE)
#All of the above
px.borders(im,1) %>% plot(int=FALSE)

imager documentation built on May 29, 2024, 1:38 a.m.