Implementation Of Generalized Unsharp Algorithm For Digital Image IMPLEMENTATION OF GENERALIZED UNSHARP MASKING ALGORITHM FOR DIGITAL IMAGE

1GANESH A. YELPALE, 2K.R.DESAI

B.V.C.E,Kolhapur. Kolhapur, India.

Abstract— Enhancement of contrast and sharpness of an imageis required in many applications. Unsharp masking is a classical tool for sharpness enhancement. We propose a generalized unsharp masking algorithm using the exploratory data model as a unified framework. The proposed algorithm is designed to address three issues: 1) simultaneously enhancing contrast and sharpness by means of individual treatment of the model component and the residual, 2) reducing the halo effect by means of an edge-preserving filter, and 3) solving the outof- range problem by means of log-ratio and tangent operations. We also present a study of the properties of the log-ratio operations and reveal a new connection between the Bregman divergence and the generalized linear systems. This connection not only provides a novel insight into the geometrical property of such systems, but also opens a new pathway for system development. We present a new system called the tangent system which is based upon a specific Bregman divergence. The proposed algorithm is able to significantly improve the contrast and sharpness of an image. In the proposed algorithm, the user can adjust the two parameters controlling the contrast and sharpness to produce the desired results. This makes the proposed algorithm practically useful. Keywords- Bregman divergence, generalized linear system, image enhancement, unsharp masking.

I. INTRODUCTION algorithm is based upon the imaging model in which the observed image is formed by the product of scene Enhancement the sharpness and contrast of images reflectance and luminance. The task is to estimate the has many practical applications. There has been reflectance from the observation. Many algorithms continuous research into the development of new use the assumption that the luminance isspatially algorithms. We first briefly review previous works smooth. The illuminance is estimated by using a low- which are directly related to our work. These related pass filter or multi resolution or formulating the works include unsharp masking and its variants, estimating problem as a constrained optimization histogram equalization, retinex and dehazing problem [7]. To reduce the halo effect, edge- algorithms, and generalized linear systems. We then preserving filters such as: adaptive Gaussian filter [8], describe the motivation and contribution of this weighted least-squares based filters [9] and bilateral paper. filters [7], [10] are used.

II. RELATED WORK III. CLASSICAL UNSHARP MASKING

Sharpness and Contrast Enhancement: the signal A) Introduction contains i) details of the image, ii) noise, and iii) Proper sharpening is a bit like black magic. We can't overshoots and under-shoots in areas of sharp edges really sharpen an image any more than it already is. If due to the smoothing of edges. While the it wasn't sharp when captured, there's nowhere the enhancement of noise isclearly undesirable, the information needed can come from later on. What we enhancement of the under-shoot and over-shoot can do is create the illusion of sharpness by creates the visually unpleasant halo effect.Ideally, the exaggerating contrast along edges in the image. This algorithm should only enhance the image details. This added contrast makes the edges stand out more, requires that the filter is not sensitive to noise and making them appear sharper. Sharpening filters does not smooth sharp edges. These issues have been emphasize the edges in the image, or the differences studied by many researchers. For example, the cubic between adjacent light and dark sample points in an filter [1] and the edge-preserving filters [2] have been image. Unsharp masking (UM) is an image used to replace the linear low-pass filter. The former manipulation technique, often available in digital is less sensitive to noise and the latter does not image processing software. The "unsharp" of the smooth sharp edges. Adaptive gain control has also name derives from the fact that the technique uses a been studied [3]. Contrast is a basic perceptual blurred, or "unsharp," positive to create a "mask" of attribute of an image [4]. It is difficult to see the the original image. The unsharped mask is then details in a low contrast image. Adaptive histogram combined with the negative, creating the illusion that equalization [5], [6] is frequently used for contrast the resulting image is sharper than the original. From enhancement. The retinex algorithm, first proposed a standpoint, an unsharp mask is generally a linear by Land has been recently studied by many ornonlinear filter that amplifies high-frequency researchers for manipulating contrast, sharpness, and components. B) Unsharp masking process The dynamic range of digital images. The retinex sharpening process works by utilizing a

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

90 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image slightly blurred version of the original image. This is then subtracted away from the original to detect the presence of edges, creating the unsharp mask (effectively a high-pass filter).

Step 1: Detect Edges and Create Mask

The classical unsharp masking algorithm can be represented by equation V=y+γ(x-y) where x is the input image y, is the result of a linear low-pass filter and the gain γ (γ>0) is a real scaling factor. The signal d=x-y is usually amplified (γ>1) to increase the sharpness. However, the signal contains 1) details of the image, 2) noise, and 3) over-shoots and under- shoots in areas of sharp edges due to the smoothing of edges. While the enhancement of noise is clearly undesirable, the enhancement of the under-shoot and overshoot creates the visually unpleasant halo effect. Ideally, the algorithm should only enhance the image details. This requires that the filter is not sensitive to noise and does not smooth sharp edges. These issues have been studied by many researchers. For example, the cubic filter and the edge-preserving filters have been used to replace the linear low-pass filter. The former is less sensitive to noise and the latter does not smooth sharp edges. Adaptive gain control has also been studied .Contrast is a basic perceptual attribute of an image. It is difficult to see the details in a low contrast image. Adaptive histogram equalization is frequently used for contrast enhancement. Halo effect: The UnSharp Mask is wonderful magic, but still,excessive and improper use of its parameters can produce artificial images with bizarre problems. Such problems can include overly contrasty images, edges that look like halos around objects, jagged edges, and specked or mottled areas, like faces with bad complexions. So if this might be your problem, back off, and practice moderation.

The "mask overlay" is when image information from the layer above the unsharp mask passes through and replaces the layer below in a way which is proportional to brightness in that region of the mask. C) Unsharp masking algorithm

Fig.1 Halo effect

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

91 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image This tiny image is a simple three tone graphic image In the proposed algorithm, the user can adjust the two containing two contrast edges, shown unsharpened on parameters controlling the contrast and sharpness to the left, and sharpened with the Unsharp Mask on the produce the desired results. This makes the proposed right. It is also shown greatly enlarged about 10X so algorithm practically useful. These related works the pixels canbe seen well. Remember about anti- include unsharp masking and its variants, histogram aliasing blending the edges with intermediate tones equalization, retinex and de-hazing algorithms, and (usually only on angled or jagged edges). Unsharp generalized linear systems. It has been recently Mask is the opposite, it involves making the pixels on studied by many researchers for manipulating the light side of the edge even lighter, and making the contrast, sharpness, and dynamic range of digital pixels on the dark side of the edge even darker, as images. The retinex algorithm is based upon the shown, to increase edge contrast. This then shows the imaging model in which the observed image is edge better, therefore we perceive the edge to be formed by the product of scene reflectance and sharper. Give this a little thought, because the same illuminance. The task is to estimate the reflectance effect happens to all of the edges in your photograph from the observation. Many algorithms use the with the Unsharp Mask. This image also assumption that the illuminance is spatially smooth. demonstrates the halo effect due to too much Enhancement of contrast and sharpness of an image is sharpening. required in many applications. Unsharp masking is a classical tool for sharpness enhancement. We propose IV. PHOTOGRAPHIC UNSHARP a generalized unsharp masking algorithm using the MASKING exploratory data model as a unified framework. The proposed algorithm is designed to address three The technique was first used in Germany in the 1930s issues: 1) simultaneously enhancing contrast and as a way of increasing the acutance, or apparent sharpness by means of individual treatment of the sharpness, of photographic images. In the model component and the residual. 2) Reducing the photographic process, a large-format glass plate halo effect by means of an edgepreserving filter. 3) negative is contactcopied onto a low contrast film or Solving the out-of-range problem by means of log- plate to create a positive. However, the positive copy ratio and tangent operations. Block diagram of is made with the copy material in contact with the Generalized unsharp masking algorithm shown in back of the original, rather than emulsion-to- Fig.2, is based upon the previous image model and emulsion, so it is blurred. After processing this generalizes the classical unsharp masking algorithm blurred positive is replaced in contact with the back by addressing issues stated in that algorithm. of the original negative, When light is passed through negative and in-register positive (in an for example), the positive partially cancels some of the information in the negative. Because the positive has been intentionally blurred, only the low frequency (blurred) information is cancelled. In addition, the mask effectively reduces the dynamic range of the original negative. Thus, if the resulting enlarged image is recorded on contrasts photographic paper, the partial cancellation emphasizes the high frequency (fine detail) information in the original, without loss of highlight or shadow detail. The resulting print appears sharper than one made without Fig.2 Block diagram of the proposed generalized the unsharp mask: its acutance is increased. In the photographic procedure, the amount of blurring can unsharp masking algorithm. This algorithm addresses be controlled by changing the softness or hardness the issue of the halo effect by using an edge- (from point source to fully diffuse) of the light source preserving filter the IMF to generate the signal. The used for the initial unsharp mask exposure, while the choice of the IMF is due to its relative simplicity and strength of the effect can be controlled by changing well studied properties such as the root signals. Other the contrast and density (i.e., exposure and more advanced edge preserving filters such as the development) of the unsharp mask. In traditional nonlocal means filter and wavelet-based de-noising photography, unsharp masking is usually used on filters can also be used. This address the issue of the monochrome materials; special panchromatic soft- need for a careful rescaling process by using new working black and white films have been available operations defined according to the log-ratio and new for masking photographic color transparencies. This generalized linear system. Since the gray scale set is has been especially useful to control the density range closed under these new operations (addition ⊕ and reproduction. scalar multiplication ⊗formally defined), the out-of- range problem is systematically solved and no V. PROPOSED ALGORITHM rescaling is needed. This algorithm addresses the

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

92 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image issue of contrast enhancement and sharpening by example by emission from a black screen, or by using two different processes. The image y reflection from a white screen). Each of the three isprocessed by adaptive histogram equalization and beams is called a component of that color, and each the output is called h(y). The detail image is of them can have an arbitrary intensity, from fully off processed byg(d)=γ(d)⊗d where γ(d) is the adaptive to fully on, in the mixture. The RGB color model is gain and is a function of the amplitude of the detail additive in the sense that the three light beams are signal. The final output of the algorithm is then given added together, and their light spectra add, by v = h(y) ⊕ [γ (d) ⊗d] We can see that the wavelength for wavelength, to make the final color's proposed algorithm is a generalization of the classical spectrum. Zero intensity for each component gives unsharp masking algorithm in several ways which are the darkest color (no light, considered the black), and summarized in Table 4.1. In the following, we full intensity of each gives a white; the quality of this present details of the new operations and white depends on the nature of the primary light enhancement of the two images y and d. sources, but if they are properly balanced, the result is a neutral white matching the system's white point. When the intensities for all the components are the same, the result is a shade of gray, darker or lighter depending on the intensity. When the intensities are different, the result is a colorized hue, more or less saturated depending on the difference of the strongest and weakest of the intensities of the primary colors employed. When one of the components has the Table.1 Comparison of classical unsharp masking strongest intensity, the color is a hue near this with generalized unsharp masking primary color (reddish, greenish, or bluish), and when two components have the same strongest intensity, A) Dealing with Color Images then the color is a hue of a secondary color (a shade We first convert a color image from the RGB color of cyan, magenta or yellow). A secondary color is space to the HSI or the LAB color space. The formed by the sum of two primary colors of equal chrominance components such as the H and S intensity: cyan is green + blue, magenta is red + blue components are not processed. After the luminance and yellow is red + green. Every secondary color is component is processed, the inverse conversion is the complement of one primary color; when a performed. An enhanced color image in its RGB primary and its complementary secondary color are color space is obtained. The rationale for only added together, the result is white: cyan complements processing the luminance component is to avoid a red, magenta complements green and yellow potential problem of altering the white balance of the complements blue. 2) HSI color model: The HSI Image when the RGB components are processed color space is very important and attractive color individually. model for image processing applications because it represents color s similarly how the human eye senses 1) RGB color model: colors. The HSI color model represents every color The RGB color model is an additive color model in with three components: hue (H), saturation(S), which red, green, and blue light are added together in intensity (I). "Hue" is what an artist refers to as various ways to reproduce a broad array of colors. "pigment"; it is what we think of as "color" -- yellow, The name of the model comes from the initials of the orange, cyan and magenta are examples of different three additive primary colors, red, green, and blue. hues. An artist usually starts with a highly saturated The main purpose of the RGB color model is for the (i.e., pure), and intense (i.e., bright) pigment, and then sensing, representation, and display of images in adds some white to reduce its saturation and some electronic systems, such as televisions and computers, black to reduce its intensity. Red and Pink are two though it has also been used in conventional different "saturations" of the same hue, Red. The HSI photography. Before the electronic age, the RGB model is useful when processing images to compare color model already had a solid theory behind it, two colors, or for changing a color from one to based in human perception of colors. RGB is a another. For example, changing a value from Cyan to device-dependent color model, different devices Magenta is more easily accomplished in an HSI detect or reproduce a given RGB value differently, model; only the H value needs to be changed (from since the color elements (such as phosphors or dyes) 180 to 300). Making the same change in an RGB and their response to the individual R, G, and B levels view is less intuitive; since you must know the vary from manufacturer to manufacturer, or even in correct amounts of Red, Green and Blue needed to the same device over time. Thus an RGB value does create Magenta. The HSI model is also a more useful not define the same color across devices without model for evaluating or measuring an object's color some kind of color management. To form a color characteristics, such as the "redness" of a berry or the with RGB, three colored light beams (one red, one "yellowness" of an autumn leaf. green, and one blue) must be superimposed (for

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

93 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image VI. RESULTS AND COMPARISON

All test images and Farbman’s results (called combined .png for each test image) are downloaded from the Internet: www.cs.huji.ac.il/~danix/epd/. We use the canyon image called: Hunt’s Mesa (shown in top-left of Fig.6) to study the proposed algorithms. We first show the effects of the two contributing parts: contrast enhancement and detail enhancement. As shown in Fig. 3, contrast enhancement by adaptive histogram equalization does remove the haze-like Fig. 4.Results of the proposed algorithm using (3, 3) mask with effect of the original image and contrast of the cloud different shapes. is also greatly enhanced. However, the minute details on the rocks are not sharpened. On the other hand, only using detail enhancement does sharpen the image but does not improve the overall contrast. When we combine both operations both contrast and details are improved. Next, we study the impact of the shape of the filter mask of the median filter. In Fig. 4, we show results of the proposed algorithm using 3.3 filter mask with shapes of square, diagonal cross and horizontal-vertical cross. For comparison, we also show the result of replacing the median filter with a linear filter having a (33) uniform mask. As we can observe from these results, the use of a linear filter leads to the halo effect which appears as a bright Fig. 5 Results of the proposed algorithm using the log-ratio line surrounding the relatively dark mountains (for an (middle) and the tangent (right) operations. example, see the figure in Fig. 4). Using a median In Fig.6, we present more examples showing that he filter, the halo effect is mostly avoided, although for performance of the proposed algorithm (third row) is the square and diagonal cross mask there are still a similar to that of Farbman’s algorithm (second row). number of spots with very mild halo effects. We donot present results for Meylan’s algorithm However, the result from the horizontal-vertical cross because using default parameter settings, the results mask is almost free of any halo effect. In order to are not as good as those of Farbman’s. In this paper, completely remove the halo effect, adaptive filter we do not attempt to quantitatively measure the mask selection could be implemented: the horizontal- performance of the proposed algorithm. This is a vertical cross mask for strong vertical/horizontal difficult task. Part of the difficulty comes from the edge, the diagonal cross mask for strong diagonal fact that image enhancement such as the results edge and the square mask for the rest of the image. reported in this paper are a subject for human However, in practical application, it may be sufficient evaluation. to use a fixed mask for the whole image to reduce the Fig. 6 Comparison using the “badger,” “door,” and computational time. We have also performed “rock” images experiments by replacing the log-ratio operations Fig. 7 Average contrast of the proposed image as a with the tangent operations and keeping the same function of the contrast parameter For example, it is a parameter settings. We observed that there is no matter of subjective assessment to compare visually significant difference between the results. The results shown in Fig. 5 werebtained by the following settings:

Fig. 6 Comparison using the “badger,” “door,” and “rock” images Fig. 7 Average contrast of the proposed image as a Fig. 3 Comparison of individual effects of contrast function of the contrast parameter For example, it is a enhancement and detail enhancement matter of subjective assessment to compare

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

94 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image the proposed algorithm practically useful. Extensions of this work can be carried out in a number of directions. In this work, we only test the IMF as a computationally inexpensive edge preserving filter. It is expected that other more advanced edge preserving filters such as bilateral filter/non-local means filter, the least squares filters and wavelet- based de-noising can produce similar or even better results. The proposed algorithm can be easily extended into multi- resolution processing. This will allow the user to have better control of the detail signal enhancement. For contrast enhancement, we only use adaptive histogram equalization. It is expected that using advanced algorithms such as recently published retinex and dehazing algorithm can improve the quality of enhancement. We do not consider the problem of avoiding enhancement of noise. This problem can be tackled by designing an edge preserving filter which is not For example, it is a matter of subjective assessment to sensitive to noise. The idea of the cubic filter can be compare the result of our algorithm (Fig. 5) and that useful. It can also be tackled by designing a smart of Farbman’s (Fig.6). We believe that there is no adaptive gain control process such that the gain for definite answer to the question of which one is better noise pixels is set to a small value. We have shown than the other. We note that objective assessment of that the proposed the tangent system is an alternative image enhancement is a very important topic for to the log-ratio for systematically solving the out-of- further research. Interested readers can find some range problem. It is an interesting task to study the recent works in [11], [12].In the following, we application of the tangent system and compare it with present some results obtained in an attempt to other generalized systems. understand the contribution of the contrast parameter to the average contrast of the processed image. REFERENCES

CONCLUSION AND FURTHER WORK [1] G. Ramponi, “A cubic unsharp masking technique for contrast enhancement,” Signal Process. pp. 211–222, 1998 In this paper, we use an exploratory data model as a [2] S. J. Ko and Y. H. Lee, “Center weighted median filters and unified framework for developing generalized their applications to image enhancement,” IEEE Trans. Circuits Syst., vol. 38, no. 9, pp. 984–993, Sep. 1991. unsharp masking algorithms. Using this framework, [3] A. Polesel, G. Ramponi, and V. Mathews, “Image enhancement we propose a new algorithm to address three issues via adaptive unsharp masking,” IEEE Trans. Image Process., associated with vol. 9, no. 3, pp. 505–510, Mar. 2000 classical unsharp masking algorithms: 1) [4] E. Peli, “Contrast in complex images,” J. Opt. Soc. Amer., vol. 7, no. 10, pp. 2032–2040, 1990 simultaneously enhancing contrast and sharpness by [5] S. Pizer, E. Amburn, J. Austin, R. Cromartie, A. Geselowitz, T. means of individual treatment of the model Greer, B. Romeny, J. Zimmerman, and K.Zuiderveld, component and the residual, 2) reducing the halo- “Adaptive histogram equalization and its variations,” effect by means of an edge-preserving filter, and 3) Comput. Vis. Graph. Image Process Vol. 39, no. 3, pp. 355– 368, Sep. 1987 eliminating the rescaling process by means of log- [6] J. Stark, “Adaptive image contrast enhancement using ratio and tangent operations. We present a study of generalizations of histogram equalization,” IEEE Trans. the log-ratio operations and their properties. In Image Process., vol. 9, no. 5, pp. 889–896, May 2000 particular, we reveal a new connection between the [7] M. Elad, “Retinex by two bilateral filters,” in Proc. Scale Space, 2005, pp. 217–229. Bregman divergence and the generalized linear [8] J. Zhang and S. Kamata, “Adaptive local contrast enhancement systems (including the log-ratio, MHS and the LIP for the visualization of high dynamic range images,” in Proc. model). This connection not only provides us with a Int. Conf. Pattern Recognit., 2008, pp. 1-4 novel insight into the geometrical property of [9] Z. Farbman, R. Fattal, D. Lischinski, and R. Szeliski, “Edge- preserving decompositions for multi-scale tone and detail generalized linear systems, but also opens a new manipulation,” ACM Trans. Graph., vol. 27, no. 3, pp. 1–10, pathway to develop such systems. We present a new Aug. 2008. system called the tangent system which is based upon [10]F. Durand and J. Dorsey, “Fast bilateral filtering for the display a specific Bregman divergence. Experimental results, of highdynamic- range images,” in Proc. 29th Annu. Conf. Comput. Graph. Interactive Tech., 2002, pp. 257–266. which are comparable to recently published results, [11] S. Agaian, B. Silver, and K. Panetta, “Transform coefficient show that the proposed algorithm is able to histogram based image enhancement algorithms using significantly improve the contrast and sharpness of an contrast entropy,” IEEE Trans. Image Process., vol. 16, no. 3, image. In the proposed algorithm, the user can adjust pp. 741–758, Mar. 2007. [12] M. ˇ Cadík, M. Wimmer, L. Neumann, and A. Artusi, the two parameters controlling the contrast and “Evaluation of HDR tone mapping methods using essential sharpness to produce the desired results. This makes

Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

95 Implementation Of Generalized Unsharp Masking Algorithm For Digital Image perceptual attributes,”Comput. Graph. vol. 32, no. 3, pp. 330– [14] L. Meylan and S. Süsstrunk, “High dynamic range image 349, Jun. 2008. rendering using a retinex-based adaptive filter,” IEEE Trans. [13] J. B. Fraleigh, A First Course in Abstract Algebra. Reading, Image Process., vol. 15, no. 9, pp. 2820–2830, Sep. 2006 MA: Addison-Wesley, 1978



Proceedings of 10th IRAJ International Conference, 27th October 2013, Tirupati, India. ISBN: 978-93-82702-36-8

96