whaifree
82acfa83dc
- 新增dataprocessing.py脚本,实现图像数据处理功能,包括文件读取、格式转换、低对比度筛选等 - 新增H5Dataset类,用于加载和访问H5格式的图像数据集 - 在项目中配置远程服务器部署和代码自动上传 - 添加IDE配置文件,包括项目路径、模块管理、代码检查等设置
21 lines
693 B
Python
21 lines
693 B
Python
import numpy as np
|
|
import cv2
|
|
import os
|
|
from skimage.io import imsave
|
|
|
|
def image_read_cv2(path, mode='RGB'):
|
|
img_BGR = cv2.imread(path).astype('float32')
|
|
assert mode == 'RGB' or mode == 'GRAY' or mode == 'YCrCb', 'mode error'
|
|
if mode == 'RGB':
|
|
img = cv2.cvtColor(img_BGR, cv2.COLOR_BGR2RGB)
|
|
elif mode == 'GRAY':
|
|
img = np.round(cv2.cvtColor(img_BGR, cv2.COLOR_BGR2GRAY))
|
|
elif mode == 'YCrCb':
|
|
img = cv2.cvtColor(img_BGR, cv2.COLOR_BGR2YCrCb)
|
|
return img
|
|
|
|
def img_save(image,imagename,savepath):
|
|
if not os.path.exists(savepath):
|
|
os.makedirs(savepath)
|
|
# Gray_pic
|
|
imsave(os.path.join(savepath, "{}.png".format(imagename)),image) |