Examples of Fuzzy Logic-based methods

This page contains the results after applying the different methods based on Fuzzy Logic.

Example image

Let us consider the following image, which we want to segment.

We load the image, and initialise the Segmentator object to proceed with the segmentation.

import cv2 
from colour_segmentation.base.segmentation_algorithm import SegmentationAlgorithm
from colour_segmentation.segmentator import Segmentator

segmentator = Segmentator(image=cv2.imread(r"assets/nectarine.jpg"))

Results

For each of the above methods, we will apply the segmentation with and without the achromatic colours.

Amante-Fonseca

result_amante_fonseca_achr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_AMANTE,
                                                 remove_achromatic_colours=False)
result_amante_fonseca_chr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_AMANTE,
                                                remove_achromatic_colours=True)

Chamorro-Martínez

result_chamorro_achr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_CHAMORRO,
                                           remove_achromatic_colours=False)
result_chamorro_chr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_CHAMORRO,
                                              remove_achromatic_colours=True)

Liu-Wang

result_liu = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_LIU,
                                 apply_colour_correction=False,
                                 remove_achromatic_colours=True)
result_liu_corrected = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_LIU,
                                           apply_colour_correction=True,
                                           remove_achromatic_colours=True)

Shamir

result_shamir_achr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_SHAMIR,
                                         remove_achromatic_colours=False)
result_shamir_chr = segmentator.segment(method=SegmentationAlgorithm.FUZZY_SET_SHAMIR,
                                        remove_achromatic_colours=True)

Last updated