|
Algorithm 1. Fuzzy edge-detection using Prewitt and Sobel operators. |
Select the operator to calculate the gradients (Prewitt or Sobel).
Case Prewitt:
Use kernels Prewittx (Equation (4)) and Prewitty (Equation (5))
Case Sobel:
Use kernels Sobelx 9 (Equation (6)) and Sobely (Equation (7))
Read input image
Obtain image dimensions (rows and columns)
[rows, columns] = size(f)
Calculate the classical gradient corresponding to the fuzzy filter desired
[Dx, Dy] = zeros(rows, columns) // Generate a zero matrix with the same dimensions as f to capture the gradient
for i = 0 to rows:
for j = 0 to columns:
Dx[i,j] = sum(
∗ f [i: i+3, j: j+3]) // Equation (8)
Dy[i,j] = sum(
∗ f [i: i+3, j: j+3]) // Equation (9)
end for
end for
end for
Generate the required fuzzy controller using the fuzzy rules from Table 2 and Table 3.
Fuzzify the two input gradients Dx and Dy, using Gaussian MFs (Equations (18)–(23)).
Infer the edges output with the selected controller
Defuzzify the output (edges) of the controller.
|