Modified active contour method in image processing

Viewed 218

I have images like this:

from skimage.segmentation import inverse_gaussian_gradient
from skimage.filters import meijering
from skimage import color
import numpy as np
import skimage.io
import cv2

# Load image, convert RGB to GRAY and then to float64
original = color.rgb2gray(skimage.io.imread("stack.jpg"))
image = skimage.img_as_float64(original)

Original image

And I want to get result like this (each worm has one unique color and is correctly recognized at intersections, ...): Result image

I tried Gaussian gradient:

# Make Gaussian gradient of image
gradient = inverse_gaussian_gradient(image)
gradient = gradient - np.amin(gradient)
gradient = gradient * (1 / np.amax(gradient))
gradient = np.uint8(gradient * 255)

Gaussian gradient

I also tried ridge detector on raw image and then also on gradient:

# Get ridges
ridge = meijering(gradient, sigmas=[1], mode='reflect', black_ridges=0)
ridge = np.uint8(ridge * 255)

Ridge detector on raw image Ridge detector on gradient image

And of course I tried Canny, too:

# Get edges
edges = feature.canny(image, sigma=3)
edges = np.uint8(edges * 255)

Canny

I want to use some or all of these filters to find all worms in image (join separated curves from filters, choose good curve path for each worm at intersections, ...). I think filters are doing pretty good job - I want to program modified active contour model that combines some features from them, but I do not know, how to program it. Active contour model can be parametrized by:

  • Worm's length (long white smooth curve in ridge detector)
  • Worm's smoothness - each curve can be approximated as smooth curve (spline/Bezier/..)
  • Worm's symmetry - it has always two identical mirrored curves at the edge (use somehow two long black spaces along long white curve in gradient)
  • Worm's same size except for its ends

Anybody, please, know, how to program it in Python/C++?

0 Answers
Related