numero = 8 files = GetImagenes("dataset_gray") img = numero*2 A = v.imread('dataset_gray/'+files[img], 0) B = v.imread('dataset_gray/'+files[img+1], 0) particiones = 30 Ai = dividir(A, particiones, particiones) Bi = dividir(B, particiones, particiones) out = Ai for i in range(len(Ai[0])): for j in range(len(Ai)): Aieol = eolaplace(Ai[j][i]) Bieol = eolaplace(Bi[j][i]) Aisml = smlaplacian(Ai[j][i]) Bisml = smlaplacian(Bi[j][i]) Aieog = eogradient(Ai[j][i]) Bieog = eogradient(Bi[j][i]) Aivar = np.var(Ai[j][i]) Bivar = np.var(Bi[j][i]) caract = np.asarray([Aieol, Aieog, Aisml, Aivar, Bieol, Bieog, Bisml, Bivar])/norm imagefocus = vector.pred(caract) alpha = abs(Aivar/(Aivar+Bivar)) if abs(Aivar/(Aivar+Bivar)) > 0 else 0.5 out[j][i] = Ai[j][i] if imagefocus == 0 else Bi[j][i] if imagefocus == 1 else Ai[j][i]*(alpha) + Bi[j][i]*(1-alpha) v.imshow('1', unir(out))
except: pass response = None while len(files) != 0: Img1 = files.pop() Img2 = Img1.split('_') Img2[1] = '1' if Img2[1] == '2' else '2' Img2[3] = 'N.jpg' if Img2[3] == 'E.jpg' else 'E.jpg' if Img2[3] == 'N.jpg' else 'I.jpg' Img2 = Img2[0]+'_'+Img2[1]+'_'+Img2[2]+'_'+Img2[3] Img2 = files.pop(files.index(Img2)) clase = 0 if Img1[-5:-4] == 'E' else 1 if Img2[-5:-4] == 'E' else 2 Img1 = v.imread('OUT/'+Img1, 0) Img2 = v.imread('OUT/'+Img2, 0) Iaeol = eolaplace(Img1) Iaeog = eogradient(Img1) Iasml = smlaplacian(Img1) Iavar = varianza(Img1) Iamrp = morphgradient(Img1) Ibeol = eolaplace(Img2) Ibeog = eogradient(Img2) Ibsml = smlaplacian(Img2) Ibvar = varianza(Img2) Ibmrp = morphgradient(Img2) #print Iaeol, Iaeog, Iasml, Iavar, Iamrp, Ibeol, Ibeog, Ibsml, Ibvar, Ibmrp, clase print Iaeol, Ibeol Img1 = v.cvtColor(Img1, v.COLOR_GRAY2RGB) Img2 = v.cvtColor(Img2, v.COLOR_GRAY2RGB) v.circle(Img1,(len(Img1[0])/2,len(Img1)/2),len(Img1)/2,[0,0,255],3) if clase ==0 else v.circle(Img2,(len(Img1[0])/2,len(Img1)/2),len(Img1)/2,[0,0,255],3) if clase ==1 else 0 v.imshow('A', Img1)