forked from nyukat/BIRADS_classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
28 lines (23 loc) · 697 Bytes
/
utils.py
File metadata and controls
28 lines (23 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
from scipy import misc
import imageio
def load_images(image_path, view):
"""
Function that loads and preprocess input images
:param image_path: base path to image
:param view: L-CC / R-CC / L-MLO / R-MLO
:return: Batch x Height x Width x Channels array
"""
image = imageio.imread(image_path + view + '.png')
image = image.astype(np.float32)
normalize_single_image(image)
image = np.expand_dims(image, axis=0)
image = np.expand_dims(image, axis=3)
return image
def normalize_single_image(image):
"""
Normalize image in-place
:param image: numpy array
"""
image -= np.mean(image)
image /= np.std(image)