/level-set

level set segmetation

Primary LanguageC++Mozilla Public License 2.0MPL-2.0

Build Status Pull Requests

Licence Release GitHub contributors

level-set

Team project - Cyfrowe techniki rozpoznawania obrazów (pl. "Digital image recognition methods") 2016/2017


Overview

In our “perfect” world there is more and more electronic devices that use discrete data as an input or/and output. The best example is digital camera, that saves recorded image as a binary numbers. Because output informations are numbers, and nowadays processors are powerful, so digital techniques could be used to extract some data from all samples - for example, to speed up some production or medical diagnosis processes.

The main purpose of this project is to detect shape’s borders in images. It is based on “active contour without edges” model (proposed by Chan-Vase) using level set method. Implementation based on

Basic algorithm

“Active contour without edges” model is an evolution form of “active contour” model - also named as a “snake” model.

wiki1

But snake model is not ideal one, because there have to be known edge of an object beforehand to properly segment data, that is why Chan-Vase used level set method to achieve that.

Level set method is not easy, especially looking at it's equation.

eq1,

where C is enclosed area dividing image on three parts:

  • laying outside C area
  • laying on a border of C area
  • laying inside C area

eq2

c1 is an average value of all pixels inside C area, and c2 is an average value of rest pixels. Other parameters like 𝜇, λ, ν, controls precisions and speed of calculations. The main ingredient of level set method is level set function φ(x) that determines shape of C area. The starting initialization function φ(x) can be anything type, but the typical one are function for circle of radius:

eq3

pic1

and sine:

eq4,

that gives a chessboard shape as a start initialization area, and what is more - have fast convergence.

The principle of operation of level set method is based on evolving only φ(x) function that equally change C area.

The numerical equation is denote as:

eq5

Where A and B are coefficients specified as:

eq6

As said before parameters 𝜇, λ, ν, have huge impact on final effect - precision of segmentation. Too small or too big value can result in no segmentation at all.

pic2

Here are some examples, how curvature of φ(x) function, changes with iterations:

demo1demo2

And here is an effect of our work:

image005


##C++11

Why do we need C++11?

Disable copy constructor and move constructor
        Image(Image const&) = delete;  
        Image(Image const&&) = delete;  

Although there is no need for explicitly deleting (since we do not create new objects based on object created earlier), it could be good for documentation. C++11 allows to disabling these. In previous standards copy constructor could be defined as private, so the compiler woludn't allow to call it.

SO1, SO2

auto

TBD

'using' keyword
        using Flags = std::map<std::string, std::string>;

Safer than MACROs

lambdas

TBD

curly brackets initialization
        float sum_inside{}; // inside or on border

TBD

std::stof

TBD

std::next

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4317.pdf

Range-based loop
        for (auto& i : flags)

TBD


Usage

  $ mkdir -p build
  $ cd build
  $ cmake .. # or cmake -DBUILD_TESTS=ON if you want to build gtests
  $ make
  $ ./level-set -i ../test-images/001.jpg

Ifstead of cmake .. type cmake -DBUILD_TESTS=ON if you want to build gtests.


Results

1-gif 2-gif 3-gif


Timeline

  • 28.11.2016 - start
  • 16.01.2017 - project will have been finished by this date
  • 23.01.2017 - presentation

Credits

TBD

Contributors

GitHub contributors

contributors

Licence

Licence

Mozilla Public License Version 2.0