Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

low impact of GC pairwise regul. #11

Open
3 tasks done
Borda opened this issue Jul 12, 2018 · 4 comments
Open
3 tasks done

low impact of GC pairwise regul. #11

Borda opened this issue Jul 12, 2018 · 4 comments

Comments

@Borda
Copy link
Owner

Borda commented Jul 12, 2018

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)
@Borda
Copy link
Owner Author

Borda commented Aug 8, 2018

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

@Borda Borda added the bug label Aug 19, 2018
@Borda
Copy link
Owner Author

Borda commented Oct 8, 2018

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

@Borda
Copy link
Owner Author

Borda commented Apr 9, 2019

Have look at https://networkx.github.io

@Borda
Copy link
Owner Author

Borda commented Oct 12, 2020

probably can be solved by #21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant