class Seg():
    '''Segment obrazku.
    Reprezentovan je dvemi krajnimi body, vyskou, sirkou a centralnim bodem
    '''
    def __init__(self, ul_x, ul_y, lr_x, lr_y):
        self.ul_x = ul_x
        self.ul_y = ul_y
        self.lr_x = lr_x
        self.lr_y = lr_y
        self.width = lr_x - ul_x
        self.height = lr_y - ul_y
        self.center_x = ul_x/2 + lr_x/2
        self.center_y = lr_y/2 + ul_y/2

    @staticmethod
    def combine(seg):
        '''Spojeni dvou segmentu minimalizaci a maximalizaci krajnich bodu
        '''
        return Seg(min(s.ul_x for s in seg if s != None),
                   min(s.ul_y for s in seg if s != None),
                   max(s.lr_x for s in seg if s != None),
                   max(s.lr_y for s in seg if s != None))