-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMatExtractor.py
More file actions
40 lines (35 loc) · 996 Bytes
/
MatExtractor.py
File metadata and controls
40 lines (35 loc) · 996 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
29
30
31
32
33
34
35
36
37
38
39
40
"""
Extract single segment images from .mat files found in
the surreal database.
"""
import scipy.io
class MatExtractor(object):
"""
path: is the full path where the .mat file is located
self.segments: Contains a list of the segments names
"""
def __init__(self, path):
#super(MatExtractor, self).__init__()
#self.arg = arg
self.path = path
self.mat = None
self.segments = None
self.avoid = ['__header__', '__version__', '__globals__']
self.__load_mat()
def __load_mat(self):
"""
Pseudo private class.... called 'name mangling'
Loads the segmentation mat file of SURREAL database
"""
print(self.path)
self.mat = scipy.io.loadmat(self.path)
self.segments = list(self.mat.keys())
for dropped in self.avoid:
self.segments.remove(dropped)
def extract_seg(self,index):
"""
index: A number from 0 to n
"""
index +=1
name = 'segm_'+str(index)
return(self.mat[name])