Segmentator object
The Segmentator class defines the basic object for chromatically segmenting an image. This page shows how it works.
Initialization
In order to segment an image, it is only necessary to initialise the object by passing that image as a parameter. Then, the segment
method performs the segmentation.
Note that the function receives the image in tensor format, with discrete inputs, and the channels sorted in BGR.
Segmentation procedure
The segment
function receives, as a mandatory argument, the method to be used. The method is determined using the list of values defined by SegmentationAlgorithm
, whose values are summarised in the following table.
Algorithm
Key
Value
Amante-Fonseca
FUZZY_SET_AMANTE
0
Chamorro-Martínez
FUZZY_SET_CHAMORRO
1
Liu-Wang
FUZZY_SET_LIU
2
Shamir
FUZZY_SET_SHAMIR
3
The parameters of each method must be passed with its corresponding key.
The method returns a SegmentationResult
object. For more information about the result, see section Segmentation result.
Segmentation result
The SegmentationResult
object contains the result of the segmentation. Specifically, the values it contains are:
segmented_image
: It represents the final segmented image, with the different artificial colours associated with each class. It is a RGB image, with the same dimension as the original image. Its type isnumpy.ndarray
.segmented_classes
: Represents the class to which each pixel belongs. It is a single channel image, containing in each entry an integer value representing the colour index of that pixel. Its type isnumpy.ndarray
.elapsed_time
: It is a float value, representing the execution time.
Finally, the SegmentationResult
object implements the get_colour_proportion
function, which allows to calculate the proportion of pixels whose associated class is the one specified by parameter.
Last updated