# Working with 3d lattices in mrf2d In mrf2d: Markov Random Field Models for Image Analysis



## Hidden MRFs

Hidden Markov Random Fields on 3 dimensions can also be projected to 2 dimensions using the exact same strategy. Here we add a Gaussian noise to the Ising Model sample generated.

set.seed(3)
Yflat <- Zflat_ising + rnorm(prod(dim(Zflat)), sd = 0.4)
cplot(Yflat)


Again, by using the 2d projection of the 3d nearest-neighbor interaction structure R3, we can fit a Gaussian Hidden Markov Random Field model with the fit_ghm() function with the transformed data.

set.seed(4)
denoising <- fit_ghm(Yflat, R3, theta, verbose = FALSE)


The recovered image for the underlying field will also be a 2d projected version of the array.

dplot(denoising$Z_pred)  # Caveats of 2d projections There are some not so obvious drawbacks in the presented approach to creating 2-dimensional versions of 3d Markov Random Field problems. The most important in our vision are: • The interaction structure cannot be directly reused for multiple datasets if the analyzed have different sizes. For example: In our$64 \times 64 \times 3$data, the nearest-neighbor interactions structure$(1,0,0), (0,1,0), (0,0,1)$was mapped to the 2d version$(1,0), (0,1), (65,0)$. If new data with dimensions$100 \times 100 \times 3$was considered, the corresponding interacting structure would be$(1,0), (0,1), (101,0)$. This problem can be dealt with by considering an arbitrarily large number of NA columns between slices in the 2d projection, but a maximum size would be required known prior to starting the implementation. • Converting analysis results back to a three-dimensional interpretation requires a careful understanding of how the projections were obtained. For example, in the previous example, without the information on the array dimensions and the number of NA columns, it is not possible to infer that the relative position$(65,0)$is mapping$(0,0,1)\$ and, even with such information, interpreting raw long-range 2d relative positions as 3d relative positions is not an intuitive task.

## Try the mrf2d package in your browser

Any scripts or data that you put into this service are public.

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