OPTIMAS/trefide_pipeline.py
def play_3d(movie,
            gain=3,
            fr=60,
            offset=0,
            magnification=1,
            repeat=False,
            save = False,
            path = None):

    """ Render Video With OpenCV3 Library's Imshow"""
    fov_height, fov_width, nb_channels, num_frames = movie.shape
    maxmov = np.max(movie)
    looping=True
    terminated=False
    while looping:
        for t in range(num_frames):
            if magnification != 1:
                frame = cv2.resize(np.reshape(movie[:,:,:,t], (fov_height, -1), order='F'),
                                   None,
                                   fx=magnification,
                                   fy=magnification,
                                   interpolation=cv2.INTER_LINEAR)
            else:
                frame = np.reshape(movie[:,:,:,t], (fov_height, -1), order='F')
            if save:
                plt.imsave(str(path) + '/image{}.png'.format(t), frame, cmap='gray')
            # cv2.imshow('frame', (frame - offset) / maxmov*gain)
            if cv2.waitKey(int(1. / fr * 1000)) & 0xFF == ord('q'):
                looping = False
                terminated = True
                break
        if terminated:
            break
        looping=repeat
    cv2.waitKey(100)
    cv2.destroyAllWindows()
    for i in range(10):
        cv2.waitKey(100)
 Render Video With OpenCV3 Library's Imshow
Render Video With OpenCV3 Library's Imshow
Render Video With OpenCV3 Library ' s Imshow
def play_3d(movie,
            gain=3,
            fr=60,
            offset=0,
            magnification=1,
            repeat=False,
            save = False,
            path = None):
    fov_height, fov_width, nb_channels, num_frames = movie.shape
    maxmov = np.max(movie)
    looping=True
    terminated=False
    while looping:
        for t in range(num_frames):
            if magnification != 1:
                frame = cv2.resize(np.reshape(movie[:,:,:,t], (fov_height, -1), order='F'),
                                   None,
                                   fx=magnification,
                                   fy=magnification,
                                   interpolation=cv2.INTER_LINEAR)
            else:
                frame = np.reshape(movie[:,:,:,t], (fov_height, -1), order='F')
            if save:
                plt.imsave(str(path) + '/image{}.png'.format(t), frame, cmap='gray')
            if cv2.waitKey(int(1. / fr * 1000)) & 0xFF == ord('q'):
                looping = False
                terminated = True
                break
        if terminated:
            break
        looping=repeat
    cv2.waitKey(100)
    cv2.destroyAllWindows()
    for i in range(10):
        cv2.waitKey(100)
def play_3d ( movie , gain = 3 , fr = 60 , offset = 0 , magnification = 1 , repeat = False , save = False , path = None ) : fov_height , fov_width , nb_channels , num_frames = movie . shape maxmov = np . max ( movie ) looping = True terminated = False while looping : for t in range ( num_frames ) : if magnification != 1 : frame = cv2 . resize ( np . reshape ( movie [ : , : , : , t ] , ( fov_height , - 1 ) , order = 'F' ) , None , fx = magnification , fy = magnification , interpolation = cv2 . INTER_LINEAR ) else : frame = np . reshape ( movie [ : , : , : , t ] , ( fov_height , - 1 ) , order = 'F' ) if save : plt . imsave ( str ( path ) + '/image{}.png' . format ( t ) , frame , cmap = 'gray' ) if cv2 . waitKey ( int ( 1. / fr * 1000 ) ) & 0xFF == ord ( 'q' ) : looping = False terminated = True break if terminated : break looping = repeat cv2 . waitKey ( 100 ) cv2 . destroyAllWindows ( ) for i in range ( 10 ) : cv2 . waitKey ( 100 )
Render Video With OpenCV3 Library's Imshow
Render Video With OpenCV3 Library ' s Imshow
""" Render Video With OpenCV3 Library's Imshow""" # cv2.imshow('frame', (frame - offset) / maxmov*gain)
movie
gain
fr
offset
magnification
repeat
save
path