Abstract
Edge Detection is the first stage in the image division into separate parts. Image division is the partitioning of a digital image to the different zones or the set of pixels. Edge detection is one of the techniques applied in digital image processing often. The purpose of detecting pixels is to match the edges in the image. Filtering, Enhancement, and Detection are three steps in edge detection. Images are usually destroyed by casual changes in intensity intervals called noise or confusion. some noise variations include salt and pepper, pulse, and Gaussian. However, there is a relation between edge detection power and noise reduction. Using filters to the noise reduction causes the loss of edge detection power. For facilitating the edges detection, it is essential for the determination of pixels’ intensity constraints in their neighborhood. Many points in an image have a nontransparent slope, and all of them are not the edges of the joint space. Therefore, some of the linear and nonlinear methods such as Sobel, Prewitt, and Robert have to be used to determine the edge points. The fuzzy logic and the system based on it, is one of the most effective methods for edge detection. This paper presents an optimized rule-based fuzzy inference system and designs the efficiency mask matric. The simulation results for edge detection are presented using the traditional edge detection techniques, including Binary Filter, Sobel Filter, Prewitt Filter, and Robert Filter. Also, it is presented using the fuzzy approach. The simulation results show that the designed fuzzy system has been able to detect the edges of the image more accurately and help to increase the sharpness and quality of the edges. Therefore, the proposed method has more accurate and more reliable results and reduces false edge detection comparison to the traditional methods.
Introduction
Over the years, various methods for edge detection have been presented. Edge detection is a technique of branding pixels in a digital image in which the light intensity varies widely for a variety of methodologies. Various applications can be used for edge detection, such as speed and type of road traffic, medical, and medical fields.
When reviewing an image, it is frustrating if that image has only one particular color. While putting several colors together makes that image enjoyable. But putting several colors together, which also creates a beautiful landscape, has its problems. These problems are due to the creation of various noises such as salt and pepper, Gaussian, etc., and the low intensity of the color of the pixels [1, 2]. The condition for detecting a slight defect in the border between two colors is the absence of noise on the image. If the image is noisy, the image is opaque and different algorithms must be used to detect the edge. Edge detection algorithms are of two types, linear and non-linear, which generally work using a derivative operator. Detectors have a similar function when moving from one surface, not suddenly but slowly and slowly to another. The moot point of edge recognition plays a central role in all areas of image processing research almost. If the borders exactly are recognized, the position of the objects can be detected, and parameters such as shape and location can be measured more accurately [3, 4]. The goal of this paper is to state a novel method using fuzzy logic by optimizing the fuzzy rule table and the system mask matrix for image edge recognition that has more precision and dependable results in evaluation to the following techniques. The new proposed approach in this paper is to optimally reduce the number of fuzzy rules and the dimensions of the mask matrix. In this paper, by changing and optimizing the rules and especially the size of the mask matrix, a new fuzzy inference system is designed with shorter rules and also, higher performance. It should be noted that in this system, all possible scenarios have been applied. In this regard, the new rules, which include several two-by-two matrices, have a rule that in it, the four matrix elements must be equal, or the three numbers were one, and the other must be zero, and vice versa.
As can be seen in [5–13], edge detection has been performed with the help of a fuzzy system by designing a mask matrix with dimensions of 3 * 3. For example, paper [7], is presented a fuzzy system by designing a mask matrix with dimensions of 3 * 3, to see edges in the presence of disturbance. A fuzzy classifier’s system was stated in [8] to classify the image pixels based on gray scale variation in different directions by designing a mask matrix with dimensions of 3 * 3. A new edge detector based on fuzzy inference rules (IF-THEN) was presented in [9] to state edges. Mask matrix in this paper has dimensions of 3 * 3. In [11, 12], the authors improved traditional edge detection methods with the help of fuzzy logic. In this paper has proposed a fuzzy system for edge detection by using a 3×3 mask.
In this paper, the proposed approach is completely innovative and new, and results state that the new approach is more desirable than the mentioned samples.
This paper is formed as follows: Part 2 introduces and shows edge detection algorithms consisting of four traditional algorithms. Part of 3, presents edge detection with a fuzzy system. Section 4, presents the main results and compares the two methods in [14] and this paper. The conclusion is stated at the end of paper in Section 5.
Problem statement
Edge detection algorithms
Laplacian edge detection filter
The Laplacian filter operator is known as a 2-D derivative operator. Using a Laplacian filter is to highlight and enhance fine details. Like the threaded edges. As you know, the Laplacian filter is a linear non-rotating actuator. The Laplacian filter can be expressed separately for all of dimensions. Partial quadratic derivatives in the x and y directions can be obtained with (1) [15]. Mask matrix of Laplacian filter has the 3×3 dimension that is shown in Fig. 1.

The Two Samples of Laplacian kernels.
Laplacian operator is a second-order minimum agent with convergence properties in border detection that plays a significant role in image processing techniques. But anyway, there are two drawbacks. First, Laplacian cannot obtain accurate edge direction information; Secondly, because of the sensitivity to noise, the border often appears with a width of two pixels. Therefore, the Laplacein operator is used only to recognize the image pixels, as the Laplacian operator is in the black or light region [16].
Laplace filter itself increases the noise in the image and detects the noise as an edge. Therefore, to use this filter, first use an anti-noise filter (Gaussian filter) on the image and then apply the Laplacein filter. Also, the use of a Laplacian filter as a result of the median filter, prevents this problem. This most of the noise is reduced in the middle filtration process [15]. Figure 2, represents the main image and Laplacian Filtered image, and this filter is applied to the original picture in this paper.

(a) Original Image and (b) Laplacian Filtered Image.
The Prewitt agent is a first-class differential agent in edge recognition technique. Using the variation in the amount of gray between the pixels above and below, and the left and right neighbor pixels, the edge can be recognized with a short amount in the edge, and some pseudo-edges can be eliminated, which also making the noise smoother. The general rule is for using two main patterns in the image pixels to doing of the convolution in the image. Main patterns distinguish the horizontal edge and the vertical edge. The Prewitt agent is an essential technique for border recognition due to computational simplicity and ease of implementation with hardware. So, this filter has been used a lot. Although, the custom Prewitt operator has a weak efficacy on busy images and apparent deviations from the trial results [17].
The Prewitt mask in this method, is a discrete operator and uses two 3×3 mask matrices for getting the approximate values in horizontal and vertical orientations. Figure 3 shows this mask matrix [17].

Mask Matrix in Prewitt Filter.
Horizontal derivative and vertical derivative approximate as (2) [9].
The method of detection of the Prewitt operator can easily lead to incorrect detection of border pixels, since the gray amount of many pixels is high. If the small border is recognized, the picture’s border is removed [17]. Figure 4 shows this matter.

(a) Original Image and (b) Prewitt Filtered Image.
This filter approximates the slope of a picture via digital derivation. The Robert mask matric, along with the whole picture is convolved using Robert horizontal and vertical masks to show the edge of the recognized picture, in the x and y directions, correspondingly [18]. Figure 5 shows this mask matrix.

Mask Matrixs in Robert Filter.
Horizontal derivative approximates and vertical derivative approximate as (3) [18]:
In the use of diagonal edge, we need 2-D kernels, and the Roberts cross-gradient agents are one of the closest efforts to applying it. The agents are based on fulfilment the diagonal differences [19]. Robert produced a dark background with the least edging information [20]. Figure 6 shows this matter.

(a) Original Image and (b) Prewitt Filtered Image.
This filter (Sobel operator), a widespread applied edge detection algorithm, was first introduced by Erwin Sobel at the Stanford Artificial Intelligence Laboratory in 1968. This operator uses the second brightness level change to recognize the edges inside the picture. The gradient vector in a situation (x, y) is presented as (4). In (4), G
x
and G
y
are the gradient of pixels in the x and y senses, correspondingly [21].
| ∇ f| is the largest size of conversion of f(x, y) per unique interval in orientation of gradient vector at the given position (x, y). ∠ (∇ f) is given as orientation of the gradient vector. Figure 7 presents Sobel mask matrices that are presented in (6) to illustrate the G x and G y vectors [22, 23].

Mask Matrix in Sobel Filter: (a) Mask matrix for x-direction and (b) Mask matrix for the y-direction.
The G
x
and G
y
are described as follows [23]. The mask matrix related to them is shown in Fig. 7.
Two filters are applied to the image, and the results are combined to give us a binary image of the edges [19]. Figure 8 shows this matter.

(a) Original Image and (b) Sobel Filtered Image.
Fuzzy logic and applications
Professor Lotfizadeh [24] introduced the fuzzy set and fuzzy logic theories in a thesis entitled (Fuzzy Sets-Information and Control) in 1965 for the first time. In addition, Mr. Mamdani used this logic to build a simple steam engine in 1974, and subsequently, the Hitachi Company developed an automated train control system based on fuzzy logic.
The fuzzy sets are derived from the classical set theory, which is used in fuzzy logic. A fuzzy collection is a collection whose members have a fellowship degree [25]. In classical theory, a point is the member of a set or is not. Indeed, the membership function of elements follows a binary pattern in the form of zero and one, but the fuzzy set theory extends this opinion and introduces graded fellowship [24, 25].
In fuzzy sets, the fellowship of the members of the fuzzy set is characterized by the function U(x), where x illustrates a definite member and u is a fuzzy function which indicates the degree of fellowship of x in the related set. The value of it is between 0 and 1. Equation (7) shows it [26–29].
Fuzzy logic is used via rules called “fuzzy operators,” presented based on the following model [30]. Fuzzy logic, like classical logic, has some basic operators. For example, fuzzy logic is used of the AND, OR, NOT operators, and fuzzy logic is equivalent to these operators. For example, the combination of AND two variables X and Y is the minimum values of U(x) and U(y), where both X and Y are fuzzy values, and the values of U(x) and U(y) reach their lowest value.
The problem solving with the fuzzy logic method, the following three steps must be done step by step: Convert the numeric values to the fuzzy values. Apply a set of inference rules to fuzzy data. Convert the fuzzy values to the standard values.
These steps are flexible for different areas and applications and change depending on the subject. Figure 9 presents the flowchart of fuzzy stages [31]. Fuzzy logic and its system can be used for detect edge in image processing. In this regard, the various membership functions can be used, which the triangular and Gaussian membership functions are one of the most widely used. This membership function must be selected so that it can be used to describe the status of each pixel at the edge.

The flowchart of fuzzy stages.
As a result, the fuzzy image processing has three phases: Fuzzification of input data Fuzzy derivation system Defuzzification of results
Figure 10 presents these general steps in more detail [32]:

The block diagram of a fuzzy system in image processing.
As stated in Fig. 10, it can be seen that there are various methods for edge recognition using the fuzzy sets theory. Therefore, the following three points should be considered:
To convert numerical values to fuzzy values, it should be noted that there are most of the different membership functions such as triangular, trapezoidal, and Gaussian, which are briefly described below [33, 34]. The converting of numerical values to fuzzy values with a triangular membership function, need three numeric values in which the lower bound (a), the upper bound (b), and the mean (m). The converting of numerical values to fuzzy values with the trapezoidal membership function, require four numeric values, which are {a, b, c, d}. The converting of numeric values to fuzzy values with Gaussian membership function, require three numeric values, which are {a, u, b}.
As stated in the previous part, the various membership functions can be used in edge detection based on fuzzy logic. This membership function should be selected so that it can be used to explain the status of each pixel at the edge. This paper uses an innovative algorithm for fuzzification, rule-based inference and defuzzification in edge detection. An algorithm provides the 16 new rules that a sample code of them seen in Fig. 11.

The sample code of one of the new rules.
In image processing with fuzzy logic, the input and output image must be gray. So each image will be divided into three parts: black, white, and edge. According to the previous definitions, all points of the image have a degree of fellowship of these three components [35]. At first, in the output are observed the different results, which are revealed by turning them from fuzzy to gray. In [14], are used of the following rules to identify edge using a mask matrix. So in a three-by-three matrix, the number of rules is vast if we want to consider all states; if we also reduce the rules, the output of edge detection does not have the necessary quality and efficiency. These differences are visible below.
In this paper, by changing and optimizing the rules and the size of the mask matrix in [14], a new fuzzy inference system is designed with the shorter rules and higher performance. It should be noted that in this system, all possible scenarios have been applied. Table 1 presents the fuzzy rules of using the paper [14], and Fig. 12 shows the mask matrix is [14]. In Table 1, Bl is black pixel value, “Wh” is white pixel value and “En” is edge enable. This table shows that 34 fuzzy rules, are presented in [14]. Also, fuzzy system in [14] has 9 inputs and 1 output.

The mask matrix that is used in [14].
The Fuzzy System Rules in [14]
In this regard, the new rules, which include several two-by-two matrices, have a rule that in it, the four matrix elements must be equal, or the three numbers were one, and the other must be zero, and vice versa.
Figure 13 shows that this paper uses a symmetric but even mask matrix designed in this paper. In the simulation section, we will see that this new simple and compact rule works the optimized and better than older edge detection techniques such as Sobel, Prewitt, and Robert. In addition, in the new rules, with the help of mathematics, the optimization of instructions has been followed to reduce the volume of the program and border recognition [26–28].

The mask matrix in the proposed fuzzy system.
Table 2 shows the new and optimized rules designed and used in this paper for edge image detection based on fuzzy set theory. The developed fuzzy system in this paper consists of 4 inputs and 1 output.
The New Rules in this Paper
Defuzzification transforms the outputs of the fuzzy inference engine into a crisp number. There are a lot of phase removal techniques [33], such as the center of gravity (COG), the area division (BOA), the maximum mean (MOM), the left maximum (LM), the right maximum (RM), and so on.
Main results
Using the rules in Table 2 and with the help of MATLAB software, a proposed fuzzy controller for edge recognition in images was designed. The fuzzy logic algorithm was compared with classical image processing methods, using the operators Binary, Roberts, Prewitt, and Sobel for edge detection. This system is of the Mamdani type, consisting of 4 inputs and one output. Figure 14 presents the simulation results for edge recognition using traditional edge detection techniques. Also, to prove the efficiency and superiority of the proposed fuzzy system in this paper, Fig. 15 compares the fuzzy system simulation results presented in [14] with the proposed fuzzy technique in this paper. In this paper, each fuzzy rule was adjusted to obtain good results while extracting the edges of the image. As shown in Figs. 14 15, these images were used as a comparative model for traditional operators and proposed fuzzy system approach.

The simulation results for edge detection using traditional edge detection techniques: (a) Original Image, (b) Binary Filter, (c) Sobel Filter, (d) Prewitt Filter, and (e) Robert Filter.

The simulation results of a fuzzy system: (a) The output of a fuzzy system in [14], (b) The output of a proposed fuzzy system.
The main image is presented in part (a) of Fig. 14. The edge detection using classical operators in MATLAB is illustrated in other parts in Fig. 14. In addition, the proposed approach was checked out with various images. Its operation is adapted to the traditional operators and the stated fuzzy system approach that is shown in Figs. 16 17.

The simulation results for edge detection using traditional edge detection techniques: (a) Original Image, (b) Binary Filter, (c) Sobel Filter, (d) Prewitt Filter, and (e) Robert Filter.

The simulation results of a fuzzy system: (a) The output of a fuzzy system in [14], (b) The output of a proposed fuzzy system.
The white points on the results illustrate edges. By applying the proposed fuzzy system on the image, it is illustrated that the edge improved algorithm has fewer noise, as shown in part (b) Fig. 15 and part (b) Fig. 17. We observe, in Figs. 14 16, which the traditional methods do not allow edges to be seen in the areas of low contrast. But, fuzzy approach allows edges to be seen even in the low contrast areas, as illustrated in part (b) Fig. 15 and part (b) Fig. 17. In this paper, by changing and optimizing the rules and the size of the mask matrix in [14], a new fuzzy inference system is designed with the shorter rules and also the higher performance. The proposed system uses a symmetric but even mask matrix. In parts (a) and (b) Figs. 15 17, we see that these new compact rules work the optimized and better than older edge detection techniques such as Binary, Sobel, Prewitt, and Robert. Also, in the new rules, the optimization of instructions has been followed to reduce the volume of the program and border recognition. The resulting image in part (b) in Figs. 15 17 in the proposed fuzzy system seems to be much smoother with less noise and more accurate than part (a) in Figs. 15 17. The result of Figs. 15 17 indicates an improvement and increase in the system’s accuracy compared to [14] and edge detection traditional methods. The advantage of the proposed method is given with a comparative analysis between the proposed method and other existing approaches in Table 3.
Comparison between edge detection methods using the number of pixels that detected as an edge
This table shows that the edge detection method detects the number of pixels as an edge. In fact, Table 3 shows that the proposed fuzzy system in Figs. 15 17 led to better and more reliable results in detecting edge pixels. The surface diagrams produced in MATLAB for binary and fuzzy images are shown in Fig. 18. These figures illustrate the color intensity of pixels in the image, and the color intensity of 1 in the surface diagram of the part (b) Fig. 18 indicates the edges.

The color intensity of pixels in binary and fuzzy images: (a) Surface diagram of binary image, (b) Surface diagram of fuzzy image.
This work presents an optimal and efficient fuzzy edge detector based on mask matrix optimization and fuzzy rule database. The target of such a new filtering layout is to retain edges accurately. To overcome the restrictions using the existing gradient-based methods, we present an optimized mask matrix and inference engine rules.
In the main results in the previous section, it can be seen that the traditional edge detection algorithms with threshold automatically estimated the image’s binary value do not will enable edges to be seen in the regions of low contrast. However, the proposed fuzzy system, in turn, allows edges to be detected even in the low contrast regions, as illustrated in Figs. 15 17. It is the advantage and disadvantage of this study work. The new fuzzy technique has improved the edge detection operation with a two-by-two mask matrix. The results in Table 3 confirm this matter.
The paper [14] uses a three-by-three mask matrix, but its drawback is that it has designed and implemented inefficient rules for edge detection. In this proposed paper, an attempt was made to select a sample space that can include all possible rules. The result of this choice is the design of new rules, and the result of the simulation determines the optimality of the method that has more precision. As a task for the future, we can focus on edge detection of images using a type 2 fuzzy system.
