Edge detection using charge analogy

Edge detection using charge analogy

COMPUTER GRAPHICS AND IMAGE PROCESSING u), 185- 195 ( 1982) NOTE Edge Detection Using Charge Analogy I.K. SETHI Department of Electronics I...

552KB Sizes 5 Downloads 184 Views

COMPUTER

GRAPHICS

AND

IMAGE

PROCESSING

u),

185- 195 ( 1982)

NOTE

Edge Detection

Using Charge Analogy I.K. SETHI

Department

of Electronics Indian-Institute

Received

& Electrical Communications Engineering, of Technology, Kharagpur, India

September

28, 198 1; revised

November

2, 198 I

In this paper a technique based on a charge analogy is presented for the design of edge detectors of various sizes. Using this analogy, an extended version of the Roberts cross operator is derived. The results of an edge-detection experiment on two digital pictures are also presented. 1. INTRODUCTION

Edge detection constitutes an important activity in the enhancement and segmentation of pictures, and many methods have been developed for edge detection in pictures [l-3]. In this paper a technique for the design of edge detectors of various sizes is presented. The method is based on a charge analogy which has been used earlier by Kazmierczak [4] for character recognition. An extended version of the Roberts cross operator is derived. The results of an edge detection experiment on two digital pictures along with the sensitivity of these edge operators are also presented. 2. CHARGE

ANALOGY

FOR

EDGE

DEFINITION

Let us consider a picture of M X N pixels, where each pixel represents a positive charge whose magnitude is equal to the gray level of the pixel. Let it be further assumed that these charges are positioned at the center of each pixel. Now, if we compute the intensity of the electric field at various positions in the picture plane, then it is obvious that abrupt changes in the gray levels at the edges in the picture give rise to large electric field intensities at those positions. Moreover, it can be seen that the edge direction at such a position is perpendicular to the direction of the electric field there. Thus, by computing the electric field intensity vector at different positions we can derive information about the edges in the picture. Based on this simple analogy and using some approximations for the electric field intensity we can derive masks of different sizes for edge-detection operations. Some of these operators are discussed below. 3. EVEN

EDGE

OPERATORS

In an even edge operator consisting of a 2 X 2 or 4 X 4 array of pixels, the edge strength is measured by computing the electric field intensity at the comers of the pixels. Similarly for determining various odd edge operators like 3 X 3, we will compute the electric field intensity at the center of each pixel. 185 0146-664X/82/100185-11$02.00/0 Copyright 0 1982 by Academic Press. Inc. All rights of reproduction in any form reserved.

186

I. K. SETHI

Consider the four pixels a, b, c, and d of a picture as shown below: a

b *P d

C

As a simple approximation, let us assume that charges represented by the pixels other than a, b, c, and d do not contribute much to the electric field at the point P which is midway between the four pixels. Since the electric field is directly proportional to the charge and varies inversely as the square of the distance, its horizontal and vertical components at the point P are E, = @[(b

-t d) - (u + c)]

E, = @[(a

+ b) - (c + d)].

and

The net electric field intensity at point P is therefore E = (Ei + .Ez)‘/’ with a direction given by tan-‘EJE,,. Hence the edge strength at the point P is E and its direction is tan- ‘E,/E, + ~/2. Since the relative edge strength is important and not its absolute value, the edge strength E at point P can be computed by the following two masks: H, = -1 -1 This is surface in Instead directions,

+1 +1

and

H2=

‘:

‘;.

the same result as the 2 X 2 operator of Prewitt obtained by fitting a the least squares sense to a neighborhood of each pixel [5]. of resolving the electric field at point P in the horizontal and vertical let us resolve it along the diagonal directions. In that case, we get Ed = 2(d - u)

and EC = 2(c - 6). This implies an edge strength of (Ed2 -t- Ez)‘j2 at the point P with an edge direction of tan-‘E/E, + n/2 where positive angle is measured in the clockwise direction from the line joining the points P and d. This result corresponds to two masksofsize2X2with H,=-1

0

’ +1

and

H2=

’ +1

-’

0

which are nothing but the masks for the Roberts cross operator. It is the most efficient way of determGng the edge strength over a 2 X 2 region because of t&e lesser number of arithmetic operations required per computation.

EDGE DETECTION

USING CHARGE

ANALOGY

187

To improve upon the computation of the electric field intensity at a point midway between the pixels, let us now consider charges present in a 4 X 4 region. Let a ef

b Eh” .P

i m

j n

k 0

1 P

be the charges around the point P. Resolving the electric field due to these charges at P in the horizontal and vertical directions, we get Eh*[lOO[(g+k)-(ftj)] +ll[(d+p)

+27[(h+ - (a -l-m)]

l)-

(e+i)]

+ 9[(c + o) -(b

+ n)]]/lOO

and E,*[lOO[( +ll[(a

f + g) - (j + k)] + 27[(b + c) - (n + o)]

+ d) - (112+p)]

+ 9[(e + h) -(i

+ e)]]/lOO,

where the weights of the different factors have been rounded off to integer values for ease in computation. Thus using charges over the 4 X 4 region, the edge strength at point P can be calculated by the following masks: -11

-9 -100 -100 -9

H, = 1;;

-11

+9

+lOO +lOO +9

+11 +27 +27 +11

and H = 2

+11

+27

+27

+9 -9

+100 -100

+100 -100

-11

-27

-27

+ll +9 -9 -11

However, if we resolve the electric field in the diagonal directions as was done earlier, we obtain the following two 4 X 4 masks: -22

N,=---;

-18

-9

-loo 0 +9

0 +lOO +18

+1s

-100 -18 0 +9

0

0 +9

+18 +22

and

H2=,:i

+i +22

-22 -18 -9

0

188

I. K. SETH1

By analogy, the 4 X 4 edge detector with the masks as described above can be called an extended Roberts cross operator. Following the above procedure, masks for even bigger regions can be deveioped for better approximation to the edgeness at points midway between the pixels. 4. ODD EDGE OPERATORS

In order to derive the masks of size 3 X 3, 5 X 5, etc., the electric field intensity at the center of each pixel is computed. The charge at the center of the pixel where the electric field intensity is being calculated is assumed to be the test charge for the measurement of field strength. Consider the following charges over a 3 X 3 region: a

b

c

d e f g

h

i

The following two equations are obtained for the electric field intensity at the center of the 3 X 3 region, i.e., at point e. E,, -[3(

f-

d) f (c + i) - (a + g)]/3

and E, -[3(b

- h) + (a + c) - (g + i)]/3

Therefore the 3 X 3 masks for edge detection can be written as -1 H,=-3

-1

0

+1

0

+3

0

+1

+3

and

Hz=+:

0 -1

-3

+1 0 -1

Similarly the masks for bigger sizes such as 5 X 5, etc. can be determined. Resolving the electric field along the diagonal directions does not give any advantage in this case. 5. SENSITIVITY

ANALYSIS

A good edge detector should exhibit the following desirable features: (i) The response of the edge detector should be independent of the orientation of the edge. (ii) The edge detector response should fall off sharply as it is moved away from the edge. For ideal edges, Abdou and Pratt [6] have suggested a procedure for analyzing the sensitivity of the edge detectors with respect to the above features. The results of this sensitivity analysis for the three edge detectors described in the previous sections along with similar analysis for Sobel’s and Prewitt’s 3 X 3 operators are shown in Fig. 1. It is seen from these curves that the proposed 3 X 3 operator is more sensitive to diagonal edges in comparison to the other operators. Again the proposed 4 X 4

EDGE DETECTION 1.60

z

1.20

: g 1.00

5 w .a0 3

USING CHARGE

189

ANALOGY

r

E

II

III

IP P I

00

.20

40

.60 tan

.e4l

1.0

1.2

t

(a) 41 : ACTUAL +

EDGE

: DETECTED

ORIENTATION EDGE

ORIENTATION

1.20

1.00

.40 .20 0

J 0

.20

.bO

.60 tan

A0

1.0

1.2

()

(b)

FIG. 1. Edge-detector sensitivity curves for (I) 2 X 2 operators, (II) proposed 3 X 3 operator, (III) Sobel operator, (IV) Prewitt operator, (V) 4 X 4 operator. (a) Normalized edge strength as a function of actual edge orientation. (b) Detected edge orientation as a function of actual edge orientation. (c) Normalized edge strength as a function of edge displacement for vertical edge. (d) Normalized edge strength as a function of edge displacement for diagonal edge.

operator shows an improvement over the 2 X 2 operators in regard to the sensitivity to edge orientation. All the 3 X 3 edge operators exhibit a constant response over small edge displacements, meaning that, for the same thresholding level, the binary edge picture in this case will have more thick edges than to the even operators.

190

I. K. SETH1

.25

.50

.75

1.00

1.25

DISPLACEMENT,

150

1.75

2.00

2.25

1.75

2.00

2.25

d

(cl

0

.25

.50

.75

1.00

1.25

OISPLACEMENT

1.50 , d

(d)

FIG. I.

Continued.

6. EDGE-DETECTION

EXAMPLES

In order to evaluate the performance of the proposed 3 X 3 and 4 X 4 operators, they were used to detect the edges in two digital pictures of size 64 X 64 with 32 gray levels. The picture data were obtained from Gonzalez and Wintz [7] and are shown in Fig. 2. The results of the edge operators are shown in Figs. 3 and 4. Also shown in Fig. 3 are the results of the use of Sobel’s operator. For the results shown in Fig. 3 threshold levels of 5.0 and 8.5, i.e., about 15.5% and 26.5% of the maximum possible edge strength, were used. It can be seen that the proposed 3 X 3 operator yields almost the same result as that of Sob&s operator. The 4 X 4 operator shows an improvement by producing less thick edges for the same threshold level. Fiiure 4a shows the result of appl-g the 4 X 4 operator to the airplane picture of Fig. 2b, where a threshold of 5.0 has been used. Figure 4b shows the same e~&e pictiure sfter the thickness of the edges has been removed by using thy local maxima f&r.

. . . . . . . ..~

ij:

.-.. __--_ . . L ~~~mIli...=..=---..._;.,.;;*_..===~~~...=*=====, . . . . . . . . . . . . . . . . . .._...........-.=~~=.=-*.==. .=.. .). ._.....

(b) FIG. 2. 32 gray-level test pictures. (a) Lincoln (b) airplane. 191

.*.** .

,..* if.

..*.

**.*.

11.

*I**. .

..*.

t*.

. *+

.

*.+ .

.

.

tt. .

+*.

*t. .**

**.t.++<*

.

+** *

.*.*. I.*.*.. t**.** .*..

**it *.*** ***/ t** tt ** .+ **

** t.

FIG.

3.

(a) and (b) Binary

edge pictures

using 192

3 X 3 operator

with

thresholds

5.0 and 8.5

++++++t

t+*+

++*+ ++++

+* +*

++x+ *+++ -+ ++t+ +++ +++ ++t+ +c ++++ ++ + +* ++I ++ +* +++ ++

++ ++ If++ ++++ t+*+ +++++ .++

+*I ++I ++

++I +++ ++* +++++

*+ w +x +++++ +++++ ++++ ++++

++ +++ ++

+++++ ++**

+++ +++ ++ +++

* ++ + ++ ++++ +++*+ + +++* ++ +** ++ -+++ +tt *+i+ +* ++++ ++++ +*+++ + ++ +++ *++ +++ + it++++ ++ ++*+ + + + +t*+ ++ ++ +*+ x * + + *+ *+++ ++++ tt + * * +x +* +*+ * +++++a

+ + + + + : + + + + + + + +

+++**** ++* +*

*it++

+t * + ff ++ ++++ + ++ ++ ++ ++ ++ * * ++ +++++t+ ++ ++ ++x+*++ ++*++ + + ++ if +*+ ++*t++t +++ +++ +++ + +*+++++t+ ++ ++ ++I/, + +++ 1+ +++ ++++*+ +++ +++ +++ x It *+a++++ ++ tt + +*+ * + * + + +++++ + +++ *+ ++*++ + ++ f 1 ++++ + +++*t*++++ + * 1 *++++++++ + + + + ++++ ++ + +++a ++ tt + ++ +++ + + +++++ + ++ ++ + +++++ + *+++++ +++*+ I ++++++t++ + ++ ++ +++*++++ c it+++ + ++ + +* +++ ++++ +++ i++++ *+ + ++ +*++++*+++*t* ++ ++* ++t++++ + + *++*+* +++ + ++ it++ ++t*+*+++* ++ it+ +++t +t ++I

+*+ ++++*+t t*++

+ I

++++ +++ + + +++++ + +++++++++*t++++ +++ ++/+*+++ +++

:: ++ + +

.++++

+*+* +x+ +++i +++*

+++i +t +++ ++++

++* +

(4

t* .* *.

**

.*

**. ..+* ***.* .*.* .*1

.*. .

..* .*.

(4 FIG.

3. (Continued)

(c) and (d) same using 193

4 X 4 operator.

cNIIt.8 +Ut+ HUI +++cI +++ uzz+ +++I XI ++i++ *It*++ i++ *+*+ ++++++++a+ ++++

l +++ *+* ++t+ +tt++ +++1’ ‘XI ++++ ++++ +*+ l +u ++t+ ++++*+++ +++ +++ +++ ++++++ +++ +++++ +*+ +CU+ +++ ++ +++++ +** + +++c

++ + l ++ Cl+ ++ et+*++ XI *+++++.+++++b *+*+++++l* ++++X+++C ++++ +I+*+++ +++++I +*+* +++t +x Xf f++++ I*++++*++ -+ *++*+++t++ *x+++ +++ +t++++i++++ ++++t* I +++ + L

+ ++ ++ ++ *+ +* + + / * + ++ x ** ++ ++ ++ ++

*+ +t+++,++++~*+ ++++

+++ x **t*++ +++I, +++ u *+ ++ t+ *

it++*+

++++++ If++/

we+

::

FIG.

+++

ct++++ ++++* lUf4.t

z ++*+t+ *++ ++++++

++a++ -+ ++t++++++++ ++++ f t+++*+ +++*++++ +++++++++* +++

++

++ *++ ++++I+ +++ u +++

+

++i + *+++I t+++++++u * tl++x **++

+++ +*+ +*+ *++

+-

+ti++*+ ++++I***

+x

++a f+++ ++ ix+ fit +*+ Cl+ t++t+ ++ + ++++++z ++++I + ++ ++ + * + +++lCl++++ +++*++tU+++ + +++++t+*++. ++ ++ ++++t +, ++ ++++ ++

++++++ 1 + ++**

++.

**

++++ * + + ‘XI++ +++ +++++*++ t +t+ ++ ++ +x+ + + ++++++ c ++ + a+++++ +++ x ++ +* ++++ trrr++++a ++ + ++ ++++++a+++*+++++ 1, ++*++ + ++i+++++ ++ +t*+++ ++ 11 ++++TI++ If +c+t ++. ++f ++* u ++++ +*+. +++ +++I++++’ I++*+

f

+I ++++ x +++

+*++I

3. (Continued)

I++ *+++t++ +++++++++++t+Cl+++++++ ++*++++ +++++++++++++++++++ +i

+e++*++* +++

*

* + + L

++*+++ *+ i,

++t++++++++ ++

*++

+.A++ -t++++ ++*++

+t+ *,I+ u

++*+++,:++L+”

+

+++++ *+.+t

++

++++++n++rt++++++ +++ +*+t++++++Cti+ 111

t/i++

+++:w:+:

++++++ ‘++I *t++

(e) and (f) same using Sobel’s operator. 194

EDGE DETECTION

USING CHARGE

(4

195

ANALOGY

(b)

FIG. 4. (a) Binary edge picture of Fig. 2b using 4 X 4 operator with threshold 5.0. (b) Same using local maxima. 7. CONCLUSIONS

The proposed analogy allows the determination of masks of various sizes for the detection of edges. An extended version of the Roberts Cross operator has also been developed which shows promising results. Recently, there has been considerable interest in multidimensional edge detection [8]. The procedures proposed in this paper can be directly extended to this case and the detectors of various sizes for this task can easily be developed. REFERENCES I. A. Rosenfeld and A. Kak, Digital Picture Processing, Academic Press, New York, 1976. 2. W. K. Pratt, Digital Image Processing, Wiley, New York, 1978. 3. L. S. Davis, A survey of edge detection techniques, Computer Graphics and Image Processing

4, 1975,

248-270. 4.

H. Kazmierczak, The potential field as an aid to character recognition, Inform. Paris,

Process.,

UNESCO,

1959, 244-247.

5. J. M. S. Prewitt, Object enhancement and extraction, in Picture Processing and Psychopictorics (B. S. Lipkin and A. Rosenfeld, Eds), pp. 75-149, Academic Press, New York, 1970. 6. I. E. Abdou and W. K. Pratt, Quantitative design and evaluation of enhancement/thresholding edge detectors, Proc. IEEE 67 (1979), 753-763. 7. R. Gonzalez and P. Win& Digital Image Processing, Addison-Wesley, Reading, Mass, 1977. 8. D. G. Morgenthaler and A. Rosenfeld, Multidimensional Edge Detection by Hypersurface Fitting, TR-877, Computer Science Center, Univ. of Maryland, Feb. 1980.