Skip to content

Implementation of active contour, using energy forces and constraints for segregation of the pixels of interest

Notifications You must be signed in to change notification settings

saeidrazavi/Active-Contours

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Active Contours

In this repo, we implement active contours, in order to stick to the desired object. we will say further how to implement it

Original image Active contour implementation

What is active contour?

Active contour is a type of segmentation technique which can be defined as use of energy forces and constraints for segregation of the pixels of interest from the image for further processing and analysis. Active contour described as active model for the process of segmentation

Theory behind active contour

we have a contour and our goal is to minimize "energy" of this contour . this energy contains three section .

$$E_{total}=E_{internals}+E_{external}$$


$$E_{external}=\Sigma((G_{x}(x_{i},y_{i}))^{2}+(G_{y}(x_{i},y_{i}))^{2}$$

$$ where \ G_{x} \ is \ gradient \ of \ x \ axis \ and \ G_{y} \ is \ gradient \ of \ y \ axis $$$$


$$E_{internal_{1}}=\Sigma({v_{i}-v_{i-1}}-d)^{2}$$

$$ where \ v_{i} \ is \ a \ tuple, \ consists \ of \ vertice \ coordinate. \ that \ is \ v_{i}=(x_{i},y_{i}) $$

we define $E_{internal_{1}}$ that is sensetive to distance from center of object . this parameter help us to make contour become closer to boarders. in order to avoid contour to pass object, we define another paramter that is senstive to gradian of image and as contour get closer, this paramter has bigger impact on it. this is beacuse avoiding contour pulled into object after reaching boarders . so we define :

$E_{internal_{2}}=\Sigma(\sqrt{\lvert{v_{i}-v_{center}}}^{2}\rvert-l)^{2}$ , where $l$ is the average distance between coordinates of vertices and center's coordinate

so to summarize our energy function is :

$E_{total}=\alpha_{0}\Sigma((G_{x}(x_{i},y_{i}))^{2}+(G_{y}(x_{i},y_{i}))^{2}+\alpha_{1}\Sigma(\left(\lvert{v_{i}-v_{i-1}}-d)^{2}\right\rvert)+\alpha_{2}\Sigma(\sqrt{\lvert{v_{i}-v_{center}}^{2}}\rvert-l)^{2}$

our task is to find minimum energy of snake. to find minimum energy we use dynamic programming (viterbi algorithm) : below we can see schematic of this algorithm:

Viterbi algorithm
Drawing

##Preprocess data

we use canny edge detection to calculate gradians of our image . after that i use two another method to remove background from forground :

  1. first we use guassin filter to remove noise from picture
  2. use filters.threshold_yen. this filter is very strong method to remove background noise from forground
Canny edge detection Gaussian filter Yen threshold filter
Drawing Drawing Drawing

choose initial contour over object

after choosing points all around the object , we determine initial contour(circular contour) . you can see the implementation of active contour in python file active_contour.py

Initial contour Active contour

About

Implementation of active contour, using energy forces and constraints for segregation of the pixels of interest

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages