**4. Image pre-processing**

Image acquisition is a highly important step for the automatic quality control because it provides the input data for the whole process. The acquisition is performed by an optical sensor which is always a video camera with one line or a matrix of CCD, which provide accurate and noiseless image. Local illumination is directly linked with the quality of image acquisition because it is straight forward to demonstrate that its variations can heavily affect the patterns visibility in the image. Consequently the natural sources of light which are nonconstant must not be employed and their influence should be carefully eliminated. Thus the use of a strictly controlled illumination provides good illumination control. Exclusively, one or more artificial light sources are the reasonable alternative.

Pre-processing: Before a computer vision method can be applied to image data in order to extract some specific piece of information, it is usually necessary to process the data in order to assure that it satisfies certain assumptions implied by the method. Examples are


The following are the generally applied preprocessing methods.

a. Contrast adjustment

284 Fuzzy Inference System – Theory and Applications

dimensional plots of a Type-1 MFs. Another way to visualize Type-2 fuzzy sets is to plot their so-called Footprint Of Uncertainty (FOU). The Type-2 MFs, MF(x, w), sits atop a twodimensional x-w plane. It sits only on the permissible (sometimes called "admissible") values of x and w. This means that x is defined over a range of values (its domain)—say, X.

From the Figure 2, the measured (crisp) inputs are first transformed into fuzzy sets in the fuzzifier block because it is fuzzy set, not the number, that activates the rules which are

Three types of fuzzifiers are possible in an interval Type-2 FLS. When measurements are:

Noisy, but the noise is non-stationary, they are modeled as an interval Type-2 fuzzy set

after fuzzification of measurements (inputs), the resulting input fuzzy sets are mapped into fuzzy output sets by the Inference block. This is accomplished by first quantifying each rule using fuzzy set theory, and by then using the mathematics of fuzzy sets to establish the output of each rule, with the help of an inference mechanism. If there are M rules, the fuzzy input sets to the Inference block will activate only a subset of those rules usually fewer than M rules. So, at the output of the Inference block, there will be one or more fired-rule fuzzy

The fired-rule output fuzzy sets have to be converted into a number by Output Processing block as shown in the Figure 2. Conversion of an interval Type-2 fuzzy set to a number (usually) requires two steps. In the first step, an interval Type-2 fuzzy set is reduced to an interval-valued Type-1 fuzzy set called type-reduction. There are many type-reduction methods available [Karnik'2001]. Karnik and Mendel have developed an algorithm, known as the KM Algorithm, used for type-reduction. It is very fast algorithm but iterative. The second step of output processing, after type-reduction, is defuzzification. Since a typereduced set of an interval Type-1 fuzzy set is a finite interval of numbers, the defuzzified value is just the average of the two end-points of this interval. If a type-reduced set of an interval Type-2 fuzzy set is a Type-1 fuzzy set, the defuzzified value can be obtain by any of

Image acquisition is a highly important step for the automatic quality control because it provides the input data for the whole process. The acquisition is performed by an optical sensor which is always a video camera with one line or a matrix of CCD, which provide accurate and noiseless image. Local illumination is directly linked with the quality of image acquisition because it is straight forward to demonstrate that its variations can heavily affect the patterns visibility in the image. Consequently the natural sources of light which are nonconstant must not be employed and their influence should be carefully eliminated. Thus the use of a strictly controlled illumination provides good illumination control. Exclusively, one

Noisy, but the noise is stationary, they are modeled as a Type-1 fuzzy set; and,

(this latter kind of fuzzification cannot be done in a Type-1 FLS).

In addition, w is defined over its range of values (its domain)—say, W.

described in terms of fuzzy sets.

output sets.

Perfect, they are modeled as a crisp set;

the defuzzification method applied to Type-1 FL.

or more artificial light sources are the reasonable alternative.

**4. Image pre-processing** 


Type-2 Fuzzy Logic for Edge Detection of Gray Scale Images 287

segmentation. This process detects outlines of an object and boundaries between objects and the background in the image. An edge-detection filter can also be used to improve the

The basic edge-detection operator is a matrix-area gradient operation that determines the level of variance between different pixels. The edge-detection operator is calculated by forming a matrix centered on a pixel chosen as the center of the matrix area. If the value of this matrix area is more than a given threshold, then the middle pixel is classified as an edge. For the of edges detection techniques normally methods like *Canny, Narwa, Iverson, Bergholm y Rothwell* [Heath'1996] are applied. Others methods can group in two categories: Gradient and Laplacian. The gradient methods like *Roberts, Prewitt* and *Sobel* detect edges, looking for maximum and minimum in first derivative of the image like the Laplacian methods find the zeros of second order derivative from the image [webpage5]Edges are extracted from the enhanced image by a two-stage edge detection operator that identifies the edge candidates based on the local characteristics of the image. Examples of gradientbased edge detectors are *Roberts*, *Prewitt*, and *Sobel* operators. All the gradient-based algorithms have kernel operators that calculate the strength of the slope in the directions which are orthogonal to each other, commonly vertical and horizontal. Later, the contributions of the different components of the slopes are combined to give the total value

Recent techniques have characterized edge detection as a fuzzy reasoning problem [Boskovitz'2002], [Hanmandlu'2004], [Liang'2001&2003], [Miosso'2001]. These techniques have presented good and promising results in the areas of image processing and computational vision. Fuzzy techniques allow a new perspective to model uncertainties due to the uncertainty of gray-values present in the images. Thus, instead of assigning gray-values to the pixels in the image, fuzzy membership values may be assigned. Miosso and Bauchspiess [Miosso'01] have evaluated the performance of a fuzzy inference system in edge detection. It was concluded that despite the much superior computational effort, when compared to the *Sobel* operator, the implemented FIS system presents greater robustness to contrast and lighting variations besides avoiding obtaining double edges. Further tuning of the parameters associated with the fuzzy inference rules is still necessary to further reducing the membership values for the non-edge pixels. The proposed study is the beginning of an effort for the design of new edge detection

The *prewitt* operator measures two components. The vertical edge component is calculated with kernel *prewitt\_y* and the horizontal edge component is calculated with kernel *prewitt\_x.*  The operator uses two 3×3 kernels [Green'02] and they are smaller than image size. These kernels are convolved with the original image. Convolution is a mathematical way of combining two signals to form a third signal. It is the most important technique in Digital Signal Processing. Using the strategy of impulse decomposition, systems are described by a signal called the impulse response. Convolution is important because it relates the three signals of interest: the input signal, the output signal, and the impulse response. These kernels are convolved with the original image to calculate approximations of the

appearance of blurred or anti-aliased video streams.[webpage4]

of the edge strength.

techniques, using Fuzzy Inference Systems (FIS).

**5.1 Calculation of the gradients** 

some sort representing the histogram statistics. The histogram graphically shows the following:


The Histogram Equalization [wang'95] evenly distributes the occurrence of pixel intensities so that the entire range of intensities is covered. This method usually increases the global contrast of images, especially when the usable data of the image is represented by close contrast values. Through this adjustment, the intensities can be better distributed on the histogram. It allows the areas of lower local contrast to gain a higher global contrast. Histogram equalization accomplishes this by effectively spreading out the most frequent intensity values. Then probability density function (pdf) is calculated for the histogram.

d. **Morphological Operation** The identification of objects within an image can be a very difficult task. One way to simplify the problem is to change the grayscale image into a binary image, in which each pixel is restricted to a value of either "0" or "1". The techniques used on these binary images go by such names as: blob analysis, connectivity analysis, and morphological image processing (from the Greek word morphē, meaning shape or form). The foundation of morphological processing is in the mathematically rigorous field of set theory. However, this level of sophistication is seldom needed. Most morphological algorithms are simple logic operations and very ad hoc. Each application requires a custom solution developed by trial-and-error. Every texture image taken has been implemented with morphological reconstruction using Extended Maxima Transformation (EMT) with thresholding technique. The EMT is the regional maxima computation of the corresponding Horizontal Maxima Transformation (HMT). As a result, it produces a binary image. A connected-component labeling operation is performed, in order to evaluate the characteristics and the location of every object. The extended maxima transform computes the regional maxima of the H-Transform. Here H refers to nonnegative scalar [Karnik'2001]. Regional maxima are connected components of pixels with a constant intensity value, and whose external boundary pixels will have a lower value.

There are many techniques for preprocessing available in the literature. In the presented work, images are pre-processed using low pass filter whose mask is given as in eq. (5). This preprocessing is applied to remove the noise from the image. Later Image is normalized by taking account of mean and standard deviation.

$$Lp = \frac{1}{25} \* \begin{bmatrix} 1 \ 1 \ 1 \ 1 \ 1 \ 1 \\ 1 \ 1 \ 1 \ 1 \ 1 \\ 1 \ 1 \ 1 \ 1 \ 1 \\ 1 \ 1 \ 1 \ 1 \ 1 \end{bmatrix} \tag{5}$$

#### **5. Edge detection**

Edge detection is a fundamental tool used in most image processing applications to obtain information from the frames as a precursor step to feature extraction and object

The Histogram Equalization [wang'95] evenly distributes the occurrence of pixel intensities so that the entire range of intensities is covered. This method usually increases the global contrast of images, especially when the usable data of the image is represented by close contrast values. Through this adjustment, the intensities can be better distributed on the histogram. It allows the areas of lower local contrast to gain a higher global contrast. Histogram equalization accomplishes this by effectively spreading out the most frequent intensity values. Then probability density function (pdf) is calculated for the histogram.

d. **Morphological Operation** The identification of objects within an image can be a very difficult task. One way to simplify the problem is to change the grayscale image into a binary image, in which each pixel is restricted to a value of either "0" or "1". The techniques used on these binary images go by such names as: blob analysis, connectivity analysis, and morphological image processing (from the Greek word morphē, meaning shape or form). The foundation of morphological processing is in the mathematically rigorous field of set theory. However, this level of sophistication is seldom needed. Most morphological algorithms are simple logic operations and very ad hoc. Each application requires a custom solution developed by trial-and-error. Every texture image taken has been implemented with morphological reconstruction using Extended Maxima Transformation (EMT) with thresholding technique. The EMT is the regional maxima computation of the corresponding Horizontal Maxima Transformation (HMT). As a result, it produces a binary image. A connected-component labeling operation is performed, in order to evaluate the characteristics and the location of every object. The extended maxima transform computes the regional maxima of the H-Transform. Here H refers to nonnegative scalar [Karnik'2001]. Regional maxima are connected components of pixels with a constant intensity value, and whose external

There are many techniques for preprocessing available in the literature. In the presented work, images are pre-processed using low pass filter whose mask is given as in eq. (5). This preprocessing is applied to remove the noise from the image. Later Image is normalized by

> � � � � �

Edge detection is a fundamental tool used in most image processing applications to obtain information from the frames as a precursor step to feature extraction and object

� � � �

(5)

�� � � �� ∗

following:

3. Skewness of the data; 4. Presence of outliers; and

1. Center (i.e., the location) of the data; 2. Spread (i.e., the scale) of the data;

5. Presence of multiple modes in the data.

boundary pixels will have a lower value.

taking account of mean and standard deviation.

**5. Edge detection** 

some sort representing the histogram statistics. The histogram graphically shows the

segmentation. This process detects outlines of an object and boundaries between objects and the background in the image. An edge-detection filter can also be used to improve the appearance of blurred or anti-aliased video streams.[webpage4]

The basic edge-detection operator is a matrix-area gradient operation that determines the level of variance between different pixels. The edge-detection operator is calculated by forming a matrix centered on a pixel chosen as the center of the matrix area. If the value of this matrix area is more than a given threshold, then the middle pixel is classified as an edge. For the of edges detection techniques normally methods like *Canny, Narwa, Iverson, Bergholm y Rothwell* [Heath'1996] are applied. Others methods can group in two categories: Gradient and Laplacian. The gradient methods like *Roberts, Prewitt* and *Sobel* detect edges, looking for maximum and minimum in first derivative of the image like the Laplacian methods find the zeros of second order derivative from the image [webpage5]Edges are extracted from the enhanced image by a two-stage edge detection operator that identifies the edge candidates based on the local characteristics of the image. Examples of gradientbased edge detectors are *Roberts*, *Prewitt*, and *Sobel* operators. All the gradient-based algorithms have kernel operators that calculate the strength of the slope in the directions which are orthogonal to each other, commonly vertical and horizontal. Later, the contributions of the different components of the slopes are combined to give the total value of the edge strength.

Recent techniques have characterized edge detection as a fuzzy reasoning problem [Boskovitz'2002], [Hanmandlu'2004], [Liang'2001&2003], [Miosso'2001]. These techniques have presented good and promising results in the areas of image processing and computational vision. Fuzzy techniques allow a new perspective to model uncertainties due to the uncertainty of gray-values present in the images. Thus, instead of assigning gray-values to the pixels in the image, fuzzy membership values may be assigned. Miosso and Bauchspiess [Miosso'01] have evaluated the performance of a fuzzy inference system in edge detection. It was concluded that despite the much superior computational effort, when compared to the *Sobel* operator, the implemented FIS system presents greater robustness to contrast and lighting variations besides avoiding obtaining double edges. Further tuning of the parameters associated with the fuzzy inference rules is still necessary to further reducing the membership values for the non-edge pixels. The proposed study is the beginning of an effort for the design of new edge detection techniques, using Fuzzy Inference Systems (FIS).

#### **5.1 Calculation of the gradients**

The *prewitt* operator measures two components. The vertical edge component is calculated with kernel *prewitt\_y* and the horizontal edge component is calculated with kernel *prewitt\_x.*  The operator uses two 3×3 kernels [Green'02] and they are smaller than image size. These kernels are convolved with the original image. Convolution is a mathematical way of combining two signals to form a third signal. It is the most important technique in Digital Signal Processing. Using the strategy of impulse decomposition, systems are described by a signal called the impulse response. Convolution is important because it relates the three signals of interest: the input signal, the output signal, and the impulse response. These kernels are convolved with the original image to calculate approximations of the

$$G\_{\mathbf{x}} = \sum\_{l=1}^{l=3} \sum\_{j=1}^{j=3} \{ Precitt\_{\mathbf{z}} \chi\_{l,l} \} \* I\_{\mathbf{r}+l-2, c+j-2} \tag{6}$$

$$G\_y = \sum\_{l=1}^{l=3} \sum\_{j=1}^{j=3} \left( Precitt \\_y\_{l,j} \right) \* I\_{r+l-2, c+j-2} \tag{7}$$

$$Prewitt \, \text{ $x = \begin{bmatrix} -1 & 0 & +1 \\ -1 & 0 & +1 \\ -1 & 0 & +1 \end{bmatrix} \text{ and } Precwitt \, \text{$ y = \begin{bmatrix} -1 & -1 & -1 \\ 0 & 0 & 0 \\ +1 & +1 & +1 \end{bmatrix} \tag{8}$$


Type-2 Fuzzy Logic for Edge Detection of Gray Scale Images 291

For all the fuzzy variables, the membership functions are Gaussian. According to the executed tests, the values in DH and DV, vary from -850 to 850, then the ranks in x-axis adjusted as shown in Figures 7 and Figure 8..The output variable , i.e. EDGES, membership

LOW MEDIUM HIGH


DV

LOW MEDIUM HIGH

The ten fuzzy rules that allow to evaluate the input variables, so that the output image displays the edges of the image in color near white (255 gray scale), whereas the background

0 50 100 150 200 250

EDGES

Fuzzy 1 output image and its corresponding histogram

functions are shown in Figure 9.

0

0.2

0.4

Degree of m em bership

0.6

0.8

1

Fig. 8. Membership function for input 2 (DV)

Fig. 9. Membership function for output EDGES

1. If (DH is LOW) and (DV is LOW) then (EDGES is LOW)

2. If (DH is MEDIUM) and (DV is MEDIUM) then (EDGES is HIGH) 3. If (DH is HIGH) and (DV is MEDIUM) then (EDGES is HIGH) 4. If (DH is HIGH) and (DV is MEDIUM) then (EDGES is HIGH) 5. If (DH is MEDIUM) and (DV is LOW) then (EDGES is MEDIUM)

was in near black (0 gray value).

0

0.2

0.4

Degree of membership

0.6

0.8

1

#### **5.2 Edges detection by type-1 FIS**

The system implementation was carried out considering that both, the input image and the output image obtained after defuzzification, are 8-bit quantized. The Mamdani method was chosen as the defuzzification procedure, which means that the output fuzzy sets obtained by applying each inference rule to the input data were joined through the add function; the output of the system was then computed as the centroid of the resulting membership function [Jang'95]. Block Diagram of Type-1 Fuzzy Logic, with two inputs, one output and 10rules, using the Matlab Fuzzy Logic Tool Box [WebPage 7] is shown in Figure 6.

Fig. 6. Block Diagram for Type-1 Darken the lines between blocks Inference System

Since the image is preprocessed hence we use the horizontal gradient and Vertical gradient as inputs to Type-1 FIS with Gaussian member ship function For the Type-1 FIS, these two inputs are the gradients with respect to x-axis and y-axis and calculated by equations (6) and (7) which are denoted by DH and DV respectively.

Fig. 7. Membership function for input 1 (DH)

The system implementation was carried out considering that both, the input image and the output image obtained after defuzzification, are 8-bit quantized. The Mamdani method was chosen as the defuzzification procedure, which means that the output fuzzy sets obtained by applying each inference rule to the input data were joined through the add function; the output of the system was then computed as the centroid of the resulting membership function [Jang'95]. Block Diagram of Type-1 Fuzzy Logic, with two inputs, one output and

10rules, using the Matlab Fuzzy Logic Tool Box [WebPage 7] is shown in Figure 6.

EdgeFuzzy

(mamdani)

10 rules

Fig. 6. Block Diagram for Type-1 Darken the lines between blocks Inference System

(7) which are denoted by DH and DV respectively.

Fig. 7. Membership function for input 1 (DH)

0

0.2

0.4

Degree of m

 em bership

0.6

0.8

1

Since the image is preprocessed hence we use the horizontal gradient and Vertical gradient as inputs to Type-1 FIS with Gaussian member ship function For the Type-1 FIS, these two inputs are the gradients with respect to x-axis and y-axis and calculated by equations (6) and

System EdgeFuzzy: 2 inputs, 1 outputs, 10 rules

LOW MEDIUM HIGH

EDGES (3)


DH

**5.2 Edges detection by type-1 FIS** 

DH (3)

DV (3)

Fuzzy 1 output image and its corresponding histogram

For all the fuzzy variables, the membership functions are Gaussian. According to the executed tests, the values in DH and DV, vary from -850 to 850, then the ranks in x-axis adjusted as shown in Figures 7 and Figure 8..The output variable , i.e. EDGES, membership functions are shown in Figure 9.

Fig. 8. Membership function for input 2 (DV)

Fig. 9. Membership function for output EDGES

The ten fuzzy rules that allow to evaluate the input variables, so that the output image displays the edges of the image in color near white (255 gray scale), whereas the background was in near black (0 gray value).


Type-2 Fuzzy Logic for Edge Detection of Gray Scale Images 293

LOW MEDIUM HIGH


DH

LOW MEDIUM HIGH


DV

LOW MEDIUM HIGH

<sup>0</sup> <sup>50</sup> <sup>100</sup> <sup>150</sup> <sup>200</sup> <sup>250</sup> <sup>300</sup> <sup>0</sup>

EDGES

Fig. 11. Membership function for input 1 (DH)

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Degree of Membership

Fig. 12. Membership function for input 2 (DV)

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Degree of Membership

Fig. 13. Membership function for output (EDGE)

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Degree of Membership


The result obtained from Type-1 FIS is outperform the *prewitt* operator edges as shown in Figure 10.

Fig. 10. (a) AnEdge obtained by Type-1 FIS , and (b) its histogram.
