Skip to main content
. 2022 Aug 7;22(15):5892. doi: 10.3390/s22155892
Algorithm 1. Fuzzy edge-detection using Prewitt and Sobel operators.
  1. Select the operator to calculate the gradients (Prewitt or Sobel).

  2. Case Prewitt:

  3.  Use kernels Prewittx (Equation (4)) and Prewitty (Equation (5))

  4. Case Sobel:

  5.  Use kernels Sobelx 9 (Equation (6)) and Sobely (Equation (7))

  6. Read input image f

  7. Obtain image dimensions (rows and columns)

  8. [rows, columns] = size(f)

  9. Calculate the classical gradient corresponding to the fuzzy filter desired

  10. [Dx, Dy] = zeros(rows, columns) // Generate a zero matrix with the same dimensions as f to capture the gradient

  11.   for i = 0 to rows:

  12.    for j = 0 to columns:

  13.       Dx[i,j] = sum(kernelx ∗ f [i: i+3, j: j+3]) // Equation (8)

  14.       Dy[i,j] = sum(kernely ∗ f [i: i+3, j: j+3]) // Equation (9)

  15.    end for

  16.   end for

  17. end for

  18. Generate the required fuzzy controller using the fuzzy rules from Table 2 and Table 3.

  19. Fuzzify the two input gradients Dx and Dy, using Gaussian MFs (Equations (18)–(23)).

  20. Infer the edges output with the selected controller

  21. Defuzzify the output (edges) of the controller.