Last active
October 4, 2018 06:51
-
-
Save vashineyu/de5e9dd26d639236ba11c6c395e4c79b to your computer and use it in GitHub Desktop.
special image reader, one-time usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bin2img_mix(file_path, channel_first = False): | |
w, h = 70, 70 | |
with open(file_path, 'rb') as f: | |
affine_info = np.fromfile(f, dtype='float64', count=6) | |
img1 = np.fromfile(f, dtype='single',count=245000) | |
img2 = np.fromfile(f, dtype='single',count=245000) | |
img2[img2 < -900] = -900 | |
if channel_first: | |
return img1.reshape(-1, w, h), img2.reshape(-1,w,h), affine_info | |
else: | |
return np.rollaxis(img1.reshape(-1,w,h), 0, 3), np.rollaxis(img2.reshape(-1,w,h), 0, 3), affine_info | |
data_dir = "/home/seanyu/cases/" | |
all_files = [os.path.join(data_dir, i) for i in os.listdir("/home/seanyu/cases/")] | |
a,b,c = bin2img_mix(all_files[4]) | |
# a = spect (70 x 70 x 50) | |
# b = ct (70 x 70 x 50) | |
# c = target (6 numbers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment