localCurvature: Local Curvature

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/localCurvature.R

Description

Computes signed curvature along a line.

Usage

1
localCurvature(x, h, maxk)

Arguments

x

A data frame or matrix of dimensions N x 2 containing the coordinates of the line, where N is the number of points. The points should be ordered according to their position on the line. The columns should contain the x and y coordinates. The curvature calculation is unaffected by any permutation of the columns. Directly accepts a list element from ocontour.

h

Specifies the length of the smoothing window. See locfit::lp for more details.

maxk

See locfit::locfit.raw for details.

Details

localCurvature fits a local non-parametric smoothing line (polynomial of degree 2) at each point along the line segment, and computes the curvature locally using numerical derivatives.

Value

Returns a list containing the contour coordinates x, the signed curvature at each point curvature and the arc length of the contour length.

Author(s)

Joseph Barry, Wolfgang Huber, 2013

See Also

ocontour

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  ## curvature goes as the inverse of the radius of a circle
  range=seq(3.5,33.5,by=2)
  plotRange=seq(0.5,33.5,length=100)
  circleRes=array(dim=length(range))
  names(circleRes)=range
  for (i in  seq_along(1:length(range))) {
   y=as.Image(makeBrush('disc', size=2*range[i]))
   y=ocontour(y)[[1]]
   circleRes[i]=abs(mean(localCurvature(x=y,h=range[i])$curvature, na.rm=TRUE))
  }
  plot(range, circleRes, ylim=c(0,max(circleRes, na.rm=TRUE)), xlab='Circle Radius', ylab='Curvature', type='p', xlim=range(plotRange))
  points(plotRange, 1/plotRange, type='l')

  ## Calculate curvature
  x = readImage(system.file("images", "shapes.png", package="EBImage"))[25:74, 60:109]
  x = resize(x, 200)
  y = gblur(x, 3) > .3
  display(y)
  
  contours = ocontour(bwlabel(y))
  c = localCurvature(x=contours[[1]], h=11)
  i = c$curvature >= 0
  pos = neg = array(0, dim(x))
  pos[c$contour[i,]+1]  = c$curvature[i]
  neg[c$contour[!i,]+1] = -c$curvature[!i]
  display(10*(rgbImage(pos, , neg)), title = "Image curvature")

Example output



EBImage documentation built on Nov. 8, 2020, 5:41 p.m.