Borda / pyImSegm

Image segmentation - general superpixel segmentation & center detection & region growing

Home Page:https://borda.github.io/pyImSegm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

low impact of GC pairwise regul.

Borda opened this issue · comments

Description

Investigate an issue with nearly zero impact of the pairwise term in GraphCut segmentation on small elements with high confidence belonging to one class. Even these peaces are composed only a few superpixels, and the regularisation is set on maximum, they do not disappear...

image

import os
from skimage import segmentation, io
import matplotlib.pylab as plt

import imsegm.utils.data_io as tl_io
import imsegm.pipelines as seg_pipe

name = 'Lh05-04'
PATH_IMAGES = os.path.join(tl_io.update_path('data_images'), 'langerhans_islets')
img = io.imread(os.path.join(PATH_IMAGES, 'image', name + '.jpg'))
annot = io.imread(os.path.join(PATH_IMAGES, 'annot', name + '.png'))
# plt.imshow(img), plt.contour(annot, colors='b')

img_red = img[:, :, 0]
SLIC_SIZE = 25
SLIC_REGUL = 0.2
DICT_FEATURES = {'color': ['mean', 'median']}

model_seg, list_slic, _, _ = seg_pipe.train_classif_color2d_slic_features([img_red], [annot], DICT_FEATURES, sp_size=SLIC_SIZE, sp_regul=SLIC_REGUL)

plt.figure()
plt.imshow(segmentation.mark_boundaries(img[800:900, 1100:1300], list_slic[0][800:900, 1100:1300], color=(1, 1, 1)))

segm_gc, seg_soft = seg_pipe.segment_color2d_slic_features_model_graphcut(img_red, model_seg, DICT_FEATURES, sp_size=SLIC_SIZE, sp_regul=SLIC_REGUL, gc_edge_type='ones', gc_regul=5000000.)

plt.figure()
plt.imshow(segm_gc), plt.contour(annot, colors='g'), plt.title('segmenatation')

plt.figure(figsize=(10, 3))
plt.subplot(1, 2, 1), plt.imshow(seg_soft[800:900, 1100:1300, 0]), plt.title('class 0'), plt.colorbar()
plt.subplot(1, 2, 2), plt.imshow(seg_soft[800:900, 1100:1300, 1]), plt.title('class 1'), plt.colorbar()

image
image

Way to reproduce

  • Code example
  • Relevant images
  • packages version (gco-wrapper==3.0.3)

Probably investigate some numerical instability in GraphCut, compute the global energy with and without assimilated the small region (bottom right).

"Have you looked at opengm? I'm pretty sure they have their own implementation. Opencv does, too..."
amueller/gco_python#18

probably can be solved by #21

ezoic increase your site revenue