def reconstruct_input(nparray): #split npbig = nparray[0:675].A npsmall = nparray[675:].A #reshape npbig_rs = npbig.reshape((15, 15, 3)) npsml_rs = npsmall.reshape((3, 3, 3)) #convert to cv img = ut.np2cv(npbig_rs.astype(np.uint8)) context = ut.np2cv(npsml_rs.astype(np.uint8)) return img, context
def reconstruct_input(nparray): #split npbig = nparray[0:675].A npsmall = nparray[675:].A #reshape npbig_rs = npbig.reshape((15,15,3)) npsml_rs = npsmall.reshape((3,3,3)) #convert to cv img = ut.np2cv(npbig_rs.astype(np.uint8)) context = ut.np2cv(npsml_rs.astype(np.uint8)) return img, context
def visualize(eigens): l1 = eigens[:, :, 0] l2 = eigens[:, :, 1] m1 = np.min(l1) m2 = np.min(l2) r1 = np.max(l1) - m1 r2 = np.max(l2) - m2 if r1 == 0: r1 = 1 if r2 == 0: r2 = 1 l1cv = ut.np2cv(np.array((1 - ((l1 - m1) / r1)) * 255, dtype="uint8")) l2cv = ut.np2cv(np.array((1 - ((l2 - m2) / r2)) * 255, dtype="uint8")) hg.cvNamedWindow("eigen value 1", 1) hg.cvNamedWindow("eigen value 2", 1) hg.cvShowImage("eigen value 1", l1cv) hg.cvShowImage("eigen value 2", l2cv) while True: k = hg.cvWaitKey(33) if k == " ": return if k == "x": exit()
def visualize(eigens): l1 = eigens[:, :, 0] l2 = eigens[:, :, 1] m1 = np.min(l1) m2 = np.min(l2) r1 = np.max(l1) - m1 r2 = np.max(l2) - m2 if r1 == 0: r1 = 1 if r2 == 0: r2 = 1 l1cv = ut.np2cv(np.array((1 - ((l1 - m1) / r1)) * 255, dtype='uint8')) l2cv = ut.np2cv(np.array((1 - ((l2 - m2) / r2)) * 255, dtype='uint8')) hg.cvNamedWindow('eigen value 1', 1) hg.cvNamedWindow('eigen value 2', 1) hg.cvShowImage('eigen value 1', l1cv) hg.cvShowImage('eigen value 2', l2cv) while True: k = hg.cvWaitKey(33) if k == ' ': return if k == 'x': exit()