segmenter.py 2.33 KB
Newer Older
1 2 3 4
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
"""
5 6 7 8
    Abstract class for segmenters.
    
    Name: segmenter.py
    Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
9
"""
10

11 12
from abc import ABCMeta, abstractmethod

13
class Segmenter(object):
14
    """Abstract class for segmenter algorithms."""
15 16
    
    __metaclass__ = ABCMeta
17

18
    def get_name(self):
19 20 21 22 23 24 25
        """Return the name of class.
        
        Returns
        -------
        name : string
            Returns the name of instantiated class.
        """
26 27 28 29
        return self.__class__.__name__
    
    @abstractmethod
    def get_config(self):
30 31 32
        """Return configuration of segmenter. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
33 34 35 36
        pass
    
    @abstractmethod
    def set_config(self, configs):
37 38 39
        """Update configuration of segmenter. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
40 41 42 43
        pass
    
    @abstractmethod
    def get_summary_config(self):
44 45 46
        """Return fomatted summary of configuration. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
47 48
        pass
    
49 50
    @abstractmethod
    def get_list_segments(self):
51 52 53
        """Return a list with segments after apply segmentation. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
54 55
        pass
    
56 57
    @abstractmethod
    def get_segment(self, px, py, idx_segment):
58 59 60
        """Return a specified segment using a index or position in image. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
61 62 63 64
        pass
    
    @abstractmethod
    def paint_segment(self, image, color, px, py, idx_segment, border, clear):
65 66 67
        """Paint a list of segments using a index or position in image. 
        Implement this method to extend this class with a new segmenter algorithm.
        """
68
        pass
69

70
    
71 72
    @abstractmethod
    def run(self, image):
73 74 75
        """Perform the segmentation 
        Implement this method to extend this class with a new segmenter algorithm.
        """
76
        pass
77 78

    @abstractmethod
79
    def reset(self):
80 81 82 83
        """Clean all data of segmentation. 
        Implement this method to extend this class with a new classifier algorithm.
        """
        pass