| mrfi-class | R Documentation |
The mrfi S4 class is a representation of the interaction
structure for a spatially-stationary Markov Random Field.
The function 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 max_norm and
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, rpositions()
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
subtracting two mrfi objects.
These operations deal with opposite directions filtering to avoid redundancy in the interaction structure.
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)
max_norm |
a |
norm_type |
a |
positions |
a |
x |
|
... |
other arguments not used by this method. |
i |
vector of indexes to extract interacting positions. |
e1, mrfi |
A |
e2 |
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 rx and ry
representing the "shift" in the x-axis and 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 mrfi object.
To illustrate that, a nearest neighbor dependence structure can be specified by:
mrfi(1)
Note that it only includes the positions (1,0) and (0,1), but when
visualizing it, for example, mrf2d understands the opposite directions
are also conditionally dependent, as in
plot(mrfi(1)).
A mrfi object.
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 mrfi object.
+: computes the union of the interaction structure in a mrfi object with
a numeric representing an additional position to include or another mrfi
object.
RmatA 2-column matrix where each row represents a relative position
of interaction.
If a position in positions is already included due to the
max_norm and norm_type specification, the second ocurrence is ignored.
The same is valid for repeated or opposite positions in positions.
A paper with detailed description of the package can be found at doi: 10.18637/jss.v101.i08.
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)[[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.