Ask Your Question

Revision history [back]

You might have some luck using the HFS segmentation technique built into the more recent versions:

import cv2
import numpy as np

img = cv2.imread("test-image.png")
# create engine
engine = cv2.hfs.HfsSegment_create(img.shape[0], img.shape[1])
engine.setSlicSpixelSize(50)
# perform segmentation
# now "res" is a matrix of indices
# change the second parameter to "True" to get a rgb image for "res"
res = engine.performSegmentCpu(img, True)