【问题标题】:Otsu thresholding on RGBRGB 上的 Otsu 阈值处理
【发布时间】:2022-06-22 19:53:03
【问题描述】:

我正在尝试解决这个问题: “对每个通道(红色、绿色和蓝色)应用 Otsu 阈值,并将所有通道强度高于阈值的所有像素设置为上述步骤 1 中原始图像的相应通道均值。”

如何将 skimage.filters.threshold_otsu(image) 用于特定频道?

【问题讨论】:

  • 对于第一个通道(通常为红色),使用skimage.filters.threshold_otsu(image[...,0]) 为下一个通道更改 0 为 1,依此类推。
  • @MarkSetchell 谢谢!在此之后如何使用 io.imshow(image) 显示图片?应用过滤器后,我使用“image = image_filtered > thresh_1”,之后我只得到“图像数据的形状无效”或“不支持的 dtype”。

标签: python image-processing computer-vision scikit-image


【解决方案1】:

我不是在电脑前给你一个完整的答案,所以这里是粗略的......

您需要在 3 个通道上循环:

for channel in range(3):
    # Make handy synonym for this channel
    thisChannel = im[..., channel]

然后你需要每个通道的平均值:

    mean = np.mean(thisChannel)

那么你想要大津阈值:

    thresh = skimage.filters.threshold_otsu(thisChannel)

然后你想用平均值替换阈值以上的值:

    thisChannel[thisChannel>thresh] = mean

那么你就可以希望在循环结束后显示结果了。

【讨论】:

    猜你喜欢
    • 2020-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 2015-10-19
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多