Description Usage Arguments Examples
These functions for 2D 0/1 image matrices
1 | my.circ.measure(x, r)
|
x |
is a 0/1 matrix. |
r |
is a positive real value of width to measure circumference. |
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 27 28 29 30 31 32 33 34 35 | x <- matrix(1:16,4,4)
v <- c(2,3)
my.parallel(x,v)
v <- c(-2,-3)
my.parallel(x,v)
v <- c(2,-3)
my.parallel(x,v)
n <- 2^8
x <- y <- 1:n
xy <- as.matrix(expand.grid(x,y))
xy.val <- rep(0,length(xy[,1]))
n.circle <- 100
ctr <- matrix(sample(50:200,replace=TRUE,n.circle*2),ncol=2)
r <- sample(1:40,replace=TRUE,n.circle)
for(i in 1:n.circle){
tmp.x <- xy[,1] - ctr[i,1]
tmp.y <- xy[,2] - ctr[i,2]
s <- which(tmp.x^2+tmp.y^2 < r[i]^2)
xy.val[s] <- 1
}
xy.mat <- matrix(xy.val,ncol=n)
image(xy.mat)
rs <- seq(from=0,to=20,length=21)
rs <- rs[-1]
tmp.out <- list()
for(i in 1:length(rs)){
tmp.out[[i]] <- my.circ.measure(xy.mat,rs[i])
}
circs <- rep(0,length(rs))
for(i in 1:length(tmp.out)){
circs[i] <- tmp.out[[i]]$circ
}
plot(rs,circs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.