HiLab-git / SimpleCRF

matlab and python wrap of crf and dense crf, both 2d and 3d are supported
BSD 3-Clause "New" or "Revised" License
164 stars 34 forks source link

SimpleCRF

Matlab and Python wrap of Conditional Random Field (CRF) and fully connected (dense) CRF for 2D and 3D image segmentation, according to the following papers:

[1] Yuri Boykov and Vladimir Kolmogorov, "An experimental comparison of min-cut/max-flow algorithms for energy minimization in vision", IEEE TPAMI, 2004.

[2] Philipp Krähenbühl and Vladlen Koltun, "Efficient inference in fully connected crfs with gaussian edge potentials", in NIPS, 2011.

[3] Kamnitsas et al in "Efficient multi-scale 3D CNN with fully connected CRF for accurate brain lesion segmentation", Medical Image Analysis, 2017.

maxflow densecrf1 densecrf2

Dependency

This repository depends on the following packages: Maxflow, DenceCRF and 3D Dense CRF

Installation

  1. Install by: pip install SimpleCRF

  2. Alternatively, you can compile the source files by the following two steps:

    python setup.py build
    python setup.py install

Examples

Some demos of using this package are:

Modules

  1. maxflow has four functions as follows. Note that the current version only supports binary segmentation.
  1. denseCRF has the following function. It can deal with multi-class segmentation, and only supports RGB images.
  1. denseCRF3D has the following function. It can deal with multi-class segmentation. The input channel number can be 1-5.