예제 #1
0
def tomography_callback(self):
    '''
    Real image acquisition-routine for tomographd mode. 
    '''
    # parameters
    nbr_steps = fg.config['tomo']['steps']+1
    fg.config['tomo']['done'] = False

    # get update (motor-movement direction)
    fg.config['tomo']['direction'] = -1 if fg.config['tomo']['posSTART'] >= fg.config['tomo']['posEND'] else 1
    if  fg.config['tomo']['posSTART'] ==  fg.config['tomo']['posEND']:
        logger.warning("Start and END-Pos are the same hence the system will take {} images at the same position.".format(nbr_steps))

    # iterate through tomography stack
    for imnbr in range(fg.config['tomo']['steps']+1):
        # actualize global number
        fg.config['tomo']['step_number'] = imnbr

        # to update measurement numbers indirectly
        if imnbr == fg.config['tomo']['steps']:
            fg.config['tomo']['done'] = True

        # take image with selected method
        toolbox.take_image(self)

        # move to next position 
        toolbox.move_motor(self, instance=None, motor_sel=fg.config['tomo']['motor'],
                motor_stepsize=fg.config['tomo']['stepsize'])
예제 #2
0
def autofocus_take_image(self, image_name_template, method):
    imvar = 0
    mythresh = 0.005  #has to be adjusted again
    myc = 0
    eps = 0.00001
    image_stack = []
    imvar_stack = []
    # neutralize with prior image to have more averaging? -> NOT IMPLEMENTED
    # take again if variance is too small until limit
    while (imvar < mythresh or myc == 4):
        image = toolbox.take_image(self, 'autofocus', image_name_template)
        # normalize image to reside in [0,1]
        help_image = image - np.min(image)
        help_image[help_image == 0] = eps
        help_image /= np.max(help_image)
        imvar = np.var(help_image)
        myc += 1
    image_stack = [
        image_stack,
        image,
    ]
    imvar_stack = [
        imvar_stack,
        imvar,
    ]
    # calc_image_quality -> TENENGRAD for now
    print("autofocus_take_image -> myc={}".format(myc))
    if myc == 4:
        image = image_stack[np.argmax(
            imvar_stack
        )]  #note: stack was created as list of arrays! -> so: access array
    imqual_res = imqual_metric(image, method=method)
    return image, imqual_res