mrf2d
An R package for analysis of Markov Random Fields on 2-dimensional lattices.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (22.0%) to scientific vocabulary
Keywords
cran
gibbs-energy
hidden-markov-model
hidden-markov-models
markov-random-field
mrf
mrf-models
neighborhood
r
rpackage
Last synced: 6 months ago
·
JSON representation
Repository
An R package for analysis of Markov Random Fields on 2-dimensional lattices.
Basic Info
- Host: GitHub
- Owner: Freguglia
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: https://freguglia.github.io/mrf2d/
- Size: 34.7 MB
Statistics
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 5
Topics
cran
gibbs-energy
hidden-markov-model
hidden-markov-models
markov-random-field
mrf
mrf-models
neighborhood
r
rpackage
Created over 6 years ago
· Last pushed about 2 years ago
Metadata Files
Readme
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
echo = FALSE
)
```
# mrf2d
[](https://github.com/Freguglia/mrf2d/actions/workflows/check-release.yaml)
[](https://cran.r-project.org/package=mrf2d)
[](https://app.codecov.io/gh/Freguglia/mrf2d?branch=main)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
Markov Random Fields are probabilistic models capable of describing sets of random variables with a local dependence property (the Markov property) defined on a neighborhood system. Particularly on the context of image processing, pixels can be seen as vertices of a graph defined on a finite 2-dimensional lattice, and a neighborhood system can be defined based on their relative positions to construct a MRF.
The goal of `mrf2d` is to provide a framework for the analysis of Markov Random Fields with pairwise interactions on 2-dimensional lattices, including Hidden Markov Random Fields. It introduces the S4 class `mrfi` to describe interaction structures in a very general way, being able to adapt from very simple cases like the Ising Model to complex anisotropic models with different types of interaction.
```{r example_interacions, fig.show="hold", warning = FALSE, message = FALSE, fig.width=1.8, fig.height=1.6}
library(mrf2d)
plot(mrfi())
plot(mrfi(max_norm = 2, norm_type = "m"))
plot(mrfi(max_norm = 2, positions = list(c(3,3),c(4,4), c(-2,4))))
```
A complete paper describing the details of the package and examples is published in the Journal of Statistical Software and can be found [here](https://doi.org/10.18637/jss.v101.i08).
---
## Installation
You can install the stable version of `mrf2d` from [CRAN](https://CRAN.R-project.org) with:
```{r, echo = TRUE, eval = FALSE}
install.packages("mrf2d")
```
The development version is available on the package's [Github page](https://github.com/Freguglia/mrf2d). It can be installed with the `devtools` package by using
```{r, echo = TRUE, eval=FALSE}
devtools::install_github("Freguglia/mrf2d")
```
---
## Usage
`mrf2d` introduces a programming interface for the general Markov Random Field model in *Freguglia, Victor, Nancy L. Garcia, and Juliano L. Bicas. "Hidden Markov random field models applied to color homogeneity evaluation in dyed textile images." Environmetrics (2019): e2613.* Using specific interaction structures and parameter restrictions can lead to important models as particular cases, such as the Potts model.
It introduces the S4 class `mrfi` to represent interaction structures. The `mrfi()` function can be used to create these objects representing interaction structures with relative positions included based on the norm of the relative position (distance) or explicitly specified
```{r plot_interaction, echo = TRUE, fig.width=2, fig.height=2}
interact <- mrfi(max_norm = 1, positions = list(c(4,2)))
interact
plot(interact)
```
Potentials (parameters) are represented by three-dimensional arrays, where rows and columns represent pixel label values and slices represent interacting positions.
```{r, echo = TRUE}
potentials <- expand_array(c(-0.9, -0.9, 0.2), family = "oneeach", C = 1, mrfi = interact)
potentials
```
The negative values out of diagonal means different "colors" are less likely in that relative position.
The package has many built-in functions for sampling, potentials estimation and hidden MRF model fitting (used for image segmentation), but it also provides all the basic stack of computations used to implement algorithms for MRF models, making it suitable for development of research in Markov Random Field models.
```{r Z_example_plot, echo = TRUE, fig.width=5.5, fig.height=4, fig.align='center'}
set.seed(1)
img_dim <- c(200,200)
Z <- rmrf2d(img_dim, mrfi = interact, theta = potentials, cycles = 60)
dplot(Z, legend = TRUE)
```
---
## Contributing and Bug Reports
If you're interested in contributing or found a bug or error, please file an [issue](https://github.com/Freguglia/mrf2d/issues). Contributions can be done in form of code optimization, new ideas, discussing new structures, etc.
Owner
- Name: Victor Freguglia
- Login: Freguglia
- Kind: user
- Location: Brazil
- Company: Unicamp
- Repositories: 5
- Profile: https://github.com/Freguglia
PhD in Statistics. R, Python, C++ and vim.
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 16
- Average time to close issues: N/A
- Average time to close pull requests: 12 minutes
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 16
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- Freguglia (16)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 302 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 7
- Total maintainers: 1
cran.r-project.org: mrf2d
Markov Random Field Models for Image Analysis
- Homepage: https://github.com/Freguglia/mrf2d
- Documentation: http://cran.r-project.org/web/packages/mrf2d/mrf2d.pdf
- License: GPL-3
-
Latest release: 0.4.1
published over 5 years ago
Rankings
Stargazers count: 17.4%
Dependent repos count: 23.8%
Forks count: 27.8%
Dependent packages count: 28.7%
Average: 30.0%
Downloads: 52.2%
Maintainers (1)
Last synced:
6 months ago
Dependencies
.github/workflows/check-release.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 3.5.0 depends
- Rcpp >= 1.0.1 imports
- Rdpack * imports
- dplyr >= 0.8.1 imports
- ggplot2 * imports
- methods * imports
- tidyr * imports
- covr * suggests
- glue * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat >= 2.1.0 suggests