Ejemplo n.º 1
0
def load_and_f(path,files):
	#Mapping for lbp
	mapping = IP.getmapping(8)
	for k in range(len(files)):
		#Load file
		file = os.path.join(path,files[k])
		try:
			file = sio.loadmat(file)
			Mz = file['Mz']
			sz = file['sz']			
		except NotImplementedError:
			file = h5py.File(file)
			Mz = file['Mz'][()]
			sz = file['sz'][()]			
		
		#images
		
		#Combine mean and sd images
		image = Mz+sz
		#Grayscale normalization
		image = IP.localstandard(image,23,5,5,1)
		#image = image[20:-20,20:-20]
		#Feature extraction
		dict = {'R':9,'r':3,'wc':5,'wr':(5,5)}		
		f1,f2,f3,f4 = IP.MRELBP(image,8,dict['R'],dict['r'],dict['wc'],dict['wr'])
		
		#Normalization and mapping of the features f2(large neighbourhood lbp) and f4(radial lbp)
		
		#f1 = 1/np.linalg.norm(f1)*f1
		f2 = IP.maplbp(f2,mapping)
		#f2 = 1/np.linalg.norm(f2)*f2
		f3 = IP.maplbp(f3,mapping)
		#f3 = 1/np.linalg.norm(f3)*f3
		f4 = IP.maplbp(f4,mapping)
		#f4 = 1/np.linalg.norm(f4)*f4
		
		#Concatenate features
		f = np.concatenate((f1.T,f2.T,f3.T,f4.T),axis=0)
		try:
			features = np.concatenate((features,f),axis=1)
		except NameError:
			features = f
	
	return features