This repository was archived by the owner on Feb 11, 2023. It is now read-only.
low impact of GC pairwise regul. #11
Open
Description
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...
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()
Way to reproduce
- Code example
- Relevant images
- packages version (gco-wrapper==3.0.3)