dtt_fast | R Documentation |
Rcpp wrapper for the distance transform algorithm described in Felzenszwalb and Huttenlocher (2012)
dtt_fast(x)
x |
matrix of booleans of size |
A matrix of size n x m
containing the distance transform result. Note that this function does not perform any checks on x
.
Pedro Felzenszwalb for the header files dt.h
and misc.h
that do the work, Dario Azzimonti and Julien Bect for the wrapper.
Felzenszwalb, P. F. and Huttenlocher, D. P. (2012). Distance Transforms of Sampled Functions. Theory of Computing, 8(19):415-428.
# Create an image with a square
nc = 256
nr = 256
xx = matrix(FALSE,ncol=nc,nrow=nr)
xx[(nr/16):(nr/16*15-1),nc/16]<-rep(TRUE,nr/16*14)
xx[(nr/16):(nr/16*15-1),nc/16*15]<-rep(TRUE,nr/16*14)
xx[nr/16,(nc/16):(nc/16*15-1)]<-rep(TRUE,nc/16*14)
xx[nr/16*15,(nc/16):(nc/16*15-1)]<-rep(TRUE,nc/16*14)
# Compute Distance transform
zz<- dtt_fast(xx)
# Plot the results
image(xx,col=grey.colors(20), main="Original image")
image(zz,col=grey.colors(20), main="Distance transform")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.