如何读取CrackForest数据集?

问题描述

CrackForest数据集:https://github.com/cuilimeng/CrackForest-dataset

如何阅读groundTruth? * .mat文件

解决方法

导入scipy.io 将numpy导入为np 导入cv2

mat = scipy.io.loadmat('001.mat')

np_seg = mat ['groundTruth'] [0] [0] [0]

(y,x)= np.where(np_seg == 2)

np_seg [y,x] = 255

(y,x)= np.where(np_seg == 1)

np_seg [y,x] = 0

cv2.imwrite('./ 001.png',np_seg)

print()