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 |
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
we have a contour and our goal is to minimize "energy" of this contour . this energy contains three section .
we define
so to summarize our energy function is :
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 |
##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 :
- first we use guassin filter to remove noise from picture
- use
filters.threshold_yen
. this filter is very strong method to remove background noise from forground
Canny edge detection | Gaussian filter | Yen threshold filter |
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 |