Python 如何使用多级otsu阈值进行分水岭分割?

Python 如何使用多级otsu阈值进行分水岭分割?,python,opencv,image-segmentation,watershed,image-thresholding,Python,Opencv,Image Segmentation,Watershed,Image Thresholding,是否可以使用多级大津进行流域分割?我能够从OpenCV运行分水岭算法,使用二进制otsu阈值。分割输出还可以,但对我来说还不够好。我开始玩多层次的otsu阈值从skimage和分割区域看起来更好。我现在的问题是,如何使用多级otsu进行流域分割?由于多级otsu阈值中的片段通常只标有各自的类别(1-3),因此我无法从图像中获得特定的片段,这与分水岭不同,分水岭可以获得每个片段 多级大津代码: import matplotlib import matplotlib.pyplot as plt im

是否可以使用多级大津进行流域分割?我能够从OpenCV运行分水岭算法,使用二进制otsu阈值。分割输出还可以,但对我来说还不够好。我开始玩多层次的otsu阈值从skimage和分割区域看起来更好。我现在的问题是,如何使用多级otsu进行流域分割?由于多级otsu阈值中的片段通常只标有各自的类别(1-3),因此我无法从图像中获得特定的片段,这与分水岭不同,分水岭可以获得每个片段

多级大津代码:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from skimage.filters import threshold_multiotsu
from skimage import io
import skimage
from skimage.color import label2rgb

# Setting the font size for all plots.
matplotlib.rcParams['font.size'] = 9

# The input image.
img = skimage.io.imread('./images/test1.jpg', as_gray=True)

# Applying multi-Otsu threshold for the default value, generating
# three classes.

thresholds = threshold_multiotsu(img)
thresholds = skimage.filters.gaussian(thresholds, 3)

# Using the threshold values, we generate the three regions.
regions = np.digitize(img, bins=thresholds)


fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 3.5))

# Plotting the original image.
ax[0].imshow(img, cmap='gray')
ax[0].set_title('Original')
ax[0].axis('off')


# Plotting the Multi Otsu result.
ax[1].imshow(regions)
ax[1].set_title('Multi-Otsu result')
ax[1].axis('off')


plt.subplots_adjust()
plt.show()
谢谢你的帮助