python批量图像骨架提取

参考文章:OpenCV—python 图片细化(骨架提取)
安装库pip install scikit-image -i https://pypi.tuna.tsinghua.edu.cn/simple

import cv2
from skimage import morphology
import numpy as np
import os
rootdir=r'E:/cover'
print(rootdir)
list=os.listdir(rootdir)
for i in range (len(list)):
    path=os.path.join(rootdir,list[i])
    if os.path.isfile(path):
        print(path)

        image_name=path.split('/')[1].split('\\')[1]
        print(image_name)
        inputroot=rootdir+'/'
        print(inputroot+image_name)
        input_path=inputroot+image_name

        #读取图像
        img = cv2.imread(input_path,0)
        _,binary = cv2.threshold(img,200,255,cv2.THRESH_BINARY_INV)
        。。。

后续代码跳转python彩色图像骨架提取

你可能感兴趣的:(python)