python图像分割动态域值_对图像进行Skimage自适应阈值分割并得到输出

首先需要将scikit映像转换为opencv才能使用cv2.imwrite()。在

添加以下更改-from skimage import img_as_ubyte

import matplotlib.pyplot as plt

from skimage import data

from skimage.filters import threshold_otsu, threshold_adaptive

import cv2

image = data.page()

global_thresh = threshold_otsu(image)

binary_global = image > global_thresh

block_size = 35

binary_adaptive = threshold_adaptive(image, block_size, offset=10)

fig, axes = plt.subplots(nrows=3, figsize=(7, 8))

ax0, ax1, ax2 = axes

plt.gray()

ax0.imshow(image)

ax0.set_title('Image')

ax1.imshow(binary_global)

ax1.set_title('Global thresholding')

ax2.imshow(binary_adaptive)

ax2.set_title('Adaptive thresholding')

for ax in axes:

ax.axis('off')

plt.show()

img = img_as_ubyte(binary_global)

cv2.imshow("image", img)

cv2.waitKey(0)

然后可以使用img进行书写等

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值