Sree Dip Unit3

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sree Dip Unit3 as PDF for free.

More details

  • Words: 6,601
  • Pages: 25
UNIT-III IMAGE ENHANCEMENT I. Introduction:Once if you get the image in digital form, the analysis and processing can begin. This processing of the image involves one or more algorithm being implemented on the image. There are many algorithms for image processing, some written for specific applications and some written for any application. A generally accepted classification labels the algorithms as low, mid and high level image processing algorithms. Low-level processing algorithms involves primitive operations such as image preprocessing to reduce noise, contrast enhancement and image sharpening. A lowlevel processing is characterized by the fact that both its inputs and outputs are images. Mid-level processing on images involves tasks such as segmentation (i.e., partitioning an image into regions or objects), description of those objects to reduce them to a form suitable for computer processing, and classification (recognition) of individual objects. A mid-level process is characterized by the fact that its inputs generally are images, but its outputs are attributes extracted from those images (ex: edges, contours (boundary) and identity of individual objects.) Finally, higher-level processing involves “ making sense” of an ensemble of recognized objects, performing the cognitive functions normally associated with vision i.e., these algorithms interfaces the image to some knowledge base. This associates shapes discovered during previous level of processing with known shapes of real objects. There are two types of low-level processing algorithm i). Statistical operations ii).Spatial operations The algorithms in statistical operations are independent of the position of the pixels, where as the algorithms for spatial operations are dependent on pixel position.

II. Some Definitions: Noise: -It is defined as undesirable errors in pixel values in an image, typically

caused by electrical interference what the image was captured. Histogram: The graphical representation of an image, as the number of pixels at a

particular gray level.

III. Statistical operations: - We can explain different statistical operations using following concepts. N.SREEKANTH., K.S.R.M.C.E

1

1. Some Basic Grey level transformations 2. Histogram equalization 3.Multi Image Operations (i.e., Enhancement using Arithmetic/ logic operations i.e., as we know that arithmetic and logical operations have to be done on multiple image (a + b) not for a single image). 1). Some Basic Grey Level Transformation: -

We begin the study of image enhancement techniques by discussing some gray level transformation functions. There are among the simplest of all image enhancement techniques. The different gray level transformations are i. Image negatives ii. Log transformations iii. Power law transformations. iv. Contrast stretching v. Global alternation in brightness vi. Thresholding vii. Bunching or gray level slicing i) Image negatives:-

The negative of an image with grey levels in the range [ 0, M ] obtained by using the negative transformation shown if Fig1, which is given by the expression, s= M- r. ---------------1 where, ‘s’ is new gray level value, ‘r’ old gray level value,

N.SREEKANTH., K.S.R.M.C.E

2

Reversing the intensity levels of an image in this manner produces the equivalent of photographic negatives. This type of processing is particularly suited for enhancing write or gray detail embedded in dark regions of an image, especially when the black areas are dominant in size. An example is shown if Fig.3.4. Consider the sub image shown below, where the range of gray levels are [0,9]. The resultant image is shown in second array. 1 6  5  6

2 4 5 2 4 3 7 2 4  2 5 6

8 3  4  3

original image

7 5 4 7 5 6 2 7 5  7 4 3

resultant image

ii)Log Transformations: The general form of the log transformation shown in Fig.3.3 is s= c log (1+|r|) ------------2 where, ‘s’ is new gray level value, ‘r’ old gray level value, ‘c’ is a constant, and it is assumed that r>= 0. The shape of the log curve in Fig3.3 shows that this transformation maps a narrow range of low gray-level values in the input image into a wider range of output levels. The opposite is true of higher values of the input levels. We would use a transformation of this type to expand the values of dark pixels in an image while compressing the higher-level values. The opposite is true of the inverse log transformation. Any curve having the general shape of the log functions shown in Fig.3.3 would accomplish this spreading/compressing of gray levels in an image. In fact, the power-law transformations discussed in next section are much more versatile for this purpose than the log transformations. However, the log function has the improvement

N.SREEKANTH., K.S.R.M.C.E

3

characteristic that it compresses the dynamic range of images with large variations in pixel values. An illustration of this log transformation is shown in Fig.3.5

iii). Power-Law transformations: Power law transformations have the basic form s= c(r)γ -----------3 where, ‘s’ is new gray level value, ‘r’ old gray level value, c and γ are positive constants. Sometimes equation.3 is written as s=c(r+ε)γ to account for an offset (that is, a measurable output when the input is zero). However, offsets typically are an issue of display calibration and as a result they are normally ignored in Eq. (3.2-3). Plots of s versus r for various values of γ are shown in Fig. 3.6. As in the case of the log transformation, power-law curves with fractional values of γ map a narrow range of dark input values into a wider range of output values, with the opposite being true for higher values of input levels. Unlike the log function, however, we notice here a family of possible transformation curves obtained simply by varying γ. As expected, we see in Fig. 3.6 that curves generated with values of V > 1 have exactly the opposite effect as those generated with values of γ < 1. Finally, we note that Eq.(3.23) reduces to the identity transformation when c = γ = 1.

N.SREEKANTH., K.S.R.M.C.E

4

A variety of devices used for image capture, printing, and display respond according to a power law. By convention, the exponent in the power-law equation is referred to as gamma [hence our use of this symbol in Eq. (3.2-3)]. The process used to correct this power-law response phenomena is called gamma correction. For example, cathode ray tube (CRT) devices have an intensity-to voltage response that is a power function, with exponents varying from approximately 1.8 to 2.5. With reference to the curve for γ=2.5 in Fig 3.6, we see that such display systems would tend to produce images that are darker than intended. This effect is illustrated in Fig. 3.7. Figure 3.7(a) shows a simple gray-scale linear wedge input into a CRT monitor. As expected, the output of the monitor appears darker than the input, as shown in Fig. 3.7(b). Gamma correction in this case is straightforward. All we need to do is preprocess the input image before inputting it into the monitor by performing the transformation s=r1/2.5 = r0.4. The result is shown in Fig. 3.7(c). when input into the same monitor, this gamma-corrected input produces an output that is close in appearance to the original image, as shown in Fig 3.7(d). A similar analysis would apply to other imaging devices such as scanners and printers. The only difference would be the device-dependent value of gamma.

iv). Contrast stretching One of the simplest piecewise a linear function is a contrast-stretching transformation. Low-contrast images can result from poor illumination, lack of dynamic range in the imaging sensor, or even wrong setting of a lens aperture during

N.SREEKANTH., K.S.R.M.C.E

5

image acquisition. The idea behind contrast stretching is to increase the dynamic range of the gray levels in the image being processed. Figure 3.10(a) shows a typical transformation used for contrast stretching. The locations of points (r1,s1) and (r2,s2) control the shape of the transformation function. If r1 = s1 and r2 = s2, the transformation is a linear function that produces no changes in gray level. If r1 = r2, s1 = 0 and s2 = L-1, the transformation becomes a thresholding function that creates a binary image, as illustrate in Fig. 3.2(b). Intermediate values of (r1,s1) and (r2, s2) produce various degree of spread in the gray levels of the output image, this affecting its contrast. In general, r1 ≤ r2 and s1 ≤ s2 is assumed so that the function is single valued and monotonically increasing. This condition preserves the order of gray levels, thus preventing the creation of intensity artifacts in the processed image.

Figure 3.10(b) shows an 8-bit image with low contrast. Fig. 3.10(c) shows the result of contrast stretching, obtained by setting (r1,s1) = (rmin, 0) and (r2, s2) = (rmax, L1) where rmin and rmax denote the minimum and maximum gray levels in the image, respectively. Thus, the transformation function stretched the levels linearly from their original range to the full range [0, L-1]. Finally, Fig. 3.10(d) shows the result of using the thresholding function defined previously, with r1 = r2 = m, the mean gray level in the image. v).Global alteration in Brightness:-This method is used to lighter or darker an

image. By seeing the histogram, a value can be added to or subtracted from all the N.SREEKANTH., K.S.R.M.C.E

6

image pixels giving the effect of the brightness being turned up or turned down. The histograms are shown below in Fig 3. By seeing the first histogram we can say that the image is darker. So by adding some constant value to all the pixels in the image, we get higher valued numbers when compared to your previous values. So if we display the image with new values we get a brighter image.

The code to count the number of pixels at a particular gray level is shown below. for(row=0;rowT is called an object point; otherwise, the point is called a background point . Fig.10.26(b) shows a slightly more general case of this approach, where three dominant modes characterizes the image histogram (for example, two types of light objects on a dark background). Here, multiple thresholding classifies a point (x,y) as belonging to one object class in T1< (x,y) ≤ T2, to the other object class if f(x,y)> T2 , and to the background if f(x,y) ≤ T1. In general, segmentation problems requiring multiple thresholds are best solved using region growing methods, which we are going to see in next section.

Based on the preceding discussion, thresholding may be viewed as an operation that involves tests against a function T of the form N.SREEKANTH., K.S.R.M.C.E

7

T= T [x, y , p(x , y), f(x , y)] where f(x,y) is the gray level of point (x,y) and p(x,y) denotes some local property of this point- for example, the average gray level of a neighborhood centered on (x,y). A thresholded image g(x,y) is defined as g(x,y)= 1 if f(x,y) > T 0 if f(x,y) ≤ T. Thus, pixel labeled 1(or any other convenient gray level) corresponds to objects, whereas pixels labeled 0(or any other gray level not assigned to objects) corresponds to the background. When T depends only on f(x,y) (i.e. only on gray level values) the threshold is called global threshold. If T depends on both f(x,y) and p(x,y), the threshold is called local threshold. If, in addition, T depends on the spatial coordinates x and y, the threshold is called adaptive or dynamic. To convert a gray image into a binary image, we have to choose a threshold, and then if the gray value of the given image is greater than that threshold, we assign a value and if less than or equal to threshold we will assign some other value. So that the resultant image will have only two values (binary). The different ways to choose the threshold are: i). Threshold= Average of all the gray values of the given image. ii). Threshold= (minimum value + maximum value)/2 iii). Threshold= Median of given gray values. Ex: If the given image is of size 64x64, in img[64][64] then the following is the logic to convert that into a binary image, for(i=0;i<64;I+++) for(j=0;j<64;j++) if(img[i][j] > th) img[i][j]=1 else img[i][j]=0

vii). Bunching:

To reduce the number of different gray levels in an image, to segment the image, to remove unwanted gray level gradations we use this bunching method. In this method close gray levels are combined, thus removing unwanted variations in data. This can be done by inspecting the histogram and combining close groups into single gray levels, or performed automatically by identifying a set of gray levels that N.SREEKANTH., K.S.R.M.C.E

8

will be allowed in the final image, and changing the gray leveling every pixel to its nearest allowed value. For example, the initial image 1 0  3  0

8 3 8 9

4 8 4 8

3 3 7 0

6 6 6 5

2 5 2 4

5 4 8 8

2 0 3 5

8 3 7 9

4 8 3 3

6 3 7 7

2 8 6 2

5 7  1  9

gives the following histogram. 0 **** 1 ** 2 ***** 3 ********* 4 ***** 5 ***** 6 ***** 7 ***** 8 ********* 9 *** If in the final image the allowed gray levels are only 0,3,6,9 i.e. in bunching procedure we group the gray levels (0,1) as 0, (2,3,4) as 3, (5,6,7) as 6 and (8,9) as 9. Then the resulting array and corresponding histogram is as shown below. 0 ****** 1 2 3 ******************* 4 5 6 *************** 7 8 9 ************

2). Histogram Equalization or Histogram Linearization: Histogram equalization can be use to enhance the appearance of an image and to make certain features more visible. It is means of re-mapping the pixel values in an image in an attempt to equalize the number of pixels with each particular value i.e. it is often valuable to find a function F(g) that will enhance the general contrast in an image, spreading the distribution gray levels – though this cannot be achieved exactly.

N.SREEKANTH., K.S.R.M.C.E

9

An approximation to the function can be identified by inspection of the histogram but an analytical approach is preferable. This is called histogram equalization. This tends to help in increase the contrast in parts of the histogram which are most heavily populated. This often reveals detail previously hidden. It improves contrast. It can be used on a whole image or just on a part of an image. As a result of histogram equalization, the image does not contain more data, but the data is simply presented better. The effect of histogram equalization, then, is to vary the contrast in an image by spreading the pixel gray levels across the whole of the gray-level range instead of just a small subset of it. This represents a fundamental method of improving the clarity of any image. Method: Given the number of pixels in a whole image is rowmax X colmax, and the number of gray levels over which the spread is required is g-levels, then the ideal histogram would be flat with the same number of pixels at each level: ideal number of pixels at each gray level= (rowmax X colmax)/g-levels. For example, if the size of the given image is 40X40 and if the different gray levels in the image are 0,1,2,3and 4. Then the ideal number of pixels at each gray level is 400/5=80. Now, intuitively, we want to allocate the pixels with the lowest gray level in the old image to gray level 0 in the new image, i.e. F(0)=0, where F(old gray value)= new gray value. If as a result of this allocation the new gray level ‘0’ has got less than its fair share (i.e. 80) of pixels, we allocate the pixels at the next lowest gray level in the old image also to gray level ‘0’ in the new image. When gray level ‘0’ in the new image has go something approaching its fair share of pixels we move upto gray level ‘1’ and operate the same algorithm with the unallocated pixels that have the lowest gray level in the old image. Formally the mapping of the old gray level to new gray level is as follows: If t(g) is the actual number of pixels at old gray level g or less(i.e. cumulative), then   g _ levels × t ( g )   F ( g ) = max 0, round   − 1  row max× col max   

Example1: Apply the histogram equalization for the given image. Here the problem and solution is given in the following Fig.

N.SREEKANTH., K.S.R.M.C.E

10

See the following Figures and observe the effect of this method. LINCON IMAGE AND HISTOGRAM

N.SREEKANTH., K.S.R.M.C.E

11

LINCON IMAGE AND HISTOGRAM AFTER EQUILIZATION

3. Logical operations on Images: As we know that the logical operations such as AND, OR, EXOR etc have to be applied on more than one image. So we can treat these also as operations on multi images. See the following images and their results after applying different operations on them.

III). Spatial operations:The algorithms in statistical operations are independent of the position of pixels, while the algorithms for spatial operations are dependent on pixel positions. 1. Basics of spatial filtering: A ‘mask’ or ‘filter’ or ‘ template’ or ‘window’, is a small (say, a 3x3) 2D array in which the values of mask coefficients determine the nature of the process. Enhancement techniques based on this type of approach is referred to as “mask processing “ or “filtering”. The mechanism of spatial filtering is shown in fig 1.the process consists simply of moving the filter mask from point to point in an image. At each point (x, y), the response of filter at that point is calculated using a predefined relationship.

N.SREEKANTH., K.S.R.M.C.E

12

For linear spatial filtering, the response is given by the sum of the products of the filter coefficients and the corresponding image pixels in the area spanned by the filter mask. For the 3x3 mask shown in Fig.3.32, the result (R) of linear filtering with the filter mask at a point (x,y) in the image is R=w(-1,-1)f(x-1,y-1)+w(-1,0)f(x-1,y)+………+w(0,0)f(x,y)+……………..+ w(1,0)f(x+1,y)+ w(1,1)f(x+1,y+1). This whole process of moving the mask, multiplying and adding is known as ‘Convolution’. Generally, when we are choosing the mask, it is good to choose the masks of odd sizes like 3x3, 5x5 and soon, because the masks of size 2x2, 4x4 soon are awkward (difficult) to implement because they do not have a clear center. An important consideration in implementing neighborhood operations for spatial filtering is the issue of what happens when the center of the filter approaches the border of the image. If the center of the mask moves any closes to the border, one or more rows or columns of the mask will be located outside the image plane. There are several ways to handle this situation. 1. The simplest way is to limit the excursion of the center of the mask to be at a distance no less than (n-1)/2 pixels from the border, where ‘n’ is the size of the mask. The resulting filtered image will be smaller than the original, but all the pixels in the filtered image will have been processed with the full mask. 2. Apply the mask for the available values in the image. i.e. if the result is required to be the same size a the original, then the approach typically employed is to filter all pixels only with the section of the mask that is fully contained in the image. With this approach, there will be bands of pixels near the border that will have been processed with a partial filter mask. 3. Other approach includes ‘padding’ the image by adding rows and columns of 0s (or other constant gray level), or padding by replicating rows and columns. The padding is then stripped off at the end of the process. This keeps the size of the filtered image the same as the original, but the values of the padding will have an effect near the edges that becomes more prevalent(i.e.)wide spread) as the size of the mask increases. 4. Among all these three methods, by using the first method we will obtain a perfectly filtered image.

iV).Filters: N.SREEKANTH., K.S.R.M.C.E

13

Basically filters are of two types: 1). Smoothing filters or low pass filters. 2). Sharpening filters or high pass filters. 1). Smoothing Filters: These smoothing filters are mainly classified into two types: i). Smoothing linear filters (or) Averaging filters ii). Smoothing nonlinear filters (or) Order statistic filters. i). Smoothing linear filters (or) Averaging filters: Smoothing filters are used for blurring and for noise reduction. Blurring is used in preprocessing steps, such as a removal of small details from an image prior to extract large objects, and bridging (filling) of small gaps in lines or curves. The output of a smoothing linear filter is simply the average of the pixels contained in the neighborhood of the filter mask. These filters are some times referred as ‘averaging filters’. The example of these filters are shown below.

Note that the constant multiplier ‘1/9’ in the first mask is equal to the sum of the values of its coefficients, as is required to compute an average and is same for the second mask. By using these filters, we can remove high frequencies in an image (i.e. sudden changes in pixel values) while retaining (or passing through) the low frequencies. So these filters are also called as “Low pass filters”. An averaging filter in which all coefficients are equal is sometime called as ‘Box Filters’. To design a smoothing filter it is not compulsory to have all the coefficients as equal. The different masks of this type, for smoothing linear filters as the second one shown in above diagram and the one shown below. 1 3 1 1  × 3 16 3 32 1 3 1

These masks(i.e. second one in Fig3.34 and this one) yields a so-called weighted average, thus giving more importance (weight) to some pixels at the expense of others. In the above masks, the pixels at the center of the mask is multiplied by a higher value than any other, thus giving this pixel more importance in N.SREEKANTH., K.S.R.M.C.E

14

the calculation of average. The other pixels are inversely weighted as a function of their distance from the center of the mask. The diagonal terms are further away from the center than the orthogonal neighbors (by a factor of root(2)) and, thus, are weighted less than these immediate neighbors of the center pixel. The basic strategy behind weighing the center point the highest and then reducing the value of the coefficients as a function of increasing distance from the origin is simply an attempt to reduce blurring in the smoothing process. We could have picked other weights to accomplish the same general objective. However, the sum of all the coefficients in the mask of Fig 3.34(b) is equal to 16, an attractive feature for computer implementation because it has an integer power of 2. You can observe these filtering effects in the following Figs.

As mentioned earlier, an important application of spatial averaging is to blur an image to get a gross representation of objects of interest, such that intensity of smaller objects blends with the background and larger objects become ‘blob like’ and easy to detect.

ii). Smoothing nonlinear filters (or) Order statistics filters: Order statistics filters are nonlinear spatial filters whose response is based on ordering(ranking) the pixels contained in the image area encompassed by the filter, and then replacing the values of the center pixel with the value determined by the ranking result. N.SREEKANTH., K.S.R.M.C.E

15

The different order statistics filters are: a). Median filters. b). Max. filters. c). Min. filters d). Modal filters e). k-closest averaging. In the median filters, we will replace the value of a pixel by the median of the gray levels in the neighborhood of that pixels(the original value of the pixel is included in the computation of the median). Median filters are quite popular because, for certain types of random noise, they provide excellent noise reduction capabilities, with considerably less blurring than linear smoothing filters. Median filters are particularly effective in the presence of ‘impulse noise’ also called as ‘salt-and-pepper noise’ because of its appearance as white and black dots super imposed on an image. You can observe this in the following Fig.

In Max. filters, we will replace the pixel value with the maximum value of the gay levels in the neighborhood of that pixel(the original value of the pixel is included in the computation). These Max. filters are useful in finding the brightest points in an image. The min. filters are useful in finding the darkest points in the image. The results are shown below.

N.SREEKANTH., K.S.R.M.C.E

16

In modal filtering, we will replace the pixel value with the most popular value of all the gray levels in the neighborhood including that value. In k-closest averaging, Step-1: All the pixels in the window are sorted. Step-2: The ‘k’ pixel values closest (i.e. with some constant difference) in value to the target pixel(usually the target pixel is the center of the window) are averaged. Step-3: Then that average value will be plotted in the center. Note: In both median filtering and k-closest averaging, sorting creates a heavy load on the system. In addition to this, the k-closest averaging requires differences and then averages to be calculated. Therefore, k-closest averaging is slower than medial filtering.

2.Sharpening filters (or) High pass filters: The principal objective of sharpening is to highlight fine detail in an image or to enhance detail that has been blurred. The sharpening can be applied in electronic printing, medical imaging, industrial inspection and autonomous guidance in military systems. Since averaging is analogous to integration, it is logical to conclude that sharpening could be accomplished by spatial differentiation. Sharpening filters are of two types: i). First order derivative filters ii). Second order derivative filters. Foundation: In the two sections that follow, we consider in some detail sharpening filters that are based on first- and second-order derivatives, respectively. Before proceeding with that discussion, however, we stop to look at some of the fundamental properties of these derivatives in digital context. To simplify the explanation, we focus attention on one-dimensional derivatives. In particular, we are interested in the behavior of these derivatives I areas of constant gray level (flat segments), at the onset and end of discontinuities (step and ramp discontinuities), and along gray-level ramps. These types of discontinuities can be used to model noise points, lines, and edges in an image. The behavior of derivatives during transitions into and out of these image features also in of interest. The derivatives of a digital function are defined in terms of differences. There are various ways to define these differences. However, we require that any definition we use for a first derivative (1) must be zero in flat segments ( areas of constant graylevel values); (2) must be nonzero at the onset of a gray-level step or ramp; and (3) must be nonzero along ramps. Similarly, any definition of a second derivative (1) must be zero in flat areas; (2) must be nonzero at the onset and end of a gray-level N.SREEKANTH., K.S.R.M.C.E

17

step or ramp; and (3) must be zero along ramps of constant slope. Since we are dealing with digital quantities whose values are finite, the maximum possible graylevel change also is finite, and the shortest distance over which that change can occur is between adjacent pixels. A basic definition of the first-order derivative of a one-dimensional function f(x) is the difference ∂f = f ( x + 1) − f ( x ) ∂x

We used a partial derivative here in order to keep the notation the same as when we consider an image function of two variables, f(x,y), at which time we will be dealing with partial derivatives along the two spatial axes. Use of partial derivative in the present discussion does not affect in any way the nature of what we are trying to accomplish. Similarly, we define a second-order derivative as the difference ∂2 f = f ( x + 1) + f ( x − 1) − 2 f ( x) ∂x 2

It is easily verified that these two definitions satisfy the conditions stated previously regarding derivatives of the first and second order. To see this, and also to highlight the fundamental similarities and differences between first-and second-order derivatives in the context of image processing, consider the example shown in Fig.3.38.

N.SREEKANTH., K.S.R.M.C.E

18

Figure 3.38(a) shows a simple image that contains various solid objects, a line, and a single noise point. Figure 3.38(b) shows a horizontal gray-level profile (scan line) of the image along the center and including the noise point. This profile is the one-dimensional function we will use for illustrations regarding this figure. Figure 3.38(c) shows a simplification of the profile, with just enough numbers to make it possible for us to analyze how the first-and second-order derivatives behave as they encounter a noise point, a line, and then the edge of an object. In our simplified diagram the transition in the ramp spans four pixels, the noise point is a single pixel, the line is three pixels thick, and the transition into the gray-level step takes place between adjacent pixels. The number of gray levels was simplified to only eight levels. Let us consider the properties of the first and second derivatives as we transverse the profile from left to right. First, we note that the first-order derivative is nonzero along the entire ramp, while the second-order derivative is nonzero only at the onset and end of the ramp. Because edges in an image resemble this type of transition, we conclude that first-order derivatives produce “thick” edges and secondorder derivatives, much finer ones. Next we encounter the isolated noise point. Here, the response at and around the point is much stronger for the second-than for the first-order derivative. Of course, this is not unexpected. A second-order derivative is much more aggressive than a first-order derivative in enhancing sharp changes. Thus, we can expect a second-order derivative to enhance fine detail (including noise) much more than a first-order derivative. The thin line is a fine detail, and we see essentially the same difference between the two derivatives. If the maximum gray level of the line had been the same as the isolated point, the response of the second derivative would have been stronger for the latter. Finally, in this case, the response of the two derivatives is the same at the graylevel step (in most cases when the transition into a step is not from zero, the second derivative will be weaker). We also note that the second derivative has a transition from positive back to negative. In an image, this shows as a thin double line. This “double-edge” effect is an issue that will be important in Unit III, where we use derivatives for edge detection. It is of interest also to note that if the gray level of the thin line had been the same as the step, the response of the second derivative would have been stronger for the line than for the step. In summary, comparing the response between first-and second-order derivatives, we arrive at the following conclusions. (1) First-order derivatives generally produce thicker edges in an image. (2) Second-order derivatives have a stronger response to fine detail, such as thin lines and isolated points. (3) First order derivatives generally have a stronger response to a gray-level step. (4) Second-order derivatives produce a double response at step changes in gray level.

N.SREEKANTH., K.S.R.M.C.E

19

We also note of second-order derivatives that, for similar changes in gray-level values in an image, their response is stronger to a line than to a step, and to a point than to a line. In most applications, the second derivative is better suited than the first derivative for image enhancement because of the ability of the former to enhance fine detail. i). First Order Derivative Filters:

The most common of differentiation in image processing application is the gradient. For a function (i.e. image) f(x, y) the gradient of f at coordinates (x, y) is defined as the vector  ∂f    f=  ∂∂fx     ∂y 

-----------------1

the magnitude of this vector 2

mag(f)=

 ∂f   ∂f    +    ∂x   ∂y 

2

------2

is the basis for various approaches to image differentiation. Consider the image region shown in Fig.4.20 w1 w2 w3 w4 w5 w6 w7 w8 w9 Equation 2 can be approximated at z5 in a number of ways. The simplest is to use the difference (z5-z8) in x-direction and (z5-z6) in y-direction, combined as mag(f) = (z5 − z8 )2 + (z5 − z6 )2 -----------3 Instead of using squares and square roots, we can get the similar results by using the absolute values. mag(f) = z 5 + z8 + z 5 − z 6 -----------4 Another approximation of equ.2, is to use the cross difference So mag(f) =

(z 5 − z 9 )2 + (z 6 − z8 )2 -----------5

So by using absolute values, the equ.5 can be written as mag(f) = z 5 − z 9 + z 6 − z8 -----------6

N.SREEKANTH., K.S.R.M.C.E

20

Equations 4 and 6 can be implemented by using masks of size 2x2. The equation 4 can be implemented by taking the absolute value of the response of the two masks and summing the result, as shown below. 1 − 1 0 0   

 1 0 − 1 0  

The equation 6 can be implemented by taking the absolute value of the response of the two masks and summing the results. These two masks are known as ‘Robert’s cross-gradient operators’. 1 0  0 − 1  

 0 1 − 1 0  

Masks of even size are awkward(difficult) to implement. So, an approximation of equ.2, at point z5, but now using 3x3 neighborhood is mag(f)=| (z7+z8+z9) - (z1+z2+z3) | + | (z3+z6+z9) - (z1+z4+z7) | --------7 i.e. the difference between the third and first row of a 3x3 region approximates derivation is x-direction, and the difference between third and first column approximates the derivation in y-direction. The masks are shown below, called ‘Prewitt operators’, and can be implemented by equ.7 − 1 − 1 − 1 0 0 0    1 1 1 

N.SREEKANTH., K.S.R.M.C.E

− 1 0 1 − 1 0 1   − 1 0 1

21

The masks shown below are called ‘Sobel operators’, which are another approximation of equ.2. − 1 − 2 − 1 0 0 0    1 2 1 

 − 1 0 1 − 2 0 2    − 1 0 1 

i.e. mag(f)=| (z7+2z8+z9) - (z1+2z2+z3) | + | (z3+2z6+z9) - (z1+2z4+z7) | --------8

Sobel operators have the advantage of providing both a differencing effect and smoothing effect. Because derivatives enhance noise, the smoothing effect is particularly attractive feature of the Sobel Operators. Note that all the mask coefficients sum to ‘0’, indicating a response of ‘0’ in constant areas, as expected of a derivative operator.

N.SREEKANTH., K.S.R.M.C.E

22

ii). Second order derivative filters: First order derivatives, generally produce thicker edges in an image, where as second order derivatives have a stronger response to fine detail, such as thin lines and isolated points. In most applications, the second derivatives are better suited than the first derivatives for image enhancement because of the ability of the former to enhance fine detail. For a function f(x,y) (image), the second order derivative is defined as a vector ∂ 2 f  2 ∂x 2 ∇ f = 2 ∂ f  ∂y 2 

   -----------1   

where ∂2 f = f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y ) -----------2 ∂x 2

and ∂2 f = f ( x1 , y + 1) + f ( x, y − 1) − 2 f ( x, y ) -----------3 ∂y 2

then the magnitude of the vector is define as mag (∇ 2 f ) =

 ∂2 y   ∂2 f  2  +  2  ∂x   ∂y

  -----------4 

Equ.4 can be implanted by a digital form by using the following equation. mag(2f)= [f(x+1,y)+ f(x-1,y)+ f(x,y+1)+ f(x,y-1)] - 4 f(x,y) ------5 This equation can be implemented by the mask shown below. 0 1 0  1 − 4 1   0 1 0

If we include the diagonal neighbors also, then the mask is given by

N.SREEKANTH., K.S.R.M.C.E

23

1 1 1 1 − 8 1   1 1 1

The above two masks are known as ‘Laplacian’s operators’. The other two implementations of Laplacian’s are  0 −1 0  − 1 4 − 1    0 − 1 0 

− 1 − 1 − 1 − 1 8 − 1   − 1 − 1 − 1

These two are based on a definition of Laplacian, is the negative of the one we used here. They also gives the equivalent result, but the difference in sign must be kept in mind when combining (by addition or subtraction) a Laplacian’s filtered image with another image.

VI). High boost filtering or High frequency filtering and Unsharp masking: This method is one of the basic tools for image processing applications in the printing and publishing industry. A high pass filtered image may be computed as the difference between the original and a low pass filtered version of that image, i.e. High pass= original – low pass -------------------1 Multiplying the original by an amplification factor, denoted by ‘A’ yields the definition of high boost or high frequency emphasis filter: High boost = (A)(Original) - low pass = (A-1) Original + Original – low pass } ----------2 = (A-1) Original + High pass If A=1, yields the standard high pass filter. When A>1, part of the original is added back to the high pass result, which restores partially the low frequency component, lost in the high pass filtering. The result is that the high-boost image looks more like the original image, with a relative degree of edge enhancement that depends on the value of ‘A’.

N.SREEKANTH., K.S.R.M.C.E

24

The general process of subtracting a blurred image (i.e. low pass filtered image) from the original as given in the first line of equ.2 is called ‘unsharp masking’. This method is one of the basic tools for image processing applications in the printing and publishing industry. In terms of implementation, the preceding results can be combined by letting the center weight of the mask shown in Fig 4.26 be, w= 9A-1

------------ 2

with A >= 1. The value of A determines the nature of the filter. − 1 − 1 − 1 1  × − 1 w − 1 9  − 1 − 1 − 1

N.SREEKANTH., K.S.R.M.C.E

25

Related Documents

Sree Dip Unit3
November 2019 1
Sree Dip Unit1
November 2019 3
Unit3
May 2020 6
Unit3
May 2020 10
Dip
October 2019 38