1. 原始数据:从BrainWeb 网站上下载的.rawb类型数据;
2. 目标:读取原始文件中的二进制文件,将其转换成bmp图像文件,然后保存起来;
3. 主函数代码:
# This code is used to transform the unknown type file: *.rawb, into BMP files
# in order to get the groundtruth and original brain files
# Date: 2018/7/28
# Author: Dongdong Ma
import tensorflow as tf
import struct
import binascii
import re
import scipy.misc
import numpy as np
import getpath2
# fileID = 14
for fileID in range(10,12):
f, savepath = getpath2.getpath(fileID)
data = f.readlines() # dd include just a line values
rows = 217
cols = 181
Img_mat = np.ones((1,rows*cols),dtype = 'uint8')
length = len(data)
sumpixels = 0
counter = 0
layer = 0
# print (data)
for i in range(0,length):
sumpixels = sumpixels + len(data[i])
# print len(data[i]),i
line_data = data[i]
line_data_str = bina