我正在尝试将Open-CV中的超像素应用于超像素区域邻接图。
问题是,我希望从Open-CV获得的超像素标签在水平方向上彼此区分。
我使用的代码:
RGBimg = plt.imread("Image/Test (80).jpg")
img = sp.gaussian_filter(RGBimg, sigma=2, mode='nearest')
imgG = sk.rgb2grey(RGBimg)
SegData = cv2.ximgproc.createSuperpixelLSC(img, region_size=10)
SegData.iterate(num_iterations=100)
spLabel = SegData.getLabels()
# OpenCV superpixel labels:
[[0 0 3 3]
[0 0 3 3]
[1 1 4 4]
[1 1 4 4]
[2 2 5 5]
[2 2 5 5]]
# How I want the superpixel labels to be in:
[[0 0 1 1]
[0 0 1 1]
[2 2 3 3]
[2 2 3 3]
[4 4 5 5]
[4 4 5 5]]