calc_t {potts} | R Documentation |
Calculate Canonical Statistic for Potts Model
Description
Calculate the canonical statistic 't' for a realization of a Potts Model
Usage
calc_t_full(x,ncolor)
calc_t_innergrid(x, ncolor, grid, i, j)
calc_t(x, ncolor, grid=NULL, i=NULL, j=NULL)
Arguments
x |
2 dimensional matrix, elements in 1, ..., |
ncolor |
numeric. Number of colors in this Potts Model. |
grid |
numeric. 2 dimensional matrix, elements in 1, ...,
|
i |
numeric. Row to place the grid. |
j |
numeric. Column to place the grid. |
Details
For a description of notation and terminology, see
composite.ll
.
Calculates the canonical statistics for a realized Potts Model.
calc_t
calls calc_t_full
if grid
is NULL
and calc_t_innergrid
otherwise.
calc_t_full
calculates the canonical statistics for the full image.
calc_t_innergrid
calculates the canonical statistics for the a
window of the image, but with that window replaced by grid
,
with the upper left corner of grid
located at x[i,j]
.
Value
For a description of notation and terminology, see
composite.ll
.
All functions return a vector of length ncolor+1
. Elements
1,...,ncolor
contain the number of pixels of each color.
Element ncolor+1
contains the number of matching neighbor pairs
for the image.
calc_t_full
returns the values for the whole image.
calc_t_innergrid
returns the value for just the selected
window, but this includes the number of matching pairs from the
replaced window to it's neighbors. E.g. if X
is the full
image, and A_a
is the value of some window in the image
and we want to know the value of t(y \cup X \setminus
A_a)
this would be calc_t_full(X,
ncolor) + calc_t_innergrid(X, ncolor, y, i, j) - calc_t_innergrid(X,
ncolor, A(a), i, j)
See Also
generate_t_cache
, composite.ll
.
Examples
ncolor <- 4
beta <- log(1+sqrt(ncolor))
theta <- c(rep(0,ncolor), beta)
nrow <- 32
ncol <- 32
x <- matrix(sample(ncolor, nrow*ncol, replace=TRUE), nrow=nrow, ncol=ncol)
foo <- packPotts(x, ncolor)
out <- potts(foo, theta, nbatch=10)
x <- unpackPotts(out$final)
t_stat <- calc_t(x, ncolor)
t_stat_inner <- calc_t(x, ncolor, matrix(1, nrow=2, ncol=2), 1, 1)