【问题标题】:How to select irregular shapes in a image如何选择图像中的不规则形状
【发布时间】:2017-03-31 20:12:00
【问题描述】:

使用 python 代码,我们能够创建图像片段,如屏幕截图所示。我们的要求是如何选择图像中的特定片段并为其应用不同的颜色?

以下是我们的python sn-p

from skimage.segmentation import felzenszwalb, slic,quickshift

from skimage.segmentation import mark_boundaries

from skimage.util import img_as_float

import matplotlib.pyplot as plt

from skimage import measure

from skimage import restoration

from skimage import img_as_float

image = img_as_float(io.imread("leaf.jpg"))
segments = quickshift(image, ratio=1.0, kernel_size=20, max_dist=10,return_tree=False, sigma=0, convert2lab=True, random_seed=42)

fig = plt.figure("Superpixels -- %d segments" % (500))
ax = fig.add_subplot(1, 1, 1)

ax.imshow(mark_boundaries(image, segments))

plt.axis("off")
plt.show()

【问题讨论】:

    标签: image image-processing image-segmentation


    【解决方案1】:

    这样做:

    seg_num = 64 # desired segment to be colored
    color = float64([1,0,0]) # red color
    image[segments == 64] = color # assign color to the segment
    

    【讨论】:

    • 谢谢哥们,你解决了我的问题...小变化。颜色 = np.float64([1,0,0])
    • 小帮助,根据鼠标点击如何更新特定段的颜色。
    【解决方案2】:

    你可以使用OpenCV python module - example

    【讨论】:

      猜你喜欢
      • 2018-01-20
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      相关资源
      最近更新 更多