1 Introduction

Contrast enhancement has a crucial role in image processing applications, such as digital photography, medical image analysis, remote sensing, LCD display processing, and scientific visualization. There are several reasons for an image to have poor contrast: the poor quality of the used imaging device, lack of expertise of the operator, and the adverse external conditions at the time of acquisition. These effects result in under-utilization of the offered dynamic range. As a result, such images may not reveal all the details in the captured scene, and may have a washed-out and unnatural look. Contrast enhancement targets to eliminate these problems, thereby obtaining more visually pleasing or informative images or both. Typical viewers describe the enhanced images as if a curtain of fog has been removed from the picture (Haan De 2000).

Contrast enhancement problem in digital images can be resolved using various methodologies, but Histogram Equalization (HE) (Lim 1990; Gonzalez & Woods 2002; Menotti 2007) technique is the widely used one. HE method flattens the histogram and stretches the dynamic range of intensity values by using the cumulative density function. However, there are major draw backs in HE (Lim 1990) especially when implemented to process digital images. Firstly, HE transforms the histogram of the input image into a uniform histogram by distributing the entire range of gray levels uniformly over the histogram of an image, with a mean value that is in the middle of gray level range. Accordingly, the mean brightness of the output image is always at the middle – or near to it in the case of discrete implementation. In the case of images with high and low mean brightness value, there is a significant change in the view of the enhanced image. Secondly, HE performs the enhancement based on the global content of the image. In other words, HE highlights the borders and edges between different objects, but may reduce the local details of these objects, and not adequate for local enhancement. Another consequence for this mergence is the production of over enhancement and saturation artifacts (Mukhopadhyay & Chanda 2000).

Initial studies on contrast enhancement using mathematical morphology were carried out by Meyer & Serra (1989), who introduced the contrast mappings notion. Such operators work in accordance with some proximity criterion. In selection of each point of the analyzed image, a new gray level between two patterns (primitives) (Chen & Ramli 2003b) is used. Other works based on the contrast mapping concept have been developed (Terol-Villalobos 2001, 2004; Mendiola-Santibanezi & Villalobos Terol 2002), With regard to MM, several studies based on contrast multiscale criterion have been carried out (Shannon 1948; Serra 1982; Meyer & Serra 1989; Lim 1990; Toet 1992; Kim 1997; Wang 1999; Mukhopadhyay & Chanda 2000; Terol-Villalobos 2001, 2004; Mendiola-Santibanezi & Villalobos Terol 2002; Soille 2003; Kasperek 2004; Liu et al 2007; Majumder & Irani 2007). In the work proposed by Mukhopadhyay & Chanda (2000), a scheme is defined to enhance local contrast based on a morphological top-hat transformation. While Kasperek (2004) implements a processing system in real time for its application in the enhancement of angiocardiographic images, based on the work carried out by Mukhopadhyay. Even though morphological contrast has been largely studied, there are no methodologies, from the point of view of MM, capable of simultaneously normalizing and enhancing the contrast in images with poor lighting. In Jimenez-Sanchez et al (2009), the two methodologies to compute the image background were proposed. Also, some operators to enhance and normalize the contrast in gray level images with poor lighting were introduced. Contrast operators are based on the logarithm function in a way similar to Weber’s law (Jain 1989; Meyer & Serra 1989). The use of the logarithm function avoids abrupt changes in lighting. Also, two approximations to compute the background in the processed images are proposed. Applying the above proposed operators to images with correct lighting, over illuminated images will be obtained. The goal of this paper is to obtain a visually pleasing enhancement method that can easily control the low and high intensity values and to overcome the over illumination problem which exists in previous gray and color image enhancement algorithms.

This paper proposes a new algorithm by introducing a new expression. The expression used in a paper is a parametric. A parameter α is defined for handling the over illumination which does not considered in Jimenez-Sanchez et al (2009). The paper is organized in the following sections. In section 2 we discussed the basic morphological transformations and weber’s law, In section 3, the contrast enhancement using HE and its variants, the Image background approximation using Block analysis and the Image Background Determination using the Opening by Reconstruction. The proposed method is presented in section 4. Simulation results and discussion are presented in section 5. Finally, the conclusion is presented in section 6.

2 Basic morphological transformations and Weber’s law

Morphology is the science of form and structure. The word morphology commonly denotes a branch of biology that deals with the form and structure of animals and plants. We use the same word here in the context of mathematical morphology as a tool for extracting image components that are useful in the representation and description of region shape, such as boundaries, skeletons, and the convex hull. The theory of mathematical morphology has been developed over the years by many researchers. The most common operations of mathematical morphology are the erosion, dilation, opening and closing. The morphological operations (Serra 1982) are related to minkowski addition and subtraction of subsets in Euclidean space, using translations, unions and intersections. Mathematical morphology is the part of set theory, and it has a strong geometric orientation. For binary images, mathematical morphology provides a well-found theory for analysis and processing. In binary morphological image analysis, a 2D image is defined as a subset of the 2-D Euclidean space R ×R or its digitized equivalent Z ×Z. In this paper, we deal only with digital images that are defined as subsets of Z ×Z. For an image A\(\subseteq \) Z ×Z and a point u ∈ Z ×Z, the translation of A by u is defined by the following equation:

$$ \left( {\mathrm{A}} \right)_{\mathrm{u}} =\left\{ {\mathrm{a}+{\mu} \left| {a\;\varepsilon A} \right.} \right\}. $$
(1)

The two most fundamental morphological operations dilation and erosion are defined by Eqs. (2) and (3) respectively

$$ \delta_{\mu B} A=\vee_{b\varepsilon B} \left( A \right)_{b} $$
(2)
$$ \varepsilon_{\mu B} A=\wedge_{v\varepsilon B} \left( A \right)_{b}, $$
(3)

where B is a structuring element, ∧ and ∨ represent infimum and supremum operator respectively and μ is the size of structuring element

Another important pair of morphological operations are opening and closing. They are defined in terms of dilation and erosion, and given by Eqs. (4) and (5) respectively

$$ \gamma_{\mu B} \;A=\delta_{\mu B} \left( {\varepsilon_{\mu B} A} \right) $$
(4)
$$ \varphi_{\mu B} A=\varepsilon_{\mu B} \left( {\delta_{\mu B} A} \right). $$
(5)

2.1 Weber’s Law

In psycho-visual studies, the contrast C of an object with luminance ‘Lmax’ against its surrounding luminance ‘Lmin’ is defined as

$$ \text{C } = {\left( {\text{Lmax } -\text{ Lmin}} \right)} / {\text{Lmin}} $$
(6)

If L = Lmin and ΔL = Lmax – Lmin. Then the above equation can be re-written as

$$ \text{C} = {\Delta \mathrm{L}} / {\mathrm{L}}. $$
(7)

Equation (7) indicates that logL is proportional to C; therefore, Weber’s law can be expressed as

$$ \text{C } =k\;\text{logL } +\;b~ L>0, $$
(8)

where k and b are constants, b being the background.

In our case, an approximation to Weber’s law is considered by taking the luminance L as the gray level intensity of a function f (image), then expression in Eq. (8) can be re-written as

$$ C =k\;\log \;f+ b. $$
(9)

3 Methodologies

3.1 Histogram equalization and its variants

The following are the variants of HE method used to improve the contrast of an image. Histogram-based contrast enhancement techniques utilize the image histogram to obtain a single-indexed mapping T(n) to modify the pixel values.

3.1.1 Histogram equalization (HE)

In HE and other histogram-based methods, mapping function is obtained from the histogram or the modified histogram, respectively (Gonzalez & Woods 2002). HE finds a mapping to obtain an image with a histogram that is as close as possible to a uniform distribution to fully exploit the dynamic range. A histogram, h(n), can be regarded as an un-normalized discrete probability mass function of the pixel intensities. The normalized histogram p(n) of an image gives the approximate probability density function (PDF) of its pixel intensities. Then, the approximate cumulative distribution function (CDF), c(n), is obtained from p(n). The mapping function is a scaled version of this CDF. HE uses the image histogram to obtain the mapping function; whereas, other histogram-based methods obtain the mapping function via the modified histogram. The mapping function in the discrete form is given as

$$ T\left( n \right)=\left\lfloor {\left( {2^{B}-1} \right)\sum\nolimits_{j=0}^{n} {p\left[ j \right]+0.5}} \right\rfloor, $$
(10)

where B is the number of bits used to represent the pixel values, and \(n\in \left [ {0,2^{B}-1} \right ]\). Although the histogram of the processed image will be as uniform as possible, it may not be exactly uniform because of the discrete nature of the pixel intensities.

3.1.2 Brightness Bi-HE method (BBHE)

In order to overcome the drawback introduced by the HE method described in the previous subsection, a brightness preserving Bi-HE (BBHE) method was proposed in Kim (1997). The essence of the BBHE method is to decompose the original image into two sub-images, by using the image mean gray level, and then apply the HE method on each of the subimages. In Kim (1997), it is mathematically shown that the BBHE method produces an output image with the value of brightness (the mean gray-level) located in the middle of the mean of the input image and the middle gray-level (that is, L/2).

3.1.3 Dualistic sub-image HE (DSIHE) method

Following the same basic ideas used by the BBHE method of decomposing the original image into two sub-images and then equalize the histograms of the sub-images separately, Wang (1999) proposed the so-called equal area DSIHE method. Instead of decomposing the image based on its mean gray level, the DSIHE method decomposes the images aiming at the maximization of the Shannon’s entropy (Shannon 1948) of the output image. For such aim, the input image is decomposed into two sub-images, being one dark and one bright, respecting the equal area property (that is, the sub-images has the same amount of pixels). In Wang (1999), it is shown that the brightness of the output image O produced by the DSIHE method is the average of the equal area level of the image I and the middle gray level of the image, that is, L/2. The authors of Wang (1999) claim that the brightness of the output image generated by the DSIHE method does not present a significant shift in relation to the brightness of the input image, especially for the large area of the image with the same gray-levels (represented by small areas in histograms with great concentration of gray-levels), e.g., images with small objects regarding to great darker or brighter backgrounds.

3.1.4 Minimum mean brightness error Bi-HE method (MMBEBHE)

Still following the basic principle of the BBHE and DSIHE methods of decomposing an image and then applying the CHE method to equalize the resulting sub-images independently, Chen & Ramli (2003a) proposed the MMBEBHE method. The main difference between the BBHE and DSIHE methods and the MMBEBHE one is that the latter searches for a threshold level lt that decomposes the image I into two sub-images I [0,lt] and I [lt + 1, L −1], such that the minimum brightness difference between the input image and the output image is achieved, whereas the former methods consider only the input image to perform the decomposition. Once the input image is decomposed by the threshold level lt, each of the two sub-images I [0, lt] and I [lt + 1, L −1] has its histogram equalized by the classical HE process, generating the output image. Assumptions and manipulations for finding the threshold level lt in O(L) time complexity were made in Chen & Ramli (2003a). Such strategy allows us to obtain the brightness lm (O [O, l] \(\cup \) O [l + 1, L −1]) of the output image without generating the output image for each candidate threshold level l, and its aim is to produce a method suitable for real-time application.

3.1.5 Recursive mean-separate HE (RMSHE) method

Recall that the extensions of the HE method described so far were characterized by decomposing the original image into two new sub-images. However, an extended version of the BBHE method proposed in Beghdadi & Negrate (1989), and named RMSHE, proposes the following. Instead of decomposing the image only once, the RMSHE method proposes to perform image decomposition recursively, up to a scale r, generating 2r sub-images. After, each one of these sub-images \(\mathrm {I}^{\mathrm {r}}\left [{1_{\mathrm {s}} , 1_{\mathrm {f}}} \right ]\) is independently enhanced using the HE method.

Note that when r = 0 (no sub-images are generated) and r = 1, the RMSHE method is equivalent to the HE and BBHE methods, respectively. In Wang (1999), they mathematically showed that the brightness of the output image is better preserved as r increases. Note that, computationally speaking, this method presents a drawback: the number of decomposed sub-histograms is a power of two.

3.2 Image background approximation using block analysis

Image contrast enhancement by using block analysis technique uses the background criteria of the image for each block. Then by using the background criteria of each block we calculate the transformation function for image enhancement. The transformation process is given in Algorithm 1.

3.3 Image background determination using the opening by reconstruction (IBDOR)

Opening by reconstruction method uses the morphological operators to calculate the background of the image as shown in Eq. (16). The process of background determination and Contrast enhancement is given in Algorithm 2.

4 Modified opening by reconstruction algorithm (MOR)

An efficient algorithm is proposed in Algorithm 3 to tackle the problem of over-illumination by controlling the intensities at dark and bright regions of an image and preserving the geometry of the object. Here we are introducing a new parameter α for suppressing the brighter gray levels and increasing the lower gray levels for controlling the intensities of darker and brighter regions. The proposed algorithm MOR uses RGB Color space, X ={X(i,j,l) is a color image with L discrete gray levels {X 0,X 1, …,X L−1}, where X(i,j,l) is the intensity value of the images at the 3D position (i,j,l) and X(i,j,l) belongs to {X0,X 1, …, X L−1}}.

The following block diagram shows the proposed algorithm in stage-wise.

figure c

The newly introduced additional multiplier α gives the enhanced image without producing over-illumination.

5 Results and discussions

It is always desirable to have subjective and objective assessment approaches to compare contrast enhancement techniques. There are some metrics used in the literature for objective assessment that approximate an average contrast in the image based on entropy or other measures. If these metrics are used, HE algorithm can achieve the best visually pleasing image. It is usually desired to have some quantitative measures in addition to subjective assessment. However we have used the following quantitative measures: Mean Square Error (MSE) and Discrete Entropy (H). MSE is the square of difference between input and output divided by number of pixels. The Discrete Entropy (H) is used to measure the content of an image (Beghdadi & Negrate 1989), where a high value indicates an image with richer details. The proposed algorithm has been successfully tested on a variety of test images and few of the results are shown in this paper.

5.1 Subjective assessment on gray scale images

Figure 1 shows the original test images and their corresponding contrast enhancement versions. The proposed algorithm is compared with HE and IBDOR. Usually, HE images result in the best utilization of the dynamic range of the pixel values for maximum contrast. However this often does not mean that the resulting image is better in the terms of visual quality. This situation is observed in 1(b). In enhancement by IBDOR, it is observed that in images with multi background the image with poor lighting has been enhanced, but the gray levels are brightened more than necessary. The MOR avoids this situation and improves the natural look.

Figure 1
figure 1

Results for image characters: (a) Original image. (b) Enhanced image after applying HE algorithm. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

In figure 2, there are very dark and very bright regions. In the dark part the objects are not visible and in bright part the patterns are clear. If IBDOR is applied, the objects in dark region are visible but the patterns on the bright part disappear, this limitation is eliminated in the MOR algorithm.

Figure 2
figure 2

Results for image room: (a) Original image. (b) Enhanced image after applying HE. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

5.2 Subjective assessment on color images

Figure 3 compares the contrast of the images after applying IBAB and IBDOR with MOR. It has been observed that IBDOR enhances visual quality on many images with poor lighting. However when images with varied intensity regions are considered, darker regions are enhanced, while other areas are over-illuminated which is observed in figure 3b and c. It is seen that IBAB introduces noise in the image and in both IBAB and IBDOR the patterns on the pot are over-illuminated, which is tackled by MOR algorithm controlling the gray levels between dark and bright region.

Figure 3
figure 3

Results for image jar: (a) Original image. (b) Enhanced image after applying IBAB. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

In figure 4, it is observed that using HE algorithm, undesired anti facts become more prominent and the noise is amplified which degrades the quality of the image. The proposed algorithm however has the greater control over contrast enhancement. In image with different gray level regions when IBDOR and MOR algorithms are applied, it is clear from the images that the proposed image has greater level of enhancement. In HE the contrast of the image is maximized at the expense of the amplified noise and image anti-facts.

Figure 4
figure 4

Results for image beach: (a) Original image. (b) Enhanced image after applying HE. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

In figure 5, if we observe the IBDOR algorithm, even though it increases the contrast at poor lightning regions, the actual patterns on the brighter part of the images have disappeared.

Figure 5
figure 5

Results for image wall: (a) Original image. (b) Enhanced image after applying HE. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

It is observed from figure 6 that the objects in the dark part are visible while preserving the patterns on the bright part of the image.

Figure 6
figure 6

Results for image hats: (a) Original image. (b) Enhanced image after applying HE. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

Contrast enhancement is extended to color images. Some examples using color images are given in figures 37. One can easily identify that the dark part becomes bright, and bright part becomes brighter resulting in the loss of details. The proposed algorithm brightens the dark part besides preserving the bright region, as a result produces a better visual quality result. Both HE and IBDOR results in loss of details as shown in figures. The proposed algorithm keeps the details while increasing the contrast.

Figure 7
figure 7

Results for image fan: (a) Original image. (b) Enhanced image after applying HE. (c) Enhanced images after applying IBDOR. (d) Enhanced image after applying MOR.

5.3 Objective assessment on gray scale images

Comparison of MSE value shows that the proposed method out performs HE, IBAB and IBDOR in all images. The MSE gives a smaller value in the MOR algorithm than other algorithms. Visual comparison to the original image shows that visually closed equalized image is obtained through the proposed method. Comparison of H values shows that the proposed method out performs all other algorithms. It is observed that few of the images have less H than HE and IBDOR, but the proposed MOR algorithm is more faithful to the original image. The Computed quantitative measures MSE are listed in table 1 and also shown graphically in figure 8.

Table 1 Mean Square Error (MSE).
Figure 8
figure 8

MSE values computation for MOR comparing with other methods.

Figure 8 shows computed MSE values for all the images listed in table 1 by applying different methods.

Quantitative measures MSE is listed in table 1, supplements the visual assessment presented earlier in the subjective analysis. Comparison of MSE values shows that the proposed method outperforms well over the methods IBAB and IBDOR in all images. It is also seen from figure 8 that the algorithm works better than HE for all images except hat, room and window images. Although HE method gives a smaller MSE for these images than the proposed method, it does not necessarily mean that they are more faithful to the original image as subjective analysis shows that the proposed algorithm preserves natural look of the image.

The Computed quantitative measures Entropy (H) are listed in table 2 and also shown graphically in figure 9.

Table 2 Entropy (H).
Figure 9
figure 9

Entropy (H) values computation for MOR comparing with other methods.

Figure 9 shows computed entropy (H) values for all the images listed in table 2 by applying different methods.

Comparision of Entropy values listed in table 2 has been shown in figure 9. It is observed that the proposed algorithm outperforms well over all the three emthods in most of the cases, except two cases with HE and IBDOR methods.

6 Conclusion

A new algorithm is proposed to minimize over illumination. The proposed algorithm is carefully designed to adjust the various aspects of contrast enhancement. The contrast of the multi-background image can be improved by controlling the intensities and increasing the contrast at both darker and brighter parts of the image. The objects in the darker part are visible retaining the information at the brighter part. The experimental results show the effectiveness of the algorithm in comparison to other contrast enhancement algorithms. The images obtained by using MOR are visually pleasing and have a natural look. The proposed algorithm gives a level of controllability by adjusting the gray levels from darker to the brighter part of the image. The proposed algorithm and existing is implemented in Matlab software and the proposed method takes O(M ×N) long where M ×N is the size of the image.