bayesImageS v0.4-0

0

Monthly downloads

0th

Percentile

Bayesian Methods for Image Segmentation using a Potts Model

Various algorithms for segmentation of 2D and 3D images, such as computed tomography and satellite remote sensing. This package implements Bayesian image analysis using the hidden Potts model with external field prior. Latent labels are sampled using chequerboard updating or Swendsen-Wang. Algorithms for the smoothing parameter include pseudolikelihood, path sampling, the exchange algorithm, and approximate Bayesian computation (ABC).

Readme

Various algorithms for segmentation of 2D and 3D images, such as computed tomography (CT) and satellite remote sensing. This R package implements Bayesian image analysis using the hidden Potts/Ising model with external field prior. Latent labels are sampled using chequerboard Gibbs sampling or Swendsen-Wang. Algorithms for the smoothing parameter include pseudolikelihood, path sampling, the exchange algorithm, and approximate Bayesian computation (ABC-MCMC and ABC-SMC).

For example, to generate synthetic data for a known value of β:

set.seed(123456)
library(bayesImageS)
neigh <- matrix(c(5,2,5,3,  1,5,5,4,  5,4,1,5,  3,5,2,5), nrow=4, ncol=4, byrow=TRUE)
blocks <- list(c(1,4), c(2,3))
res.sw <- swNoData(0.5, 3, neigh, blocks, niter=200)

Now add some Gaussian noise to the labels, according to the prior:

priors <- list()
priors$k <- 3
priors$mu <- c(-2, 0, 2)
priors$mu.sd <- rep(0.5,priors$k)
priors$sigma <- rep(0.25,priors$k)
priors$sigma.nu <- rep(3, priors$k)
priors$beta <- c(0,1.3)

m0 <- sort(rnorm(priors$k,priors$mu,priors$mu.sd))
SS0 <- priors$sigma.nu*priors$sigma^2
s0 <- 1/sqrt(rgamma(priors$k,priors$sigma.nu/2,SS0/2))
z <- max.col(res.sw$z)[1:nrow(neigh)]
y <- m0[z] + rnorm(nrow(neigh),0,s0[z])

Image segmentation using SMC-ABC:

res.smc <- smcPotts(y, neigh, blocks, priors=priors)
#> Initialization took 1sec
#> Iteration 1
#> previous epsilon 2 and ESS 10000 (target: 9500)
#> Took 8sec to update epsilon=9.33264e-302 (ESS=9796.24)
#> Took 1sec for 9105 RWMH updates (bw=0.519431)
#> Took 1sec for 10000 iterations to calculate S(z)=2
# pixel classifications
pred <- res.smc$alloc/rowSums(res.smc$alloc)
seg <- max.col(res.smc$alloc) # posterior mode (0-1 loss)
all.equal(seg, z)
#> [1] TRUE
mean(res.smc$beta)
#> [1] 0.649113
apply(res.smc$mu, 2, range)
#>            [,1]      [,2]       [,3]
#> [1,] -3.2701475 -1.254859 0.08924757
#> [2,] -0.5336341  1.388502 4.04662164
m0
#> [1] -1.14599925 -0.09531646  1.81442878

Functions in bayesImageS

Name Description
bayesImageS Package bayesImageS
mcmcPotts Fit the hidden Potts model using a Markov chain Monte Carlo algorithm.
mcmcPottsNoData Simulate pixel labels using chequerboard Gibbs sampling.
getNeighbors Get Neighbors of All Vertices of a Graph
gibbsGMM Fit a mixture of Gaussians to the observed data.
gibbsNorm Fit a univariate normal (Gaussian) distribution to the observed data.
initSedki Initialize the ABC algorithm using the method of Sedki et al. (2013)
swNoData Simulate pixel labels using the Swendsen-Wang algorithm.
testResample Test the residual resampling algorithm.
exactPotts Calculate the distribution of the Potts model using a brute force algorithm.
smcPotts Fit the hidden Potts model using approximate Bayesian computation with sequential Monte Carlo (ABC-SMC).
sufficientStat Calculate the sufficient statistic of the Potts model for the given labels.
getBlocks Get Blocks of a Graph
getEdges Get Edges of a Graph
No Results!

Vignettes of bayesImageS

Name
InverseTemperature.bib
bcrit2d-eps-converted-to.pdf
bcrit2d.eps
bcrit2d_sd-eps-converted-to.pdf
bcrit2d_sd.eps
bcrit3d-eps-converted-to.pdf
bcrit3d.eps
bcrit3d_sd-eps-converted-to.pdf
bcrit3d_sd.eps
beta_ct-eps-converted-to.pdf
beta_ct.eps
ct_hist-eps-converted-to.pdf
ct_hist.eps
elapsed2D-eps-converted-to.pdf
elapsed2D.eps
elapsed3D-eps-converted-to.pdf
elapsed3D.eps
elapsed_ct-eps-converted-to.pdf
elapsed_ct.eps
exact_exp_k-eps-converted-to.pdf
exact_exp_k.eps
exact_exp_n-eps-converted-to.pdf
exact_exp_n.eps
exact_var_k-eps-converted-to.pdf
exact_var_k.eps
exact_var_n-eps-converted-to.pdf
exact_var_n.eps
fanbeam.jpeg
introduction.Rnw
mcmc_err2D_ABC-eps-converted-to.pdf
mcmc_err2D_ABC.eps
mcmc_err2D_MAVM-eps-converted-to.pdf
mcmc_err2D_MAVM.eps
mcmc_err2D_PL-eps-converted-to.pdf
mcmc_err2D_PL.eps
mcmc_err2D_TI-eps-converted-to.pdf
mcmc_err2D_TI.eps
ndvi_hist-eps-converted-to.pdf
ndvi_hist.eps
ndvi_image.jpeg
path2d-eps-converted-to.pdf
path2d.eps
path3d-eps-converted-to.pdf
path3d.eps
pl_exp_n12k3-eps-converted-to.pdf
pl_exp_n12k3.eps
pl_sd_n12k3-eps-converted-to.pdf
pl_sd_n12k3.eps
No Results!

Last month downloads

Details

Type Package
Date 2017-03-21
License GPL (>= 2)
URL https://bitbucket.org/Azeari/bayesimages
BugReports https://bitbucket.org/Azeari/bayesimages/issues
LinkingTo Rcpp, RcppArmadillo
VignetteBuilder knitr
RoxygenNote 5.0.1
NeedsCompilation yes
Packaged 2017-03-21 13:24:03 UTC; stsrjs
Repository CRAN
Date/Publication 2017-03-21 15:13:30 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/bayesImageS)](http://www.rdocumentation.org/packages/bayesImageS)