mrfi S4 class is a representation of the interaction
structure for a spatially-stationary Markov Random Field.
mrfi() provides an interface for creation
mrfi objects. A
plot method is also available for visualization, as
well as conversion methods like
as.list and operators like
mrfi() creates an object of class
mrfi based on a distance
rule and optionally a list of relative positions. The argument
norm_type can be used to automatically include all positions within a
"range" defined by the norm type chosen and distance using that norm.
A list of relative positions may also be included to specify sparse
interaction structures, for example. Alternatively,
can be used to create a based exclusively on a list of relative positions.
Simple operations are provided to include (set union)
new interacting positions to a
mrfi object with the
'+' operator and
remove positions (set difference) with
-. Individual positions can be
included/excluded using length-2 vectors in the right hand side. Union and
set difference of complete structures can also be computed by adding or
These operations deal with opposite directions filtering to avoid redundancy in the interaction structure.
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
mrfi(max_norm = 1, norm_type = "1", positions = NULL) rpositions(positions) ## S3 method for class 'mrfi' as.list(x, ...) ## S4 method for signature 'mrfi' length(x) ## S4 method for signature 'mrfi,numeric,missing' x[[i]] ## S4 method for signature 'mrfi,numeric,missing' x[i] ## S4 method for signature 'mrfi,numeric' e1 + e2 ## S4 method for signature 'mrfi,numeric' e1 - e2 ## S4 method for signature 'mrfi,mrfi' e1 + e2 ## S4 method for signature 'mrfi,mrfi' e1 - e2 mrfi_to_string(mrfi)
other arguments not used by this method.
vector of indexes to extract interacting positions.
Either a second
The interaction structure is defined by the list of relative positions in it. For a specific pixel, conditional to the values of pixels in these relative positions from it, its value is independent of any other pixel in the image.
The relative positions are indentified by two integers
representing the "shift" in the
y-axis respectively. As an
example: The relative position
(1,0) representes the pixel in the immediate
right position, while
(-1,0) the left one.
Note that the inclusion of a relative position to the dependence also implies
its opposite direction is not conditionally independent (commutativeness of
dependence), but only one is included in the
To illustrate that, a nearest neighbor dependence structure can be specified by:
Note that it only includes the positions
(0,1), but when
visualizing it, for example,
mrf2d understands the opposite directions
are also conditionally dependent, as in
as.list(): converts the
mrfi object to a list of interacting
positions (list of length-2 vectors).
[[: converts to list and subsets it.
[: subsets the
mrfi object and returns another
+: computes the union of the interaction structure in a
mrfi object with
numeric representing an additional position to include or another
matrix where each row represents a relative position
If a position in
positions is already included due to the
norm_type specification, the second ocurrence is ignored.
The same is valid for repeated or opposite positions in
A paper with detailed description of the package can be found at https://arxiv.org/abs/2006.00383
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
plot(mrfi(max_norm = 2, norm_type = "1")) plot(mrfi(max_norm = 2, norm_type = "m")) plot(mrfi(max_norm = 2, norm_type = "1", positions = list(c(4,4)))) as.list(mrfi(1)) mrfi(1)[] mrfi(2)[[1:3]] mrfi(1) rpositions(list(c(1,0), c(0,1))) mrfi(2) mrfi(2, norm_type = "m") mrfi(1, positions = list(c(4,4), c(-4,4))) #Repeated positions are handled automatically mrfi(1, positions = list(c(1,0), c(2,0))) mrfi(1) + c(2,0) mrfi(1) - c(1,0) mrfi(1) + mrfi(0, positions = list(c(2,0))) mrfi(2) - mrfi(1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.