示例#1
0
def thing(expos=0.008, gain=2, mycube='spare', TDI_flag = 0):
    """
    Process command line.  This is used
    """
    IlluminateWidth = 1920
    IlluminateHeight = 1080
    CameraWidth = 1000
    CameraHeight = 1000

    #MF = MaestroFunctions.Maestro_Functions()
    MF = MaestroFunctions()

    # process the numeric arguments
    int_time = float(expos)
    em_gain  = int(gain)


    """
    Set up imaging
    """

    MF.darkfield_off()
    print "the third argument is %s\n" % mycube
    MF.filter_goto(mycube)



    """
    set up release hardware
    """

    # initialize the release system
    print "Initializing release system\n"
    PI.py_clear_memory();
    if PI.py_illuminate_init(IlluminateWidth, IlluminateHeight, \
                                            CameraWidth, CameraHeight) < 0:
        sys.exit(-1)
    #end if

    # load an identity map for alignment parameters
    # CRUCIAL as for now!!!!!!!!!!!!
    PI.py_illuminate_alignment_load_identity()

    # enable release hardware
    PI.py_illuminate_enable()

    # generate an image
    """
    im = Image.open("test.png")

    if im.size[0] > im.size[1]:
        scaler = IlluminateWidth/(im.size[0])
        im = im.resize((IlluminateWidth, scaler*im.size[1]),Image.BICUBIC)
    #end if
    else:
        scaler = IlluminateHeight/(im.size[1])
        im = im.resize((scaler*im.size[0], IlluminateHeight),Image.BICUBIC)
    #end else
    im.convert('L')
    im.show()
    im.save("testout.png")
    """
    #im = Image.open("wyss_HD_R3.bmp")
    im = Image.open("../data/alignment_DMD5.bmp")
    #im = Image.open("George_Church_03.bmp")
    #im = Image.open("all_white.bmp")
    #im = im.rotate(90)
    im = im.transpose(Image.FLIP_LEFT_RIGHT)
    im = im.transpose(Image.FLIP_TOP_BOTTOM)
    #im = im.offset(50, -300)
    pix = im.load()

    mask_number = 0
    y_step = 1
    x_step = 1
    #PI.py_clear_mask(mask_number)
    PI.py_clear_framebuffer()
    #PI.py_clear_memory()    # must run this or you will get line artifacts!!!!

    PI.py_illum_mask_radius(0,mask_number)
    #done = 0
    for y in range(0,IlluminateHeight,y_step):
        for x in range(0,IlluminateWidth,x_step):
            #if pix[y,x] != 0:
            if pix[y,x] == 0:# and done == 0:
                #x = 1920/2
                #y = 1080/2
                PI.py_illuminate_point(x,y,mask_number)
                #print x, y
                #done = 1;
            #end if
        # end for
    # end for


    # expose image, so that it stays displayed
    #PI.py_illuminate_disable()
    PI.py_illuminate_expose()

    """
    start imaging
    """

    # open shutter
    MF.shutter_open()
    return 0
示例#2
0
MaestroF = MaestroFunctions()

#my_color = "spare"
my_color = "cy3"
LEN = 1000000
data_size = LEN#+4
MAX_BEADS_PERFRAME = 1000000

img_array = np.empty(data_size, dtype=np.uint16)
img_array2 = np.empty(data_size, dtype=np.uint16)
beadpos_xcol = np.empty(MAX_BEADS_PERFRAME, dtype=np.uint16)
beadpos_yrow = np.empty(MAX_BEADS_PERFRAME, dtype=np.uint16)
segmask_image =  np.empty(data_size, dtype=np.uint16)


MaestroF.darkfield_off()
MaestroF.filter_home()
MaestroF.filter_goto(my_color)
time.sleep(1)

MapFunc.init_illum()
MapFunc.light_all()

PC.py_snapPtr(img_array, .35,80,my_color)
#invert for images where beads are lighter than background
img_array = 16383 - img_array # invert the 14 bit image
num_beads = FO.find_objects(1000, 1000, \
                            img_array, \
                            beadpos_xcol, beadpos_yrow, \
                            segmask_image)
print("The number of beads found: %d" % num_beads)
示例#3
0
def main(argv=None):
    
    """
    Process command line
    """
    IlluminateWidth = 1920
    IlluminateHeight = 1080
    CameraWidth = 1000
    CameraHeight = 1000
    
    if argv is None:
        argv = sys.argv
    # end if
    argc = len(argv)
    print "newline\n"
    print "There are %d arguments\n" % argc     
    # make sure we have the correct number of arguments */
    if  (argc < 3) or (argc > 5):
        #testDMD.show_usage()
        show_usage()
        sys.exit(-1)
    #end if
    
    MF = MaestroFunctions()
    
    # process the numeric arguments 
    int_time = float(argv[1])
    em_gain  = int(argv[2])

    # process cube name 
    if argc < 4:
        mycube = DEFAULT_CUBE
    # end if
    else:
        mycube = str(argv[3])
        
    # end else

    # process TDI flag
    if argc < 5:
        TDI_flag = DEFAULT_TDI
    # end if
    else:
        TDI_flag = int(argv[4])
    # end else

    """
        Set up imaging
    """

    MF.darkfield_off() 
    print "the third argument is %s\n" % mycube 
    MF.filter_goto(mycube)



    """
        set up release hardware
    """

    # initialize the release system 
    print "Initializing release system\n"
    # if PI.py_illuminate_init( IlluminateWidth, \
    #                           IlluminateHeight, \
    #                           CameraWidth, \
    #                           CameraHeight) < 0:
     #   sys.exit(-1)
    #end if
 
    # load an identity map for alignment parameters 
    #PI.py_illuminate_alignment_load_identity()

    # enable release hardware 
    #PI.py_illuminate_enable()
    #PI.py_clear_memory()        # must run this or you will get line artifacts!!!!
    # generate an image 
    #PI.generate_image()
    
    
    # expose image, so that it stays displayed 
    #PI.py_illuminate_expose()

    """
    start imaging
    """

    # open shutter
    MF.shutter_open()

    # start imaging
    myargc = 3;
    myargv = ['0' ,'0','c','d']    # create a list of length 4
    myargv[2] = argv[1]
    myargv[3] = argv[2]

    # start in a separate process to avoid crash if window is closed
    
    pid = os.fork()        # this is a UNIX only syscall
    if pid == 0:
        #child process
        PC.py_camera_live(myargc, myargv, TDI_flag)
        return 0;
    # end if

    # in parent process 
    # wait for child to terminate 
    #os.waitpid(pid,os.WNOHANG)     # this option WNOHANG is UNIX only
    os.wait()
    
    # close shutter
    MF.shutter_close()

    return 0
示例#4
0
def main(argv=None):
    
    """
        Process command line
    """
    IlluminateWidth = 1920
    IlluminateHeight = 1080
    CameraWidth = 1000
    CameraHeight = 1000
    
    if argv is None:
        argv = sys.argv
    # end if
    argc = len(argv)
    print "newline\n"
    print "There are %d arguments\n" % argc     
    # make sure we have the correct number of arguments */
    if  (argc < 3) or (argc > 5):
        show_usage()
        sys.exit(-1)
    #end if
    
    MF = MaestroFunctions()
    
    # process the numeric arguments 
    int_time = float(argv[1])
    em_gain  = int(argv[2])

    # process cube name 
    if argc < 4:
        mycube = DEFAULT_CUBE
    # end if
    else:
        mycube = str(argv[3])
        
    # end else

    # process TDI flag
    if argc < 5:
        TDI_flag = DEFAULT_TDI
    # end if
    else:
        TDI_flag = int(argv[4])
    # end else

    """
        Set up imaging
    """

    MF.darkfield_off() 
    print "the third argument is %s\n" % mycube 
    MF.filter_goto(mycube)



    """
        set up release hardware
    """

    # initialize the release system 
    print "Initializing release system\n"
    PI.py_clear_memory();
    if PI.py_illuminate_init(IlluminateWidth, IlluminateHeight, \
                            CameraWidth, CameraHeight) < 0:
        sys.exit(-1)
    #end if
 
    # load an identity map for alignment parameters 
    PI.py_illuminate_alignment_load_identity()
   
    # enable release hardware 
    PI.py_illuminate_enable()

    # generate an image
    """
    im = Image.open("test.png")
  
    if im.size[0] > im.size[1]:
        scaler = IlluminateWidth/(im.size[0])
        im = im.resize((IlluminateWidth, scaler*im.size[1]),Image.BICUBIC)
    #end if
    else:
        scaler = IlluminateHeight/(im.size[1])
        im = im.resize((scaler*im.size[0], IlluminateHeight),Image.BICUBIC)
    #end else
    im.convert('L')
    im.show() 
    im.save("testout.png")
    """
    #im = Image.open("wyss_HD_R3.bmp")
    #im = Image.open("alignment_DMD.bmp")
    im = Image.open("George_Church_03.bmp")
    #im = Image.open("all_white.bmp")
    #im = im.rotate(90)
    im = im.transpose(Image.FLIP_LEFT_RIGHT)
    im = im.transpose(Image.FLIP_TOP_BOTTOM)
    #im = im.offset(50, -300)
    pix = im.load()
    
    mask_number = 0
    y_step = 1
    x_step = 1 
    #PI.py_clear_mask(mask_number)
    PI.py_clear_framebuffer()
    #PI.py_clear_memory()    # must run this or you will get line artifacts!!!!
  
    PI.py_illum_mask_radius_dmd(0,mask_number)
        
    for y in range(0,IlluminateHeight,y_step):
        for x in range(0,IlluminateWidth,x_step):
            #if pix[y,x] != 0:
            if pix[y,x] == 0:
                PI.py_illuminate_point(x,y,mask_number)
            #end if
        # end for
    # end for
 

    # expose image, so that it stays displayed 
    #PI.py_illuminate_disable()
    PI.py_illuminate_expose()

    """
    start imaging
    """

    # open shutter
    MF.shutter_open()

    # start imaging
    myargc = 3;
    myargv = ['0' ,'0','c','d']    # create a list of length 4
    myargv[2] = argv[1]
    myargv[3] = argv[2]

    # start in a separate process to avoid crash if window is closed
    
    #pid = os.fork()        # this is a UNIX only syscall
    #if pid == 0:
        #child process
     #   PC.py_camera_live(myargc, myargv, TDI_flag)
      #  return 0;
    # end if

    # in parent process 
    # wait for child to terminate 
    #os.waitpid(pid,os.WNOHANG)     # this option WNOHANG is UNIX only
    #os.wait()
    
    # close shutter
    #MF.shutter_close()
    return 0