-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsingle_point_gen.py
More file actions
28 lines (20 loc) · 1.13 KB
/
single_point_gen.py
File metadata and controls
28 lines (20 loc) · 1.13 KB
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
from skimage import morphology
import numpy as np
from PIL import Image
file_list = np.loadtxt('BRCA_dataset/brca_ds_train.txt', dtype = 'str')
for file in file_list:
# print(file)
img = np.array(Image.open('BRCA_dataset/images/' + file))
out_den = np.zeros([int(img.shape[0]/2) + 1, int(img.shape[1]/2) + 1])
labels = np.loadtxt( 'BRCA_dataset/labels/' + file.split('.png')[0] + '_gt_class_coords.txt' )
labels = labels/2
out_den[labels[:,0].astype(int), labels[:,1].astype(int)] = 1
# for type in [1,2,3]:
# # kde_den = np.zeros( [ int(img.shape[0]/2), int(img.shape[1]/2), 3] )
# labels = np.loadtxt( '/home/lchen/tensorf/Dataset-BRCA-M2C/labels/' + file.split('.png')[0] + '_gt_class_coords.txt' )
# labels = labels[labels[:,2] == type]
# labels = labels/2
# point_den = np.zeros([int(img.shape[0]/2) + 1, int(img.shape[1]/2) + 1])
# point_den[labels[:,0].astype(int), labels[:,1].astype(int)] = 1
# out_den[:,:,(type - 1)] = morphology.dilation( point_den , morphology.square(3))
np.save('point_single/' + file.split('.png')[0] + '.npy', out_den )