鱼C论坛

 找回密码
 立即注册
查看: 1595|回复: 2

skimage库ImageCollection函数问题

[复制链接]
发表于 2020-8-10 15:33:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. from skimage import data_dir, io, transform, color, filters
  2. import cv2 as cv
  3. import numpy as np
  4. import os


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


  13. str = r'F:\Study\ground fissure experiment\7.29\X5S\input\*.jpg'  # 源文件目录
  14. path = r'F:\ground fissure experiment\7.28\XT2\Input'  # 源文件目录
  15. # file_list = os.listdir(path)
  16. path1 = r'F:\Study\ground fissure experiment\7.29\X5S\ostu'  # 输出文件目录
  17. coll = io.ImageCollection(str, load_func=convert_gray)
  18. print(len(coll))
  19. # for i in range(len(coll)):
  20. # #io.imsave(r'F:\Study\ground fissure experiment\7.29\X5S\ostu\ostu_' + np.str(i) + '.jpg', coll[i])
复制代码


本来是批量生成大津法后的图片,Input文件里只有10张图像,coll里有20张不知道为啥,有一张是重复的,是代码哪里出问题了吗
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-8-10 15:37:16 | 显示全部楼层
Input 和 output
1.PNG
2.PNG
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-8-12 13:01:46 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-25 10:59

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表