**2. General description composition of the fuzzy inference system**

Fuzzy image processing is not a unique theory. It is a collection of different fuzzy approaches to image processing. Generally speaking, edge detection with fuzzy logic is

Edge Detection Based on Fuzzy Logic and Expert System 273

In many image processing applications, expert knowledge is often used to work out the problems. Expert knowledge, in the form of fuzzy if-then rules, is used to deal with imprecise data in fuzzy set theory and fuzzy logic. Fuzzy method will be more suitable to

Input of the the fuzzy inference system (FIS) is the original image and composed by a highpass lter, a rst-order edge detector lter (Sobel operator) and a low-pass (median) lter. It

In FIS , hDH and hDV are the Sobel operators used to estimate the rst derivative of Image in horizontal and vertical directions. hHP and hM are the kernels of a high-pass and a low-pass (median) lters. F, I and D are the fuzzication, inference and defuzzification stages[9].

Three linear and one non-linear (median) filters are used in this paper. A high-pass lter

[i-1, j-1] [i-1, j] [i-1, j+1] [i, j-1] [i, j] [i, j+1] [i+1, j-1] [i+1, j] [i+1, j+1]

Sobel operators ( hDH and hDV ) are kernels with 3x3 elements given by [10]: hDH and hDV are Sobel operators used to estimate the rst derivative of Image in horizontal and vertical

*DH DV h h*

A high-pass lter (hHP) and a median filter (hMF) are defined as:

*HP h*


DH = hDH \* I (2)

DV = hDV \* I (3)

2 2 *D DH DV HV* (4)

Then the ltered images will be calculated through a bidimensional convolution operation, I

However, the result of convolution of the two Sobel kernels is combined by computing


(1)

(5)

manage the imperfection than the traditional way.

**3. Edge detection with FIS system** 

(hHP) and a median filter (hMF) are 3x3 masks.

depicts in Figure 2.

**3.1 Image pretreatment** 

Fig. 3. 3 \* 3 matrix mask

is the original image:

directions.

norm-2.

composed of expert knowledge, fuzzification, membership modification, fuzzy set theory and defuzzification [8]. As shown in figure 1.

Fig. 1. The general structure of fuzzy image processing

The coding of image data (fuzzification) and decoding of the results (defuzzification) are steps that make possible to process images with fuzzy techniques. The main power of fuzzy image processing is in the middle step (modification of membership values). After the image datas are transformed from gray-level plane to the membership plane (fuzzification), appropriate fuzzy techniques modify the membership values. This can be a fuzzy clustering, a fuzzy rule-based approach, a fuzzy integration approach and so on.

Fuzzy image processing plays an important role in representing uncertain datas. There are many benefits of fuzzy image processing. Firstly, fuzzy techniques are able to manage the vagueness and ambiguity efficiently and deal with imprecise data. Secondly, fuzzy logic is easy to understand. Fuzzy reasoning is very simple in mathematical concepts.

Fig. 2. Fuzzy inference system (FIS) applied to edge (E) detection

In many image processing applications, expert knowledge is often used to work out the problems. Expert knowledge, in the form of fuzzy if-then rules, is used to deal with imprecise data in fuzzy set theory and fuzzy logic. Fuzzy method will be more suitable to manage the imperfection than the traditional way.

Input of the the fuzzy inference system (FIS) is the original image and composed by a highpass lter, a rst-order edge detector lter (Sobel operator) and a low-pass (median) lter. It depicts in Figure 2.

In FIS , hDH and hDV are the Sobel operators used to estimate the rst derivative of Image in horizontal and vertical directions. hHP and hM are the kernels of a high-pass and a low-pass (median) lters. F, I and D are the fuzzication, inference and defuzzification stages[9].

#### **3. Edge detection with FIS system**

#### **3.1 Image pretreatment**

272 Fuzzy Inference System – Theory and Applications

composed of expert knowledge, fuzzification, membership modification, fuzzy set theory

The coding of image data (fuzzification) and decoding of the results (defuzzification) are steps that make possible to process images with fuzzy techniques. The main power of fuzzy image processing is in the middle step (modification of membership values). After the image datas are transformed from gray-level plane to the membership plane (fuzzification), appropriate fuzzy techniques modify the membership values. This can be a fuzzy clustering,

Fuzzy image processing plays an important role in representing uncertain datas. There are many benefits of fuzzy image processing. Firstly, fuzzy techniques are able to manage the vagueness and ambiguity efficiently and deal with imprecise data. Secondly, fuzzy logic is

and defuzzification [8]. As shown in figure 1.

Fig. 1. The general structure of fuzzy image processing

a fuzzy rule-based approach, a fuzzy integration approach and so on.

Fig. 2. Fuzzy inference system (FIS) applied to edge (E) detection

easy to understand. Fuzzy reasoning is very simple in mathematical concepts.

Three linear and one non-linear (median) filters are used in this paper. A high-pass lter (hHP) and a median filter (hMF) are 3x3 masks.


Fig. 3. 3 \* 3 matrix mask

Sobel operators ( hDH and hDV ) are kernels with 3x3 elements given by [10]: hDH and hDV are Sobel operators used to estimate the rst derivative of Image in horizontal and vertical directions.

$$h\_{DH} = \begin{bmatrix} \cdot1 & 0 & 1\\ \cdot2 & 0 & 2\\ \cdot1 & 0 & 1 \end{bmatrix}, \quad h\_{DV} = \begin{bmatrix} \cdot1 & \cdot2 & \cdot1\\ 0 & 0 & 0\\ 1 & 2 & 1 \end{bmatrix} \tag{1}$$

Then the ltered images will be calculated through a bidimensional convolution operation, I is the original image:

$$\text{IDH} = \text{pHH} \tag{2}$$

$$\mathbf{h} \mathbf{D} \mathbf{V} = \mathbf{h}\_{\text{DV}} \, \text{\* } \mathbf{I} \tag{3}$$

However, the result of convolution of the two Sobel kernels is combined by computing norm-2.

$$D\_{HV} = \sqrt{DH^2 + DV^2} \tag{4}$$

A high-pass lter (hHP) and a median filter (hMF) are defined as:

$$h\_{HP} = \begin{bmatrix} \cdot1 & \cdot2 & \cdot1 \\ \cdot2 & \cdot12 & \cdot2 \\ \cdot1 & \cdot2 & \cdot1 \end{bmatrix} \tag{5}$$

Edge Detection Based on Fuzzy Logic and Expert System 275

By the defined fuzzy rules, the output of this fuzzy system is classified to one of three

Fuzzy inference rules are applied to assign the three fuzzy sets characterized by

*Low* to the output set.

The fuzzy inference rules are dened in such a way, and the rules are shown below:

15. IF (M is medium) and ( hDV is medium) and (HP is high) THEN ("Edge" is high). 16. IF (M is medium) and ( hDV is high) and (HP is low) THEN ("Edge" is medium). 17. IF (M is medium) and ( hDV is high) and (HP is medium) THEN ("Edge" is high). 18. IF (M is medium) and ( hDV is high) and (HP is high) THEN ("Edge" is high). 19. IF (M is high) and ( hDV is low) and (HP is low) THEN ("Edge" is low).

20. IF (M is high) and ( hDV is low) and (HP is medium) THEN ("Edge" is medium). 21. IF (M is high) and ( hDV is low) and (HP is high) THEN ("Edge" is medium).

*Medium* , and

1. IF (M is low) and ( hDV is low) and (HP is low) THEN ("Edge" is low). 2. IF (M is low) and ( hDV is low) and (HP is medium) THEN ("Edge" is low). 3. IF (M is low) and ( hDV is low) and (HP is high) THEN ("Edge" is low). 4. IF (M is low) and ( hDV is medium) and (HP is low) THEN ("Edge" is low). 5. IF (M is low) and ( hDV is medium) and (HP is medium) THEN ("Edge" is low). 6. IF (M is low) and ( hDV is medium) and (HP is high) THEN ("Edge" is medium).

7. IF (M is low) and ( hDV is high) and (HP is low) THEN ("Edge" is low). 8. IF (M is low) and ( hDV is high) and (HP is medium) THEN ("Edge" is high). 9. IF (M is low) and ( hDV is high) and (HP is high) THEN ("Edge" is high). 10. IF (M is medium) and ( hDV is low) and (HP is low) THEN ("Edge" is low). 11. IF (M is medium) and ( hDV is low) and (HP is medium) THEN ("Edge" is low). 12. IF (M is medium) and ( hDV is low) and (HP is high) THEN ("Edge" is medium). 13. IF (M is medium) and ( hDV is medium) and (HP is low) THEN ("Edge" is medium). 14. IF (M is medium) and ( hDV is medium) and (HP is medium) THEN ("Edge" is

classes [11, 12]. Output membership functions are shown in figure 5.

Fig. 5. Output membership functions

 *High* , 

membership functions

medium).

**3.3 Fuzzy inference rules** 

hMF = median{x1, x2, x3, x4, x5, x6, x7, x8,x9} (6)

xi (i =1,2,...,9) is the element of 3x3 mask.

Then the ltered images will be calculated through a bidimensional convolution operation:

$$\text{HIP} = \mathsf{h}\_{\text{HP}} \, \* \, \, \Gamma \,\tag{7}$$

$$\mathbf{M} = \mathbf{h}\_{\text{MF}} \, \* \, \mathbf{I} \tag{8}$$

Laplacian operator and Gaussian function are separately defined as:

$$\nabla^2 f = \frac{\hat{\sigma}^2 f}{\hat{\sigma}\mathbf{x}^2} + \frac{\hat{\sigma}^2 f}{\hat{\sigma}y^2} \tag{9}$$

$$h(x, y) = \exp\left(-\frac{x^2 + y^2}{2\sigma^2}\right) \tag{10}$$

Then LoG operator is formed by the convolution between Gaussian function and Laplacian operator.

$$\nabla^2 h = \left(\frac{r^2 - \sigma^2}{\sigma^4}\right) \exp\left(-\frac{r^2}{2\sigma^2}\right) \tag{11}$$

Here suppose <sup>222</sup> *r x y* .

#### **3.2 Fuzzy sets and fuzzy membership functions**

Three fuzzy sets are made up to represent each variable's intensities; these sets are symbolized to the linguistic variables "low", "medium" and "high".

The adopted membership functions for the fuzzy sets are Gaussian function and sigmoid function. For the linguistic variables "low" and "high", sigmoid function is chosen; Gaussian function is used for the variable "medium" with the mean 127.5. As shown in Figure 4.

Fig. 4. Membership functions of the fuzzy sets

hMF = median{x1, x2, x3, x4, x5, x6, x7, x8,x9} (6)

2 2

 

<sup>2</sup> ( , ) exp <sup>2</sup> *x y hxy*

Then LoG operator is formed by the convolution between Gaussian function and Laplacian

*r r <sup>h</sup>* 

 

Three fuzzy sets are made up to represent each variable's intensities; these sets are

The adopted membership functions for the fuzzy sets are Gaussian function and sigmoid function. For the linguistic variables "low" and "high", sigmoid function is chosen; Gaussian function is used for the variable "medium" with the mean 127.5. As shown in Figure 4.

2 2 *f f <sup>f</sup> x y*

 

22 2

4 2 exp <sup>2</sup>

 

2 2

HP = hHP \* I (7)

M = hMF \* I (8)

(9)

(11)

(10)

Then the ltered images will be calculated through a bidimensional convolution operation:

Laplacian operator and Gaussian function are separately defined as:

2

symbolized to the linguistic variables "low", "medium" and "high".

**3.2 Fuzzy sets and fuzzy membership functions** 

Fig. 4. Membership functions of the fuzzy sets

2

xi (i =1,2,...,9) is the element of 3x3 mask.

operator.

Here suppose <sup>222</sup> *r x y* .

By the defined fuzzy rules, the output of this fuzzy system is classified to one of three classes [11, 12]. Output membership functions are shown in figure 5.

Fig. 5. Output membership functions

Fuzzy inference rules are applied to assign the three fuzzy sets characterized by membership functions *High* , *Medium* , and *Low* to the output set.

#### **3.3 Fuzzy inference rules**

The fuzzy inference rules are dened in such a way, and the rules are shown below:


Edge Detection Based on Fuzzy Logic and Expert System 277

The output of the system PFinal, which is representing the probability used for final pixel classification as edge or not, is reckoned on a singleton fuzzifier. Mamdani defuzzifier

> 1 1 1 1

 

*i l i k*

*M l n i l i k*

where αi are the fuzzy sets associated with the fuzzy rule base, *y* is the output class center

The proposed fuzzy edge detection method is simulated using MATLAB 7.0 on different images, and its performance is compared to that of the Sobel and LoG operator. In Figure 6, (a) is the original image, (b) is the image that the Sobel operator with threshold automatically estimated from image's RMS value. (c) is the image with LoG operator to detect edges, and the threshold is computed automatically. The FIS system, as shown (d),

Form above the experiments, it can be obviously shown that no matter how different images are tested, such as from bright to dim or from natural to artificial , the FIS system proposed in this paper is much better than Sobel and LoG operator in edge detection. The only

In this paper, FIS has been presented. The three edge strength values used as fuzzy system inputs were fuzzified using Gaussian membership functions and sigmoid function. Fuzzy ifthen rules are used to modify the membership to one of low, medium, and high classes. Finally, Mamdani defuzzifier method is used to form the final edge image. By the simulation results, it can be concluded that though more computationally expensive than Sobel and LoG operators, the FIS system is superior in greater robustness to detect edge, and

[1] J. C. Bezdek. (1981). *Pattern Recognition with Fuzzy Objective Functions*. Plenum, New

[2] M. N. Mahani, M. K. Moqadam, H. N. pour, etc. (2008). Dynamic Edge Detector Using

[3] L. Liang and C. Looney. (2003). Competitive Fuzzy Edge Detection, *Applied Soft* 

[4] G. Mansoori and H. Eghbali. (2006). Heuristic edge detection using fuzzy rule-based

classifier, *Journal of Intelligent and Fuzzy Systems*, Volume 17, Number 5, pp. 457-

Fuzzy Logic, *CSISS 2008*, Sharif University ofTechnology, Kish.

not only detects edges much better, but also makes the output image without noise.

disadvantage is that FIS system is not as simple as Sobel and LoG operator.

also advantage in edge detection exactly and noise removed clearly.

*y*

*Final M n*

*P*

( ( )) ( ( ))

 

 

*l i l i*

(12)

**3.4 Fuzzy logical operations and defuzzification** 

and M is the number of fuzzy rules being considered.

method [13] is given by:

**4. Experiments** 

**5. Conclusion** 

**6. References** 

York.

469.

*Computing* , pp. 123 - 137 .


Fig. 6. Using different methods to detect the image with gradation of gray levels

#### **3.4 Fuzzy logical operations and defuzzification**

The output of the system PFinal, which is representing the probability used for final pixel classification as edge or not, is reckoned on a singleton fuzzifier. Mamdani defuzzifier method [13] is given by:

$$P\_{Final} = \frac{\sum\_{l=1}^{M} \overline{\mathcal{Y}}^l \left(\prod\_{i=1}^{n} \mu\_{k\_i^l}(\alpha\_i)\right)}{\sum\_{l=1}^{M} \left(\prod\_{i=1}^{n} \mu\_{k\_i^l}(\alpha\_i)\right)}\tag{12}$$

where αi are the fuzzy sets associated with the fuzzy rule base, *y* is the output class center and M is the number of fuzzy rules being considered.
