Edge Detection For Face Image Using Multiple Filters
Edge Detection For Face Image Using Multiple Filters
E-ISSN : 2454-6135
Advanced Technology (IJERAT)
Volume.7, No. 8
DOI: 10.31695/IJERAT.2021.3736 August -2021
Haitham Salman Chyad 1, Raniah Ali Mustafa 2, & Zainab Yasser Mohamed 3
1-3
Mustansiriyah University
Department of Computer Science
College of Education,
Iraq
_______________________________________________________________________________________
ABSTRACT
Edge detection is a technique for detecting the presence and location of sharp changes in an image's intensity. Edges help in
segmentation and object recognition by defining the boundaries between sections in an image. Edge detection minimizes the
quantity of data in an image and filters out unnecessary information while keeping the image's crucial structural qualities. The
general method of edge detection is to study the changes of a single image pixel in an area, use the variation of the edge
neighboring first-order or second-order to detect the edge. This paper is an overview of different edge detection techniques like
differential operator method such as Sobel operator, canny technique and we used Visual Basic Language version 6.0 for this
paper.
Key Words: Edge Detection, Roberts Edge Detection, Sobel Edge Detection, Prewitt Edge Detection, Canny Edge Detection.
______________________________________________________________________________________________
1. INTRODUCTION
In image processing, edge detection approaches based on difference operations are commonly utilized. It can detect changes
in gray levels, but it is susceptible to noise. In image processing, edge detection is a crucial task. Pattern recognition, image
segmentation, and scene analysis all use it. An edge detector is just a high pass filter that can be used to retrieve the image's edge
points. An image's edge is a contour where the brightness of the image rapidly shifts. An edge is frequently regarded as one class
of singularities in image processing. In a function, singularities can be characterized easily as discontinuities where the gradient
approaches infinity. However, image data is discrete, so edges in an image often are defined as the local maxima of the gradient
[1, 2]. Edge widely exists between objects and backgrounds, objects and objects, primitives and primitives. The edge of an object
is reflected in the discontinuity of the gray. Edge extraction is an important technique in graphics processing and feature
extraction. The basic idea of edge detection is as follows: First, use edge enhancement operator to highlight the local edge of the
image. Then, define the pixel "edge strength" and set the threshold to extract the edge point set.
Face is one of the most appropriate biometrics to monitor applications [3]. In social life, faces are our fundamental focus
and they play an important role in expressing emotions and identity [4]. Face has gained an increasing amount of interest in
computer vision and machine learning during the past few years, due to the fact that face recognition technology can be applied in
a wide range of areas, such as, access control, identity authentication and others [5].
Dataset contains many faces; the process of matching a face to any of faces in the dataset is called Face Recognition.
Although the existing systems are as yet far away from the ability of the individual perception system, numerous techniques have
been suggested and much progress has been made to recognize faces beneath small variation in facial expressions, orientations,
and illumination [6].
www.ijerat.com Page 28
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
the background in the image. Edge detection is the most familiar approach for detecting significant discontinuities in intensity
values .
Edges are local changes in the image intensity. Edges typically occur on the boundary between two regions. The main features
can be extracted from the edges of an image. Edge detection has major feature for image analysis [7]. These features are used by
advanced computer vision algorithms. Edge detection is used for object detection which serves various applications like medical
image processing, biometrics etc [8].
These can then be combined together to find the absolute magnitude of the gradient at each point and the orientation of that
gradient. The gradient magnitude is given by:
……………………………………(1)
…………………………………......(2)
which is much faster to compute [9][10].
Note that, unlike the Sobel operator, this operator does not place any emphasis on pixels that are closer to the center of the
masks. At each point in the image, the result of the Prewitt operator is either the corresponding gradient vector or the normal of
this vector. The Prewitt operator is based on convolving the image with a small, separable, and integer valued filter in horizontal
and vertical direction and is therefore relatively inexpensive in terms of computations.
www.ijerat.com Page 29
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
…………………(3)
The canny edge detector has a simple approximate implementation in which edges are marked at maxima in gradient
magnitude of a Gaussian-smoothed image [14].The performance of the Canny algorithm depends heavily on the adjustable
parameters, σ, which is the standard deviation for the Gaussian filter, and the threshold values, th and tl. The gradient of the
smoothed array S [i, j] can be computed using the 2x2 first-difference approximations to produce two arrays P [i,j] and Q [i,j] for
the x and y partial derivatives:
The finite differences are averaged over the 2 x 2 square so that the x and y partial derivatives are computed at the same
point in the image. The magnitude and orientation of the gradient can be computed from the standard formulas for rectangular-to-
polar conversion:
Where the arctan function takes two arguments and generates an angle over the entire circle of possible directions. These
functions must be computed efficiently, preferably without using floating-point arithmetic. It is possible to compute the gradient
magnitude and orientation from the partial derivatives by table lookup. The arctangent can be computed using mostly fixed-point
arithmetic2 with a few essential floating-point calculations performed in software using integer and fixed-point arithmetic.
2.4.2 The main aims of the Canny Edge Detector are as follows
(a) Good detection - There should be a low probability of failing to mark real edge points, and low probability of falsely marking
non edge points. Since both these probabilities are monotonically decreasing functions of the output signal-to-noise ratio, this
criterion corresponds to maximizing signal-to-noise ratio. So basically, we need to mark as many real edges as possible.
(b) Good localization - The points marked out as edge points by the operator should be as close as possible to the center of the true
edge [16]. In essence, the marked out edges should be as close to the edges in the real edges as possible.
www.ijerat.com Page 30
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
(c) Minimal response - Only one response to a certain edge. This is implicitly captured in the first criterion since when there are
two responses to the same edge, one of them must be considered false. Therefore, the idea is that an edge should be marked only
once, and image noise should not create false edges.
3. PROPOSED SYSTEM
In this proposed system, we will implement techniques of edge detection on image we used to edge detection technique (Sobel &
Canny).
This paper is consisting of three Command and six picture box and one text box. The Commands is for (Load image, Sobel edge
detection & Canny edge detection).
www.ijerat.com Page 31
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
When we choose an image the image is loaded into picturebox (pic1) as sown in the follow figure:
www.ijerat.com Page 32
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
And after convert image to gray scale we implement Sobel edge detection on image as the follow code:
Pic5.Cls
Grad = 0
Op_X(-1, -1) = -1: Op_X(0, -1) = -2: Op_X(1, -1) = -1
Op_X(-1, 0) = 0: Op_X(0, 0) = 0: Op_X(1, 0) = 0
Op_X(-1, 1) = 1: Op_X(0, 1) = 2: Op_X(1, 1) = 1
Op_Y(-1, -1) = -1: Op_Y(0, -1) = 0: Op_Y(1, -1) = 1
Op_Y(-1, 0) = -2: Op_Y(0, 0) = 0: Op_Y(1, 0) = 2
Op_Y(-1, 1) = -1: Op_Y(0, 1) = 0: Op_Y(1, 1) = 1
tmps = "using Kernel for Sobel" & vbCrLf & "Horisontal >>" & vbCrLf
For X = -1 To 1
For Y = -1 To 1
tmps = tmps & Format(Op_X(X, Y), "0")" " &
Next Y
tmps = tmps & vbCrLf
Next X
tmps = tmps & "Vertical >>" & vbCrLf
For X = -1 To 1
For Y = -1 To 1
tmps = tmps & Format(Op_Y(X, Y), "0")" " &
Next Y
tmps = tmps & vbCrLf
www.ijerat.com Page 33
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
Next X
Text1.Text = Text1.Text & tmps & vbCrLf
DoEvents
For Y = 0 To Pic11.Height - 1
For X = 0 To Pic11.Width - 1
GradX = 0: GradY = 0: Grad = 0
If X = 0 Or Y = 0 Or X = Pic11.Width - 1 Or Y = Pic11.Height - 1 Then
Grad = 0
Else
For I = -1 To 1
For J = -1 To 1
PixelValue = GetPixel(Pic1.hdc, X + I, Y + J) ' x + i dan y + j
DecTORGB PixelValue, R, G, B
Itensity = (R + G + B) / 3 ' / B & W
GradX = GradX + (Itensity * Op_X(I, J))
GradY = GradY + (Itensity * Op_Y(I, J))
Next J
Next I
Grad = Round(Sqr(Abs(GradX * GradX) + Abs(GradY * GradY)))
End If
If Grad <= 0 Then Grad = 0: If Grad >= 255 Then Grad = 255
SetPixel Pic5.hdc, X, Y, RGB(Grad, Grad, Grad)
Pic5.Refresh
Next X
Pic5.Refresh
Next Y
After implement of Sobel edge detection we show the result of sobel as shown in the follow figure:
www.ijerat.com Page 34
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
Sum = 0
RR2 = -2 * fRadius * fRadius
www.ijerat.com Page 35
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
Me.Cls
ReDim Kernel(1, Rad, C)
cnt = 0
Dim tmps As String
Text1.Text = Text1.Text & vbCrLf
Text1.Text = Text1.Text & "looking for methods Canny kernel" & vbCrLf
Text1.Text = Text1.Text & "step 1 image conversion to gaussian blur ..." & vbCrLf
Text1.Text = Text1.Text + "the calculation result of gaussian blur kernel >>" & vbCrLf
Text1.SelStart = Len(Text1.Text)
ReDim Kernel(0 To 1, -GaussianSize To GaussianSize, -GaussianSize To GaussianSize)
For I = -GaussianSize To GaussianSize
For J = -GaussianSize To GaussianSize
Kernel(1, I, J) = RKernel(cnt)
tmps = tmps & Format(Kernel(1, I, J), "000")" " &
cnt = cnt + 1
Next J
Text1.Text = Text1.Text + tmps & vbCrLf
tmps"" =
Next I
Text1.Text = Text1.Text + "use Theta = " & fRadius & " and size Kernel = " & KernelSize & " x " & KernelSize & " Pixel" &
vbCrLf
Text1.Text = Text1.Text + "using 2D drawing functions"
Text1.SelStart = Len(Text1.Text)
Dim tmpIntR As Double, tmpIntG As Double, tmpIntB As Double
Dim CTotal As Single
Dim CDataR As Single, CDataG As Single, CDataB As Single
Dim Intensity As Long, Grad As Single
CTotal = (((GaussianSize * GaussianSize) + GaussianSize) * 4) + 1
Dim tmpC As Long
Dim CountClr As Long
For Y = 0 To Pic1.Height - 1
For X = 0 To Pic1.Width
For J = -GaussianSize To GaussianSize
For I = -GaussianSize To GaussianSize
PixelValue = GetPixel(Pic1.hdc, X + I, Y + J)
DecTORGB PixelValue, R, G, B
CDataR = CDataR + (Kernel(1, J, I) * R)
CDataG = CDataG + (Kernel(1, J, I) * G)
CDataB = CDataB + (Kernel(1, J, I) * B)
If mX < C Then mX = mX + 1
Next I
Next J
www.ijerat.com Page 36
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
'PixNum = InputBox("enter the value for gray between [0 - 255] :", "Input Grayscale")
PixNum = 90
Text1.Text = Text1.Text & " Grayscale color value = " & PixNum & vbCrLf
Text1.SelStart = Len(Text1.Text)
DoEvents
For Y = 0 To Pic8.Height
For X = 0 To Pic8.Width
PixelValue = GetPixel(Pic8.hdc, X, Y)
DecTORGB PixelValue, R, G, B
Pic9.Refresh
Next X
Pic9.Refresh
Next Y
The result of implement gray scale image we shown in the follow figure:
www.ijerat.com Page 37
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
In the step3: we implement Canny filter On Image in this Filtering image using 2 Thresholds.Min Threshold = 0 & Max
Threshold = 1 as shown in the follow code:
www.ijerat.com Page 38
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
End If
Pic10.Refresh
Next X
Pic10.Refresh
Next Y
Exit Sub
ErrHandle:
The result of Canny filter was shown as the shown in the follow figure:
4. DATASET
The datasets that are used in proposed system are collected from 30 volunteers of different samples; 15 samples for each
person, the images were taken under different lighting conditions, varied in expression, orientations, illumination, skin color,
background, varied in ages, and face shapes (the mouth and eyes are open or closed, with or without glasses, male and female...
etc.), the face is in frontal position.
The face images are 24 bit RGB, 300*400 pixels resolution of (BMP) format, the distance between the person and the camera
is 125 cm.
www.ijerat.com Page 39
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
Figure (1): Some Persons' Images with their Samples Chosen from the Dataset
5. CONCLUSION
In the discipline of computer vision, image processing is a quickly moving field. Its growth has been fueled by technological
advances in digital imaging, computer processors and mass storage devices. In this paper an attempt is made to review the edge
detection techniques which are based on discontinuity intensity levels. The relative performance of various edge detection
techniques (sobel and canny) is carried out with an image by using visual Basic 6.0 software. Canny result is superior one when
compared to all for a selected image since different edge detections work better under different conditions. In this paper we
conclude that the results of canny are better than Sobel.
ACKNOWLEDGMENT
The authors would like to thank Mustansiriyah University (https://uomustansiriyah.edu.iq, Baghdad- Iraq) for its support in this
work.
REFERENCES
[1] J. J. Benedetto and M.W. Frazier, "Wavelets Mathematics and Applications", CRC Press, Inc, 1994.
[2] K. A. Stevens, "Surface perception from local analysis of texture and contour",Artificial Intell. Lab., Mass. Instr. Technol.,
Cambridge, Tech. Rep. AI-TR512,1980.
[3]D. Yi, Z. Lei, and S. Z. Li, "Towards Pose Robust Face Recognition", provided by the Computer Vision Foundation the
authoritative version of this paper is available in IEEE Xplore, 2013.
[4]K. Davakhar, S. B. Mule and A. Deshmukh, " Person Authentication Using Color Face Recognition", Journal of Engineering
Research and Applications, Vol. 3, Issue 5, pp.178-182, Sep-Oct 2013.
[5]L. Xianwei and Z. Haiyang, "A Survey of Face Recognition Methods", Proceedings of the 2nd International Conference on
Computer Science and Electronics Engineering (ICCSEE), 2013.
[6]E. Al Daoud, "Enhancement of the Face Recognition Using a Modified Fourier-Gabor Filter", Computer Science Department
Zarka Private University, Jordan, Vol. 1, No. 2, November 2009.
[7]International Journal of Computer Science & Information Technology (IJCSIT) Vol 3, No 6, Dec 2011
[8]International Journal of Computer Science & Information Technology (IJCSIT) Vol 3, No 6, Dec 201,PP 261.
[10] P.Sharma,G. Singh and Amandeep Kaur , "Algorithms For Edge Canny Detection" International Journal of Engineering
Research and Applications (IJERA) ISSN: 2248-9622 Vol. 3, Issue 3, pp.458-461, May-Jun 2013.
[11] R1. Muthukrishnan and M.Radha,"EDGE DETECTION TECHNIQUES FOR IMAGE SEGMENTATION " ,P.262, 2010.
[12] R.Gonzalez & R.Wood, "Digital Image Processing", 3rd ed, Englewood Cliffs, NJ: Prentice Hall, 2007.
[13] http://www.cse.usf.edu
www.ijerat.com Page 40
DOI : 10.31695/IJERAT.2021.3736
International Journal of Engineering Research and Advanced Technology, Vol. 7, No.8, August -2021
[14] S. Bhardwaj and A. Mittal "A Survey on Various Edge Detector Techniques", Procedia Technology 4, 220 – 226, 2012.
[15] J. Arati Vyavahare, " Edge Detector Techniques" International Journal of Computer Applications (0975 – 8887) Volume
102– No.7, September 2014.
[16] D. Ray, "Edge Detection in Digital Image Processing ", Thursday, June 06, 2013.
C. Author: [email protected]
www.ijerat.com Page 41
DOI : 10.31695/IJERAT.2021.3736