Example #1
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """
        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()
            # Keep old parameters
            self.cfg["param"] = cfg_open(old_work_dir + "index.cfg", "rb")["param"]
            # Also need to clone input_0_sel.png in case the user is running
            # with new parameters but on the same subimage.
            shutil.copy(old_work_dir + "input_0_sel.png", self.work_dir + "input_0_sel.png")

        # Set undefined parameters to default values
        self.cfg["param"] = dict(self.default_param, **self.cfg["param"])
        # Generate a new timestamp
        self.timestamp = int(100 * time.time())

        # Reset cropping parameters if running with a different subimage
        if msg == "different subimage":
            self.cfg["param"]["x0"] = None
            self.cfg["param"]["y0"] = None
            self.cfg["param"]["x"] = None
            self.cfg["param"]["y"] = None

        return self.tmpl_out("params.html")
Example #2
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """
        if newrun:            
            old_work_dir = self.work_dir
            self.clone_input()
            # Keep old parameters
            self.cfg['param'] = cfg_open(old_work_dir 
                + 'index.cfg', 'rb')['param']
            # Also need to clone input_0_sel.png in case the user is running
            # with new parameters but on the same subimage.
            shutil.copy(old_work_dir + 'input_0_sel.png',
                self.work_dir + 'input_0_sel.png')

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        # Generate a new timestamp
        self.timestamp = int(100*time.time())
        
        # Reset cropping parameters if running with a different subimage
        if msg == 'different subimage':
            self.cfg['param']['x0'] = None
            self.cfg['param']['y0'] = None
            self.cfg['param']['x'] = None
            self.cfg['param']['y'] = None
        
        return self.tmpl_out('params.html')
Example #3
0
    def input_points_file(self):
        """
        write the poly points in a file
        """      

        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else :
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        ### ....................

        points = self.work_dir + "line_primitives.dat"
        ofile = file(points, "w")

        lines = json.loads( self.cfg['param']['poly'] )

        ofile.writelines("%i\n" % len(lines) )

        for ii in range(0, len(lines)) :

            ofile.writelines("%i\n" % len(lines[ii]) )
            ofile.writelines("%i %i \n" % (x, y) for (x, y) in lines[ii] )

        ofile.close()
Example #4
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """
        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()
            # Keep old parameters
            self.cfg['param'] = cfg_open(old_work_dir + 'index.cfg',
                                         'rb')['param']
            # Also need to clone input_0_sel.png in case the user is running
            # with new parameters but on the same subimage.
            shutil.copy(old_work_dir + 'input_0_sel.png',
                        self.work_dir + 'input_0_sel.png')

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        # Generate a new timestamp
        self.timestamp = int(100 * time.time())

        # Reset cropping parameters if running with a different subimage
        if msg == 'different subimage':
            self.cfg['param']['x0'] = None
            self.cfg['param']['y0'] = None
            self.cfg['param']['x'] = None
            self.cfg['param']['y'] = None

        return self.tmpl_out('params.html')
Example #5
0
    def addpoint(self, **kwargs):
        """
        draw the polygon 
        """      

        pfile = self.old_work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']


        if self.old_work_dir != self.work_dir:
            shutil.copy(self.old_work_dir + 'input_0.png', \
                        self.work_dir     + 'input_0.png')


        self.cfg['param']['zoom'] = int(self.check_zoom( kwargs['zoom'],      \
                                                         self.cfg['param'] ))

        self.cfg['param']['zoom_default'] = int(self.get_zoom_default(        \
                                                           self.cfg['param'] ))

        [ self.cfg['param']['scrollx'], self.cfg['param']['scrolly'] ] =      \
                     self.check_scroll( kwargs['scrollx'], kwargs['scrolly'], \
                     self.cfg['param']['zoom'], self.cfg['param'] )


        if (0 <= float(self.cfg['param']['sigma']) <= 30):
            self.cfg['param']['sigma'] = float( kwargs['sigma'] )

        if int(kwargs['iterations']) > 0:
            self.cfg['param']['iterations'] = int( kwargs['iterations'] )
        else: 
            self.cfg['param']['iterations'] = (-1)*int( kwargs['iterations'] )

        self.cfg['param']['snake_structure'] = int( kwargs['structure'] )
        self.cfg['param']['snake_balloon'] = int( kwargs['balloon'] )


    ## .................

       # Check action (VALUE)
        if 'action' in kwargs:
            self.cfg['param']['action'] = self.check_action( kwargs['action'], \
                                             kwargs['poly'], self.cfg['param'] )
        else :
            self.cfg['param']['poly'] = self.check_poly( kwargs['poly'], 
                                         kwargs['point.x'], kwargs['point.y'], \
                                         self.cfg['param'])

        self.cfg.save()        

        self.draw_poly( self.cfg['param'] )

        return self.tmpl_out('params.html')
Example #6
0
    def addpoint(self, **kwargs):
        """
        draw the polygon 
        """

        pfile = self.old_work_dir + 'index.cfg'

        if os.path.isfile(pfile):
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']

        if self.old_work_dir != self.work_dir:
            shutil.copy(self.old_work_dir + 'input_0.png', \
                        self.work_dir     + 'input_0.png')


        self.cfg['param']['zoom'] = int(self.check_zoom( kwargs['zoom'],      \
                                                         self.cfg['param'] ))

        self.cfg['param']['zoom_default'] = int(self.get_zoom_default(        \
                                                           self.cfg['param'] ))

        [ self.cfg['param']['scrollx'], self.cfg['param']['scrolly'] ] =      \
                     self.check_scroll( kwargs['scrollx'], kwargs['scrolly'], \
                     self.cfg['param']['zoom'], self.cfg['param'] )

        if (0 <= float(self.cfg['param']['sigma']) <= 30):
            self.cfg['param']['sigma'] = float(kwargs['sigma'])

        if int(kwargs['iterations']) > 0:
            self.cfg['param']['iterations'] = int(kwargs['iterations'])
        else:
            self.cfg['param']['iterations'] = (-1) * int(kwargs['iterations'])

        self.cfg['param']['snake_structure'] = int(kwargs['structure'])
        self.cfg['param']['snake_balloon'] = int(kwargs['balloon'])

        ## .................

        # Check action (VALUE)
        if 'action' in kwargs:
            self.cfg['param']['action'] = self.check_action( kwargs['action'], \
                                             kwargs['poly'], self.cfg['param'] )
        else:
            self.cfg['param']['poly'] = self.check_poly( kwargs['poly'],
                                         kwargs['point.x'], kwargs['point.y'], \
                                         self.cfg['param'])

        self.cfg.save()

        self.draw_poly(self.cfg['param'])

        return self.tmpl_out('params.html')
Example #7
0
    def params(self, newrun=False, msg=None):
        """
        configure the algo execution
        """
        
        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()
            
            # Keep old parameters
            self.cfg['param'] = cfg_open( old_work_dir + 'index.cfg', 'rb')['param']

        return self.tmpl_out("params.html")
Example #8
0
    def params(self, newrun=False, msg=None):
        """
        configure the algo execution
        """

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()

            # Keep old parameters
            self.cfg['param'] = cfg_open(old_work_dir + 'index.cfg',
                                         'rb')['param']

        return self.tmpl_out("params.html")
Example #9
0
    def input_points_file(self):
        """
        write the poly points in a file
        """      

        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else :
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        points = self.work_dir + "points.txt"

        ofile = file(points, "w")
        ofile.writelines("%i %i \n" % (x, y)  \
                       for (x, y) in json.loads( self.cfg['param']['poly'] ) )
        ofile.close()

        shutil.copy(points, self.work_dir + 'input_%i' % 0 + '.cn')
Example #10
0
    def input_points_file(self):
        """
        write the poly points in a file
        """

        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile(pfile):
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else:
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        points = self.work_dir + "points.txt"

        ofile = file(points, "w")
        ofile.writelines("%i %i \n" % (x, y)  \
                       for (x, y) in json.loads( self.cfg['param']['poly'] ) )
        ofile.close()

        shutil.copy(points, self.work_dir + 'input_%i' % 0 + '.cn')
Example #11
0
    def run_algo(self, stdout=None):
        """
        The core algo runner
        could also be called by a batch processor
        this one needs no parameter
        """
        timeout = False

        # Read data from configuration file
        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else :
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        
                   
        lens_distortion = self.run_proc(['lens_distortion_estimation',        \
                                         'input_0.bmp',                       \
                                         'output_0.bmp',                      \
                                         'line_primitives.dat',               \
                                         'output_0.dat',                      \
                                         str(self.cfg['param']['x_center']),  \
                                         str(self.cfg['param']['y_center']),  \
                                         str(self.cfg['param']['optimized'])],\
                                          stdout=stdout, stderr=stdout )

        self.wait_proc( lens_distortion, timeout )

        # .............
        
        in1 = self.work_dir + 'output_0.bmp'
        out1 = self.work_dir + 'output_0.png'
        
        cmdrun = ['convert'] + [in1] + [out1]
        subprocess.Popen( cmdrun ).wait()        
        
        # .............
        
        self.cfg.save()
        return
Example #12
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """
        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()
            # Keep old parameters
            self.cfg['param'] = cfg_open(old_work_dir
                + 'index.cfg', 'rb')['param']
            # Also need to clone maskcommands.txt to keep the mask
            if os.path.isfile(old_work_dir + 'maskcommands.txt'):
                shutil.copy(old_work_dir + 'maskcommands.txt',
                    self.work_dir + 'maskcommands.txt')

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        # Generate a new timestamp
        self.timestamp = int(100*time.time())
        self.rendermask()
        return self.tmpl_out('params.html')
Example #13
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """
        if newrun:
            old_work_dir = self.work_dir
            self.clone_input()
            # Keep old parameters
            self.cfg['param'] = cfg_open(old_work_dir
                + 'index.cfg', 'rb')['param']
            # Also need to clone maskcommands.txt to keep the mask
            if os.path.isfile(old_work_dir + 'maskcommands.txt'):
                shutil.copy(old_work_dir + 'maskcommands.txt',
                    self.work_dir + 'maskcommands.txt')

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        # Generate a new timestamp
        self.timestamp = int(100*time.time())

        self.rendermask()
        return self.tmpl_out('params.html')
Example #14
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """

        if self.first_run:
            self.orig_work_dir = self.work_dir
            self.first_run = False
        
        self.old_work_dir = self.work_dir
        
        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        img = image(self.work_dir + 'input_0.bmp')
        (xsize, ysize) = img.size       
       
        self.cfg['param']['img_width'] = xsize
        self.cfg['param']['img_height'] = ysize 
        
        self.cfg['param']['x_center'] = xsize/2.0
        self.cfg['param']['y_center'] = ysize/2.0 

        self.cfg['param']['zoom_default'] = int(self.get_zoom_default( \
                                                self.cfg['param'] ))

        if newrun:      
            self.clone_input()
            
            # Keep old parameters
            self.cfg['param'] = \
                      cfg_open(self.old_work_dir + 'index.cfg', 'rb')['param']


        self.cfg.save()

        self.draw_poly( self.cfg['param'] )
        return self.tmpl_out('params.html')
Example #15
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """

        if self.first_run:
            self.orig_work_dir = self.work_dir
            self.first_run = False

        self.old_work_dir = self.work_dir

        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        if newrun:

            self.clone_input()

            # Keep old parameters
            self.cfg['param'] = \
                      cfg_open(self.old_work_dir + 'index.cfg', 'rb')['param']

        img = image(self.work_dir + 'input_0.png')
        (xsize, ysize) = img.size

        self.cfg['param']['img_width'] = xsize
        self.cfg['param']['img_height'] = ysize

        self.cfg['param']['zoom_default'] = int(self.get_zoom_default( \
                                                self.cfg['param'] ))

        if msg == 'use the output points':
            shutil.copy(self.old_work_dir + 'output_0.cn', \
                        self.work_dir     + 'input_0.cn')

            lst = []

            ofile = open(self.work_dir + 'input_0.cn', 'r')

            line = ofile.readline()
            line = ofile.readline()

            ii = 0

            while line:
                if ii > -1:
                    vec = line.split(" ")
                    vec[1] = vec[1][0:len(vec[1]) - 1]

                    lst += [[int(vec[0]), self.cfg['param']['img_height'] \
                                        - int(vec[1])]]
                    ii = 0

                ii += 1
                line = ofile.readline()

            self.cfg['param']['poly'] = json.dumps(lst)

        self.cfg.save()

        self.draw_poly(self.cfg['param'])

        return self.tmpl_out('params.html')
Example #16
0
    def run_algo(self, stdout=None):
        """
        The core algo runner
        could also be called by a batch processor
        this one needs no parameter
        """

        timeout = False

        # Read data from configuration file
        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile(pfile):
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else:
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        animate_inc = 20
        niter = int((self.cfg['param']['iterations'] / animate_inc)) + 1

        nn = 0
        oimg = ''

        for ii in range(0, niter):

            nn = ii * animate_inc

            if nn < 100:
                oimg = 'output_0' + str(nn)
            else:
                oimg = 'output_' + str(nn)

            # Perform the morphological snake
            morpho_snake = self.run_proc(['morphological_snake',  \
               '-I', 'input_0.png',                             \
               '-O', oimg +'_0.png',                            \
               '-C', 'input_0.cn',                              \
               '-F', 'output_0.cn',                             \
               '-S', str(self.cfg['param']['sigma']),           \
               '-T', str(self.cfg['param']['snake_structure']), \
               '-N', str(nn),                                   \
               '-B', str(self.cfg['param']['snake_balloon']),   \
               '-R', str(self.cfg['param']['snake_balloon_diff_radius']),  \
               '-P', str(self.cfg['param']['snake_edge_detector_threshold'])], \
                     stdout=stdout, stderr=stdout )

        self.wait_proc(morpho_snake, timeout)

        if self.cfg['param']['iterations'] < 100:
            oimg = 'output_0' + str(self.cfg['param']['iterations'])
        else:
            oimg = 'output_' + str(self.cfg['param']['iterations'])


        morpho_snake = self.run_proc(['morphological_snake',  \
             '-I', 'input_0.png',                             \
             '-O', oimg +'_0.png',                            \
             '-C', 'input_0.cn',                              \
             '-F', 'output_0.cn',                             \
             '-S', str(self.cfg['param']['sigma']),           \
             '-T', str(self.cfg['param']['snake_structure']), \
             '-N', str(self.cfg['param']['iterations']),      \
             '-B', str(self.cfg['param']['snake_balloon']),   \
             '-R', str(self.cfg['param']['snake_balloon_diff_radius']),  \
             '-P', str(self.cfg['param']['snake_edge_detector_threshold'])], \
                   stdout=stdout, stderr=stdout )

        self.wait_proc(morpho_snake, timeout)


        shutil.copy( self.work_dir + oimg +'_0.png', \
                     self.work_dir + 'output_0.png' )

        cmdrun = ['convert', '-delay', '100', '-loop', '0', ' ', \
                  self.work_dir + 'output_*_0.png',              \
                  self.work_dir + 'animate_output.gif']

        subprocess.Popen(cmdrun).wait()


        self.cfg['param']['command_line'] = 'morphological_snake ' +          \
             ' -I ' + ' input_0.png' + ' -O ' + ' output_0.png' +             \
             ' -C ' + 'input_0.cn' + ' -F ' + 'output_0.cn' +                 \
             ' -S ' + str(self.cfg['param']['sigma']) +                       \
             ' -T ' + str(self.cfg['param']['snake_structure']) +             \
             ' -N ' + str(self.cfg['param']['iterations']) +                  \
             ' -B ' + str(self.cfg['param']['snake_balloon']) +               \
             ' -R ' + str(self.cfg['param']['snake_balloon_diff_radius']) +   \
             ' -P ' + str(self.cfg['param']['snake_edge_detector_threshold'])

        self.cfg.save()
        return
Example #17
0
    def run_algo(self, stdout=None):
        """
        The core algo runner
        could also be called by a batch processor
        this one needs no parameter
        """
        
        timeout = False

        # Read data from configuration file
        pfile = self.work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']
        else :
            self.cfg['param'] = dict(self.default_param, **self.cfg['param'])
        
       
        animate_inc = 20
        niter = int( (self.cfg['param']['iterations']/animate_inc) ) + 1

        nn = 0
        oimg = ''

        for ii in range(0, niter) :
            
            nn = ii * animate_inc
            
            if nn < 100 :
                oimg = 'output_0' + str(nn) 
            else :
                oimg = 'output_' + str(nn)

            # Perform the morphological snake            
            morpho_snake = self.run_proc(['morphological_snake',  \
               '-I', 'input_0.png',                             \
               '-O', oimg +'_0.png',                            \
               '-C', 'input_0.cn',                              \
               '-F', 'output_0.cn',                             \
               '-S', str(self.cfg['param']['sigma']),           \
               '-T', str(self.cfg['param']['snake_structure']), \
               '-N', str(nn),                                   \
               '-B', str(self.cfg['param']['snake_balloon']),   \
               '-R', str(self.cfg['param']['snake_balloon_diff_radius']),  \
               '-P', str(self.cfg['param']['snake_edge_detector_threshold'])], \
                     stdout=stdout, stderr=stdout )


        self.wait_proc( morpho_snake, timeout )


        if self.cfg['param']['iterations'] < 100 :
            oimg = 'output_0' + str(self.cfg['param']['iterations']) 
        else :
            oimg = 'output_' + str(self.cfg['param']['iterations'])


        morpho_snake = self.run_proc(['morphological_snake',  \
             '-I', 'input_0.png',                             \
             '-O', oimg +'_0.png',                            \
             '-C', 'input_0.cn',                              \
             '-F', 'output_0.cn',                             \
             '-S', str(self.cfg['param']['sigma']),           \
             '-T', str(self.cfg['param']['snake_structure']), \
             '-N', str(self.cfg['param']['iterations']),      \
             '-B', str(self.cfg['param']['snake_balloon']),   \
             '-R', str(self.cfg['param']['snake_balloon_diff_radius']),  \
             '-P', str(self.cfg['param']['snake_edge_detector_threshold'])], \
                   stdout=stdout, stderr=stdout )

        self.wait_proc( morpho_snake, timeout )


        shutil.copy( self.work_dir + oimg +'_0.png', \
                     self.work_dir + 'output_0.png' )         

        cmdrun = ['convert', '-delay', '100', '-loop', '0', ' ', \
                  self.work_dir + 'output_*_0.png',              \
                  self.work_dir + 'animate_output.gif'] 
        
        subprocess.Popen( cmdrun ).wait()


        self.cfg['param']['command_line'] = 'morphological_snake ' +          \
             ' -I ' + ' input_0.png' + ' -O ' + ' output_0.png' +             \
             ' -C ' + 'input_0.cn' + ' -F ' + 'output_0.cn' +                 \
             ' -S ' + str(self.cfg['param']['sigma']) +                       \
             ' -T ' + str(self.cfg['param']['snake_structure']) +             \
             ' -N ' + str(self.cfg['param']['iterations']) +                  \
             ' -B ' + str(self.cfg['param']['snake_balloon']) +               \
             ' -R ' + str(self.cfg['param']['snake_balloon_diff_radius']) +   \
             ' -P ' + str(self.cfg['param']['snake_edge_detector_threshold'])


        self.cfg.save()
        return
Example #18
0
    def params(self, newrun=False, msg=None):
        """
        Configure the algo execution
        """

        if self.first_run:
            self.orig_work_dir = self.work_dir
            self.first_run = False
        
        self.old_work_dir = self.work_dir
        
        # Set undefined parameters to default values
        self.cfg['param'] = dict(self.default_param, **self.cfg['param'])

        if newrun:      

            self.clone_input()
            
            # Keep old parameters
            self.cfg['param'] = \
                      cfg_open(self.old_work_dir + 'index.cfg', 'rb')['param']
            


        img = image(self.work_dir + 'input_0.png')
        (xsize, ysize) = img.size       
       
        self.cfg['param']['img_width'] = xsize
        self.cfg['param']['img_height'] = ysize 
        
        self.cfg['param']['zoom_default'] = int(self.get_zoom_default( \
                                                self.cfg['param'] ))

        if msg == 'use the output points':
            shutil.copy(self.old_work_dir + 'output_0.cn', \
                        self.work_dir     + 'input_0.cn')

            lst = []
            
            ofile = open(self.work_dir + 'input_0.cn','r')

            line = ofile.readline()
            line = ofile.readline()
            
            ii = 0
 
            while line:
                if ii > -1:
                    vec = line.split(" ")
                    vec[1] = vec[1][0:len(vec[1])-1]

                    lst += [[int(vec[0]), self.cfg['param']['img_height'] \
                                        - int(vec[1])]]
                    ii = 0
                    
                ii += 1   
                line = ofile.readline()
 
 
            self.cfg['param']['poly'] = json.dumps( lst )


        self.cfg.save()

        self.draw_poly( self.cfg['param'] )

        return self.tmpl_out('params.html')
Example #19
0
    def addpoint(self, **kwargs):
        """
        draw the polygon 
        """      
        
        pfile = self.old_work_dir + 'index.cfg'

        if os.path.isfile( pfile ) :
            self.cfg['param'] = cfg_open(pfile, 'rb')['param']


        if self.old_work_dir != self.work_dir:
            shutil.copy(self.old_work_dir + 'input_0.bmp', \
                        self.work_dir     + 'input_0.bmp')


        self.cfg['param']['zoom'] = int(self.check_zoom( kwargs['zoom'],      \
                                                         self.cfg['param'] ))

        self.cfg['param']['zoom_default'] = int(self.get_zoom_default(        \
                                                           self.cfg['param'] ))

        [ self.cfg['param']['scrollx'], self.cfg['param']['scrolly'] ] =      \
                     self.check_scroll( kwargs['scrollx'], kwargs['scrolly'], \
                     self.cfg['param']['zoom'], self.cfg['param'] )

    ## .................
        
        if 'x_center' in kwargs:
            self.cfg['param']['x_center'] = float( kwargs['x_center'] )

        xcoor = int( int( self.cfg['param']['x_center'] ) /  \
                     2 ** self.cfg['param']['zoom'])            
            
        if ( 0 <= xcoor <= float( self.cfg['param']['img_width']) ):
            self.cfg['param']['x_center'] = float( kwargs['x_center'] )
        else :
            self.cfg['param']['x_center'] = \
                                    float(self.cfg['param']['img_width']) / 2

        ### ......

        if 'y_center' in kwargs:
            self.cfg['param']['y_center'] = float( kwargs['y_center'] )

        ycoor = int( int( self.cfg['param']['y_center'] ) /  \
                     2 ** self.cfg['param']['zoom'])

        if ( 0 <= ycoor <= float( self.cfg['param']['img_height']) ):
            self.cfg['param']['y_center'] = float( kwargs['y_center'] )
        else :
            self.cfg['param']['y_center'] = \
                                    float(self.cfg['param']['img_height']) / 2

        ### ......

        if 'optimized' in kwargs:
            if kwargs['optimized'] == 'on':
                self.cfg['param']['optimized'] = 1
            else:
                self.cfg['param']['optimized'] = 0

        else: 
            if 'action' not in kwargs:
                self.cfg['param']['optimized'] = 0

    ## .................

       # Check action (VALUE)
        if 'action' in kwargs:
            self.cfg['param']['action'] = self.check_action( kwargs['action'], \
                                             kwargs['poly'], self.cfg['param'] )

        else :
            self.cfg['param']['poly'] = self.check_poly( kwargs['poly'], 
                                         kwargs['point.x'], kwargs['point.y'], \
                                         self.cfg['param'])

        self.cfg.save()        

        self.draw_poly( self.cfg['param'] )
        return self.tmpl_out('params.html')