前段时间做实验的时候碰到一个‘.hdf5’的文件格式,之前并没有接触过这种文件格式。于是在网上查了一些相关资料后,成功完成了格式转换。
关于‘.hdf5’文件格式的介绍这里就不再叙述了,网上已经有很多相关的帖子写得很详细了。
在这里主要分享下自己的程序。
import os
import h5py
import numpy as np
from PIL import Image
import cv2
import scipy.io as io
def write_hdf5(image,groundTruth,outfile):
with h5py.File(outfile,'w') as f:
f['test_image'] = image
f['test_labels'] = groundTruth
image_test = 'COVERAGE/image/'
image_groundTruth = 'COVERAGE/mask/'
dataset_path = './con_hdf5/'
Nimgs = 8
channels = 3
height = 256
weight = 256
下面是获取数据集的函数,在这里使用的是COVERAGE这个数据集,关于数据集的介绍可以参考下面这篇文章:
https://www.researchgate.net/publication/307515766_COVERAGE_-_A_novel_database_for_copy-move_forgery_detection
def get_datasets(image_test,image_groundTruth):
imgs = []
groundTruth = []
for i i

最低0.47元/天 解锁文章
6310

被折叠的 条评论
为什么被折叠?



