706775662 发表于 2020-8-10 15:33:44

skimage库ImageCollection函数问题

from skimage import data_dir, io, transform, color, filters
import cv2 as cv
import numpy as np
import os


def convert_gray(f):
    rgb = io.imread(f)
    gray = cv.cvtColor(rgb, cv.COLOR_RGB2GRAY)
    ret, binary = cv.threshold(gray, 0, 255, cv.THRESH_BINARY|cv.THRESH_OTSU)
    # 大津法
    # binary = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 131, 0)
    # 自适应阈值
    return binary


str = r'F:\Study\ground fissure experiment\7.29\X5S\input\*.jpg'# 源文件目录
path = r'F:\ground fissure experiment\7.28\XT2\Input'# 源文件目录
# file_list = os.listdir(path)
path1 = r'F:\Study\ground fissure experiment\7.29\X5S\ostu'# 输出文件目录
coll = io.ImageCollection(str, load_func=convert_gray)
print(len(coll))
# for i in range(len(coll)):
# #io.imsave(r'F:\Study\ground fissure experiment\7.29\X5S\ostu\ostu_' + np.str(i) + '.jpg', coll)

本来是批量生成大津法后的图片,Input文件里只有10张图像,coll里有20张不知道为啥,有一张是重复的,是代码哪里出问题了吗

706775662 发表于 2020-8-10 15:37:16

Input 和 output

706775662 发表于 2020-8-12 13:01:46

{:5_104:}
页: [1]
查看完整版本: skimage库ImageCollection函数问题