mrfi-class: mrfi: MRF interaction structure

Description Usage Arguments Details Value Slots Note See Also Examples

Description

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.

Usage

 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)

Arguments

max_norm

a numeric value. All points with norm max_dist are included.

norm_type

a character indicating the norm type used. Possible values are "m", "1", "2", etc. See norm for details.

positions

a list of numeric vectors of length 2. Each vector corresponds to a relative position included.

x

mrfi object.

...

other arguments not used by this method.

i

vector of indexes to extract interacting positions.

e1, mrfi

A mrfi object.

e2

Either a second mrfi object or a length 2 numeric with the new relative position to include (+) or remove (-).

Details

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)).

Value

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.

Slots

Rmat

A 2-column matrix where each row represents a relative position of interaction.

Note

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.

See Also

A paper with detailed description of the package can be found at https://arxiv.org/abs/2006.00383

Examples

 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)[[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)

mrf2d documentation built on Oct. 30, 2020, 1:07 a.m.