Total Variation Image Edge Detection - wseas

0 downloads 0 Views 723KB Size Report
Abstract: We studied total variation anisotropic image edge detection. ... Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and .... the Laplacian on a digital image, we discretize it as .... [2] Rafael Gonzalez and Richard E. Woods, Digital ... Fourth Edition, Springer, 1982.
Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

Total Variation Image Edge Detection PETER NDAJAH Graduate School of Science and Technology, Niigata University, 8050, Ikarashi 2-no-cho, Nishi-ku, Niigata, 950-2181, JAPAN [email protected]

HISAKAZU KIKUCHI Department of Electrical and Electronics Engineering, Niigata University, 8050, Ikarashi 2-no-cho, Nishi-ku, Niigata, 950-2181, JAPAN [email protected]

Abstract: We studied total variation anisotropic image edge detection. We derive the total variation functional from first principles rather than from measure theory and distribution theory. The Euler-Lagrange equation of the total variation functional gives a steady state equation. The steady state equation acts as an anistropic filter on an image. We compared the total variation method to the Marr-Hildreth method and found that the total variation method gives stronger edges and greater image detail at any scale than the Marr-Hildreth method. The zero crossing method used to find edge points in the Marr-Hildreth method is not effective for the total variation method. simple thresholding appears to be more effective. Key–Words: Tv, Anisotropic, Zero crossing, Total variation, Euler lagrange, LoG

1 Introduction

2 The Total Variation Functional

Edge detection is a fundamental operation in image processing. Most methods for edge detection can be grouped into two basic categories:

The total variation of a function is the total measure of the change in the function. The total variation of a function is defined as

1 Search-based methods which compute the edge strength using first order derivatives.

TV =

|f (xi+1 ) − fi |

(1)

1

2 Zero-crossing-based methods which search for zero-crossings in a second order derivative expression computed from the image. This could be the zero crossings of the Laplacian or a nonlinear differential expression.

we can multiply and divide equation 1 by Δx to obtain  n    f (xi+1 ) − fi   Δx  TV =   Δx

Historically, the Marr-Hildreth edge detection method has been the most popular edge detection method based on second order partial differential equations. It uses the Lapalacian to filter an image. Then the zero-crossings algorithm is then applied on the image to detect the edges. The Laplacian used in the MarrHildreth model is a linear partial differential equation and it has isotrpic filtering properties. We approach the problem differently. We begin from the total variation functional for a 2 dimensional image. We minimize the functional by the Euler-Lagrange method. This results is a nonlinear steady state second order partial differential equation. Because the operator is nonlinear, applying it to an image results in an anisotrpic filtering of the image. The filtered image when compared to images filtered using the Marr-Hildreth operator shows stronger image edges. ISBN: 978-960-474-276-9

n 

(2)

i=0

We can transform equation 2 into the continuous form by writing it as      f (x + h) − f (x)   = |f  (x)|dx  (3)   h Images are two dimensional spatial functions. To find the total variation of a two-dimensional mathematical object, we consider the directional derivative of a scalar function f (x) = f (x1 , x2 , ..., xn ) along a unit vector u = (u1 , ..., un ). The directional derivative is defined to be the limit ∇u f (x) = lim

h→0+

246

f (x + hu) − f (x) h

(4)

Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

We assume the function f to be differentiable at x. This means that the directional derivatives exist along any unit vector u, and one has

4 The Euler Equation of the Total Variation Functional

∇u f (x) = ∇f (x) · u

We restate the total variation functional (following the general convention) as  J(u) = |∇u|dxdy (12)

(5)

For an image we represent the directional derivatives by i,j so that  ∇x f (x) = ∇f (x) · i = ∂f ∂x (6) ∇y f (x) = ∇f (x) · j = ∂f ∂y

where u is our image function and it depends spatially on two independent variables x and y. We state the form of the Euler-Lagrange equation for the case of one dependent variable and several independent variables. Let  F (x1 , ..., xn , f, fx1 , ..., fxn )dx (13) I(f ) =

The components ∇x f (x) and ∇y f (x) are orthogonal so that ∂f ∂f +j (7) ∇f (x) = i ∂x ∂y and the inner product is    2 ∂f 2 ∂f + ∇f (x), ∇f (x) = |∇f | = ∂x ∂y (8) Therefore, equation(3) in two dimensions can be written as   |∇f | dxdy (9)

Ω

∂f . (12) is extremized only if f satisfies where fxi = ∂x i the partial differentiation equation: n

∂F  ∂ ∂F − =0 ∂f ∂xi ∂fxi i=1

We observe that the total variation functional can be written as  J(u, ∇u, x, y) = |∇u|dxdy (15)

I

which is the total variation of f over the entire image surface I. An important property of the total variation of a function f is that it uses the derivative of f to measure the total change in f .

The right hand side of the equation tells us that the functional does not depend on u but it depends on its gradient because

3 Total Variation of an Image (9) is a norm. and the vectorial components of ∇f are ∂f ∂f ∂x and ∂y . So, the norm 

 

  I

|∇f |dxdy =

I

∂f ∂x

2

 +

∂f ∂y

 |∇u| =

2 dxdy (10)

2

=f

(16)

(17)

i=1

= 0 since the functional J does not depend on but u. So we have 2  ∂ ∂f ∂ ∂f ∂ ∂f = + ∂xi ∂xi ∂x1 ∂x1 ∂x2 ∂x2

(18)

i=1

|∇f | =

 y

+

∂u ∂y

∂J ∂f

as:

x



2

∂f = f (x, y + 1) − f (x, y) ∂y Therefore, the discrete total variation is written

y

2

∂J  ∂ ∂f − =0 ∂f ∂xi ∂xi

∂f = f (x + 1, y) − f (x, y) ∂x

x

∂u ∂x

and there is no term in u on the right hand side. So the Euler equation for the total functional variation is:

In the discrete form,



(14)

but in an image, x1 = x and x2 = y and so (17) becomes [f (x + 1, y) − f (x, y)]2 + [f (x, y + 1) − f (x, y)]2 2  ∂ ∂f ∂ ∂f ∂ ∂f + (19) = (11) ∂xi ∂xi ∂x ∂x ∂y ∂y i=1

ISBN: 978-960-474-276-9

247

Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

This is equivalent to differentiating |∇u| with respect to x and y. We made f = |∇u| for simplicity. So differentiating with respect to x, we get

∂ ∂f = ∂x ∂x



∂u ∂x

2

 +

∂u ∂y

2 12

5 Partial Differential Equations Image Filters Prior to edge detection, a partial second order partial differential expression (usually a Laplacian) is used to filter an image. The result of this filtering is then tested for zero crossings. This is based on the MarrHildreth(1980) model. The use of the Laplacian operator ∂2 ∂2 L= + (27) ∂x2 ∂y 2

=

1 ∂u ∂u 1  1 · ∂x = |∇u| · ∂x   2 2

∂u 2 + ∂u ∂x ∂y

(20)

to operate on an image produces a Laplacian filtered image. This is a basic step in image segmentation using partial differential equations. An example of such segmentation is edge detection. The approach basically consists of defining a discrete formulation of the second order derivative and then constructing a filter mask based on the formulation. The mask is then convolved with the image to produce the filtered image. The Laplacian filter is isotropic. On the other hand the discretized form of the Laplacian can be applied directly to the image. The results are the same. Isotropic filters are rotation invariant in the sense that rotating the image and then applying the filter gives the same result as applying the filter first and then rotating the image. The simplest isotropic derivative operator is the Laplacian [9], which for a function(image) of two variables, is defined as

Also, ∂ ∂f = ∂y ∂y



∂u ∂x

2

 +

∂u ∂y

2 12

=

1 ∂u ∂u 1 = · 1 ·  |∇u| ∂y

∂u 2  ∂u 2 2 ∂y + ∂x ∂y

(21)

then (18) becomes ∂u

∂u ∂ ∂ ∂y · ∂x + · = ∂x |∇u| ∂y |∇u|   ∂ ∂u ∂ ∂u 1 + (22) |∇u| ∂x ∂x ∂y ∂y

We can write (19) in vector form as: 1 |∇u|



   ∂ ∂ ∂u ∂u i +j · i +j = ∂x ∂y ∂x ∂y ∇u ∇· |∇u|

∇2 f =



 ∂2u ∂2u + 2 = ∂x2 ∂y Δu ∇2 u = |∇u| |∇u|

(23)

(24)

∇2 f (x, y) = f (x + 1, y) + f (x − 1, y) + f (x, y + 1)

From the foregoing analysis, the Euler equation of the total variation functional is min J(u) = Jmin (u) = ∇ ·

∇u |∇u|

+ f (x, y − 1) − 4f (x, y) (30)

(25)

which filters the image. This equation can also be implemented using the filter mask in Table 1. The mask gives an isotropic result for rotations. Figure 1 shows the effect of this mask on an image. A variant of the above mask which works better is Table 2. It is also isotropic.

or, Jmin (u) =

ISBN: 978-960-474-276-9

∇2 u |∇u|

(28)

Because derivatives of any order are linear operators, the Laplacian is also a linear operator. To implement the Laplacian on a digital image, we discretize it as follows:  2 ∂ = f (x + 1, y) + f (x − 1, y) − 2f (x, y) ∂x2 ∂2 = f (x, y + 1) + f (x, y − 1) − 2f (x, y) ∂y 2 (29) So, adding the two equations,

This can be rewritten as 1 ∇u = ∇· |∇u| |∇u|

∂2f ∂2f + ∂x2 ∂y 2

(26)

248

Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

0 1 0

1 -4 1

0 1 0

TV filter

Table 1: Mask 1 Image filtered with Laplacian mask whose central value is −4

Original Image

Figure 3: TV Filtered Image of Shapes

Figure 1: Image Filtered with Mask 1 1 1 1

1 -8 1

advantages over the traditional Laplacian filter. We present these advantages in the next section.

1 1 1

7 Characteristics of The Total Variation Filter

Table 2: Mask 2 Original Image

We state some reasons that give the total variation filter an advantage over the traditional Laplacian filter:

Image Filtered with Mask 1

1. The total variation filter is better at edge-sensitive filtering than the Laplacian. A comparison of the TV-filtered images (Figures 7 and 9) to the other images (Figures 2 to 5) shows that the edges in the TV-filtered images are conspicuously more pronounced and detailed. 2. The total variation filter is quite texture-sensitive. This is very obvious in Figure 3. The detailed changes in the texture of the images are clearly captured in the filtered image.

Figure 2: Original Shapes Image and its Laplacian Filtered Image

6 The Total Variation Filter

3. A drawback of the Laplacian is that during the filteration process, a double edge is formed. The total variation filter overcomes this disadvantage (see Figures 4 to 7). There is only one edge formed and it is appreciably strong. Unlike the Laplacian filter, the TV filter does not show false edges. The images being compared below show this clearly. To illustrate this point, we show an image with sharp edges (the noisesquare image). The image was filtered with Mask 1, Mask 2 and the total variation filter. Mask 1 and Mask 2 are Laplacian filters and so the corresponding images are scaled to show the presence of double edges. This is not so in the case of the total variation filter. There is only one edge. However, the total variation filtered cannot be scaled.

We use the Euler-Lagrange equation of the total variation functional as a filter in place of the Laplacian. Jmin (u) =

∇2 u |∇u|

(31)

But we can see that the Jmin (u) is related to the Laplacian. The numerator of Jmin (u) is the Laplacian. The difference is that the denominator is |∇u|. Now, |∇u| is a function. It takes different values at different pixels in the image. Both the Laplacian and Jmin (u) represent diffusion. The Laplacian is isotropic but the total variation filter is anisotropic. Below we present images filtered with the total variation filter. The anisotropic property of the TV filter gives it some ISBN: 978-960-474-276-9

249

Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

Figure 4: Image filtered with Mask 2: It is Scaled to Show Double Edges

Figure 6: Magnified Region of Interest Showing Double Edges in Laplacian Filtered Image

Figure 7: Magnified Region of Interest Showing Single Edge in TV-Filtered Image

Figure 5: Image filtered with TV Filter: No double Edges

σ is the standard deviation of G(x, y) and it acts as a scaling factor. It determines the scale of the structures that can be detected. For edge detection using the Laplacian operator, we apply the operator to the smoothed image D(x, y) i.e. ∇2 D(x, y). The resulting image is called the Laplacian of Gaussian (LoG) image. Likewise for the total variation nolinear oper2 D(x,y) . ator, we apply ∇ |∇D| Below we show results of edge detection based on the LoG images and total variation filtered images. Edge detection for both kinds of images, do not follow exactly the same process. The traditional method of detecting edges in LoG images is by zero crossings. Fig-

8 Detecting Edges Edge detection first begins with a smoothing of the image. This is necessary to remove noise and image structures below a certain scale. This is accomplished by convolving the Gaussian function G(x, y) = e−

x2 +y 2 2σ 2

(32)

with the image function u(x, y) i.e. D(x, y) = G(x, y)  u(x, y) ISBN: 978-960-474-276-9

(33) 250

Recent Researches in Communications, Automation, Signal Processing, Nanotechnology, Astronomy and Nuclear Physics

ure 8 shows an example of this. However, this method is not effective for the total variation filtered images. The zero crossings do not give strong edges as expected. Therefore, for application purposes, it is best to avoid the use of zero crossings in total variation filtered images. A simple thresholding gives a better result. Figure 9 was obtained by thresholding the total variation filtered image at 0. Generally, the edges in the total variation filtered image are stronger than edges in the LoG image. The pixels in the LoG image were magnified by a factor of 30 to give the result shown in Figure 8. But even after a magnification of the pixel strength, the edges in the LoG image still do not possess the same strength and detail as the edges in the total variation filtered image. Magnifying the pixel strength of total variation filtered risks destroying the edges. Figure 9: Edge Detection in Total variation Filtered Image with Thresholding at 0 and σ = 2 filtered images. Simple thresholding is more effective. References: [1] Tony F. Chan and Jianchong Shen, Image Processing and Analysis: Variational, PDE, Wavelet and Stochastic Methods, SIAM. 2005. [2] Rafael Gonzalez and Richard E. Woods, Digital Image Processing, Pearson Prentice Hall, 2008. [3] Al Bovik, Handbook of Image and Video Processing, Academic Press, 2000. [4] D. Marr and E. Hildreth, Theory of Edge Detection, Proc. R. Soc. Lond. B 207, 187-217,, 1980. [5] Mark Nixon and Alberto Aguado, Feature Extraction and Image Processing, Second Edition, Academic Press, 2008. [6] J.R. Parker, Algorithms for Image Processing and Computer Vision, Wiley Computer Publishing, 1997. [7] Fritz John, Partial Differential Equations, Fourth Edition, Springer, 1982. [8] J.D. Logan, An Introduction to Nonlinear Partial Differential Equations, Second Edition, John Wiley and Sons, Inc., 2008. [9] Rosenfeld A. and Kak A.C. Digital Picture Processing, Academic Press, 1976. [10] Ehsan Nadernajad, Sara Sharifzadeh and Hamid Hassanpour, Edge Detection Techniques: Evaluation and Comparisons Applied Mathematical Sciences,Vol. 2, 2008, no. 31, 1507-1520.

Figure 8: Zero Crossing of LoG Image with Pixel Strength Magnification of 30 and σ = 2

9 Conclusion We have compared the total variation edge detection method to the Marr-Hildreth method and found that: 1. The TV method gives stronger edges and detail than the Marr-Hildreth method. 2. The TV filter produces only a single strong edge rather than the double edges in the Laplacian filtered image. 3. The zero crossing method used in detecting edges in the LoG images is not effective in TV ISBN: 978-960-474-276-9

251