Entropy and Contrast Enhancement of Infrared Thermal Images Using the Multiscale Top-Hat Transform

Discrete entropy is used to measure the content of an image, where a higher value indicates an image with richer details. Infrared images are capable of revealing important hidden targets. The disadvantage of this type of image is that their low contrast and level of detail are not consistent with human visual perception. These problems can be caused by variations of the environment or by limitations of the cameras that capture the images. In this work we propose a method that improves the details of infrared images, increasing their entropy, preserving their natural appearance, and enhancing contrast. The proposed method extracts multiple features of brightness and darkness from the infrared image. This is done by means of the multiscale top-hat transform. To improve the infrared image, multiple scales are added to the bright areas and multiple areas of darkness are subtracted. The method was tested with 450 infrared thermal images from a public database. Evaluation of the experimental results shows that the proposed method improves the details of the image by increasing entropy, also preserving natural appearance and enhancing the contrast of infrared thermal images.


Introduction
Thermal infrared imaging (TII) is emerging as a powerful and non-invasive tool to accurately evaluate the thermal distribution of a body. TII is based on the physical phenomenon that all bodies above absolute zero emit thermal radiation. The intensity and spectral distribution of emitted radiation depend on the temperature, and its detection allows the creation of a thermal map of temperature distribution. TII uses the thermal radiation to create an image similar to visible light imaging. However, the use of this thermal radiation presents advantages over visible light in extreme situations since it can provide valuable information from an environment independent of the quality of the environmental light source, as is the case in foggy conditions or darkness, where TII can detect the presence of individuals, objects, or animals [1,2]. This feature makes the utilization TII very competitive to traditional methods in different fields as security, engineering, ecology, etc. [1][2][3].
Despite the advantages of TII, in some scenarios images may present low contrast, as well as low-level and blur details. These issues are due to facts such as limitations of the cameras with which the images are captured, conditions in the environment, etc. Therefore, contrast enhancement techniques may yield higher image details [4,5].
Many algorithms currently exist that enhance the contrast of infrared images. Histogram-based algorithms are widely used to enhance the brightness areas of an infrared image [6][7][8][9]. One of the most popular methods is the Histogram Equalization (HE). However, in the process of enhancing an image, HE drastically changes the average brightness of the image, resulting in loss of information and visually deteriorated images [10]. The HE variants cause the same problems, but to a lesser extent. Hence, global histogram-based algorithms cannot improve image entropy [11][12][13][14][15].
Other strategies for improving thermal infrared image are based on mathematical morphology. These are widely used to enhance contrast, improve details and edges, suppress noise, and enhance small targets [4,5,[16][17][18][19][20][21][22]. However, the technique has some problems associated with the shape and size of the structuring element. In order to solve this problem, proposals have been presented where, in the basic operations of mathematical morphology, two structuring elements of equal sizes and different shapes are used [5,21,23]. Strategies have also been used within multiscale schemes, such as sequential toggle operators, to achieve improvements in infrared images [4,22,24,25].
The top-hat transform is one of the most used operations of mathematical morphology. Image enhancement by top-hat transform consists of adding bright areas and subtracting dark areas from the original image [26][27][28]. To improve the performance of top-hat transform, it is normally used in a multiscale scheme [29]. The multiscale top-hat transform can extract multiple useful features from the image, which are then used to enhance the infrared image. The multiscale top-hat transform scheme is widely used to make improvements in different types of grayscale images [26,30]. For example, it has been used to enhance retinal images [31], ultrasound images [32], and infrared images [16,22,33]. It has also been used in applications such as visible and infrared image fusion [34][35][36], image segmentation [37], and detection of small objects [21,22,38].
In the literature, the results obtained by infrared image enhancement algorithms based on multiscale mathematical morphology are generally evaluated using the following metrics: Peak Signal-to-Noise Ratio (PSNR) [21,30], which measures distortion in the improved images; and linear index of fuzziness (γ) measure [4,5,20,33], which quantifies the improvement in blurriness of infrared images. For the results of this work it is also of utmost importance to quantify the richness of the details of the infrared image by means of its entropy [39,40], contrast enhancement [16] to differentiate the objects from their background, and the mean brightness [11], which will tell us if the resulting image maintains its naturalness after the process of enhancement.
In this article we propose a new method based on the multiscale top-hat transform. Two geometrically proportional and flat structuring elements are used in top-hat operations [16]. The method improves the details of infrared images by increasing their global entropy. It also introduces less distortion, preserves natural brightness, and enhances contrast in the resulting thermal infrared images. In the proposed method, first the two structuring elements are selected to improve the performance of the multiscale scheme. It then extracts the light and dark areas of the image on multiple scales, and after that it sums and weighs the light and dark areas obtained. Finally, the infrared thermal image is enhanced by adding the bright regions and subtracting the dark regions.
The contributions of this work are: (1) proposing the top-hat transform by using two structuring elements of different sizes; (2) a new algorithm for improving entropy and contrast in TTI based on the multiscale top-hat transform.
The article is structured as follows: Section 2 presents the preliminary concepts of entropy and contrast, Section 3 presents the proposed method to improve the TII based on the multiscale top-hat transform, Section 4 shows the experimental results, and Section 5 concludes with the main contributions of the work.

Entropy and Contrast in Digital Images
TII often presents problems at the time of capture, such as poor details and low contrast. When you want to solve the above problems by means of strategies to improve the image, other types of inconvenience usually appear; for instance, loss of detail and naturalness in the image.
Entropy [39][40][41][42][43] quantifies the information content of the image. It describes how much uncertainty or randomness there is in an image. The more information the image contains, the better its quality. In [44], Wang et al. propose a method based on fractional Fourier entropy map, multilayer perceptron, and Jaya algorithm in multiple sclerosis identification. In [45], Zhang et al. propose a smart detection method for abnormal breasts in digital mammography. In this case, fractional Fourier entropy was employed to extract global features. In [46], Lee et al. investigate a framework for expressing visual information in bits termed visual entropy, based on information theory.
The entropy (E) referred to here is Shannon's entropy. In the field of information theory, entropy, also called entropy of information and Shannon's entropy, measures the uncertainty of a source of information [47]. Shannon's entropy is defined as: where I is the original image, p(k) is the probability of occurrence of the value k in the image I, and L = 2 q indicates the number of different gray levels. E(I) is a convenient notation for the entropy of an image, and should not be interpreted here as a mathematical expectation since I is not a random variable. It is not difficult to prove that if q is the number of bits representing each pixel in the image, then E(I) ∈ [0, q]; for this work q = 8 for infrared thermal images in gray scale.
In Figure 1 we can observe the histogram of an 8-bit image (histogram with uniform distribution). In this case the entropy has maximum value, i.e., the entropy has a value equal to 8. This happens when the probabilities of all possible results are equal. Also, it can be seen that the histogram uses all the available dynamic range, that is to say in the histogram we visualize all the values of intensity in the range [0, 255]. Minimal entropy happens when the result is a certainty and its value is zero. In image processing, discrete entropy is a measure of the number of bits required to encode image data [41]. The higher the value of the entropy, the more detailed the image will be.  Contrast is defined as the difference between the light and dark areas of the image. The higher the variance of gray intensities, the higher the contrast. When the difference between the maximum and minimum intensities of an image is very small, the image has low entropy and poor contrast. Niu et al. [48] introduce a contrast enhancement algorithm of tone-preserving entropy maximization. Yoo et al. [10] propose an image enhancement method called MEDHS (Maximum Entropy Distribution based Histogram Specification), which uses the Gaussian distribution to maximize the entropy and preserve the mean brightness.
Unlike the methods mentioned above, in this work we propose a new method based on mathematical morphology. This method increases the global entropy and contrast, improving the details of the TII.
In Figure 2 we can see the infrared thermal image with its associated histogram. Observing the histogram of the image, we can see that it does not effectively use the whole range of available intensity values. This indicates that the image has poor entropy and low contrast. When calculating Shannon's entropy (Equation (1)) we can see that it has a value of E = 6.008. As an example, Figure 3 shows the thermal infrared image (TII) obtained with the HE algorithm and its histogram. The HE method enhanced the contrast of the TII by making it brighter. In the histogram of the improved image we can visualize that the intensities are redistributed towards the available extreme values, leaving many holes. However, the method did not improve Shannon's entropy, obtaining a value of E = 5.933, which is less than the entropy of the unprocessed Figure 2a.
Visually it is observed in Figure 3a that there is a loss in details, for example it is not possible to differentiate well the horse from the person.  To solve the problem of improving the image without incurring in a loss of the details and the mean brightness of the image, we will make a detailed description of the proposed method based on multiscale mathematical morphology in the following section.

Enhancement of Thermal Infrared Images
The top-hat transform is one of the most used operations of mathematical morphology to obtain improvements in the TII [4,5,16,[20][21][22]. Two structuring elements of proportional sizes, equal shapes and planes, will be used to improve the performance of the top-hat transform [16].

Classic Top-Hat Transform
The top-hat transform is a composite operation of mathematical morphology; it is defined from other morphological operations, namely erosion, dilation, opening, and closing.
The morphological operations of dilation and erosion of I(u, v) for B(s, t), denoted by (I ⊕ B) and (I B), are defined as follows [27,49]: where I is the original infrared thermal image whose pixels are represented for all (u, v) spatial coordinates and B is the structuring element whose spatial coordinates are represented by (s, t).
The opening (I • B) and closing (I • B) morphological operations of I(u, v) for B(s, t) are defined from the dilation and erosion operations as follows [27,49]: The top-hat transform morphological operation [27] is defined from the morphological opening and closing. White Top-Hat (WTH) is the top-hat transform through opening, Black Top-Hat (BTH) is the top-hat transform through closing. WTH gets the bright areas and BTH gets the dark areas lost in the opening and closing operations. Both transforms are defined as follows:

Modified Top-Hat Transform
The classical top-hat transform is characterised by the use of a single structuring element. This makes its image processing performance inefficient [29]. To improve the performance of the top-hat transform it is proposed to use two structuring elements, whose characteristics will be proportional geometry and flat [16]. The Modified White Top-Hat (MWTH) and the Modified Black Top-Hat (MBTH) transforms will be used for image improvement within the scheme of multiscale top-hat transform.
Let the structuring elements be G and G geometrically proportional and flat. Then, the top-hat transform that we will use in the multiscale scheme is defined as follows: Note that if G = G , then Equations (8) and (9) are equal to Equations (6) and (7). Therefore, the classical top-hat transform is a particular case of the modified top-hat transform. In [16], Román et al. show that the modified top-hat transform improves thermal images, enhancing the contrast, preserving the details and introducing less distortion.

How Entropy is Changed by Top-Hat Transform
The Shannon entropy depends on both (a) the number of distinct values exhibiting a positive frequency, and (b) how uneven the density function is, compared with a discrete uniform distribution.
The top-hat transform, working within a local region of the image, often generates new values of grey, thereby causing a small to moderate increase in the entropy value of the region. This occurs because Equations (8) and (9) can induce one or more new levels of grey when the logic is executed.
When one new level of grey h is added by the algorithm to a region being worked, it replaces another value g at certain spatial position. There are two possibilities: either

•
The old value g was unique in the region, with a count of 1, hence it disappears from the region and is replaced by value h. No change in entropy occurs because in the old g bin of the histogram the count of 1 becomes 0, and in the new h bin the count of 0 becomes 1; or • The old value g existed in k > 1 pixels in the region. In this case the count in the g bin decreases to k − 1, and the count in the h bin increases to 1. The following Lemma shows that this change in the histogram increases the region's entropy.

Lemma 1.
Consider a rectangular region of m pixels in an image. Let H(X) be the original entropy of the grey scale X in use. Suppose that grey level g appears in k pixels of the original image and grey level h does not appear. Further, suppose that an image transformation replaces grey level g with grey level h at certain pixel of the rectangular region. Then the entropy of the transformed region increases to where the value of ε is 1/m, the inverse of the number of pixels in the region.
Proof. Without loss of generality assume 255 levels of grey; thus both g and h are integers in {1, ..., 255}.
As the sum of probabilities before and after the transformation equals 1, the increase in p h occurs at the expense of a decrease in p g ; that is, p h increases from 0 to εp g and p g decreases to (1 − ε)p g . For the region under consideration, Equation (1) can be written as After transformation, the probability corresponding to level g is broken down in two: a portion εp g for newly incorporated level h and a portion (1 − ε)p g for level g. Thus ] is a positive value representing the increase in entropy when a new level of grey is incorporated in the region. This completes the proof.
The smallest possible frequency for any level of grey in a region of m pixels is 1/m as mentioned in the Lemma. In practice, ε may be larger than 1/m; this occurs when more than one pixel is assigned the new grey level h. It is easy to show that ε = 0.5 would yield a maximum increase in entropy at current iteration; however, according to the method proposed below (next subsection), entropy increases incrementally as the algorithm iterates.

Proposed Method Using Multiscale Top-Hat Transform
The proposed method is based on the multiscale top-hat transform. This method employs two structuring elements in the top-hat transform to improve its performance. The proposed method improves the image in terms of detail, contrast and mean brightness conservation. The infrared image enhancement algorithm initially uses the following parameters: The original image I, the number of iterations n in a range i ∈ {1, 2, . . . , n}, n > 1; and two structuring elements G and G .
Multiple Brightness (MB) and Multiple Darkness (MD) areas will be obtained by top-hat transform as follows: where MB i is the i-scales of brightness extracted from the image, and G i and G i will grow in each iteration. G will always be greater than or equal to G.
where MD i are the i-scales of darkness extracted from the image. The Subtractions of the Neighboring Bright Scales (SNBS) are then calculated. This operation is expressed as follows: where SNBS i−1 are the (i − 1)-differences of the neighboring brightness scales obtained from the image. Similarly, the Subtractions of the Neighboring Dark Scales (SNDS) are calculated. This operation is expressed as follows: where SNDS i−1 are the (i − 1)-differences of the neighboring dark scales obtained from the image. The Sum of all the brightness (SMB and SSNBS) and darkness (SMD and SSNDS) values obtained in the multiscale process are then calculated as follows: Finally, the image enhancement (I E ) will be obtained as follows: where ω ∈ [0, 1] is a weighting factor or regulator of the bright and dark areas.
The TII enhancement process is described in the following Algorithm 1.

Algorithm 1 Proposed method for TII Enhancement
Input: I, G, G , n, ω Output: I E (Enhanced image) Initialization : G, G 1: for i = 1 to n do 2: Calculation of top-hat transform. (11)) (12)) 3: Calculation of subtractions from neighboring scales, obtained through the top-hat transform. The top-hat is subtracted with the previous difference, from the first subtraction of the first neighboring top-hat. (13)) (14)) 4: end for 5: Calculation of the maximum values of all the multiple scales obtained. (18)

Results and Discussion
Experiments were performed by randomly selecting 450 TII of 324 × 256 from a public repository [50]. We analyzed 9 different scenes of 50 images each one. Images were captured with an infrared thermal camera FLIR Tau 320 with a resolution of 324 × 256 pixels. Images in the database are 8-bit and 16-bit. The database has no radiometric data. Tests were performed on the 8-bit images. Figure 4 shows the scenes. The computer used has the following features: Pentium Dual-Core 2.3 GHz processor, RAM 4GB, HD 1TB, and the operating system used was Windows 7.
In order to test the performance of the proposed method, we considered three different experiments: • In the first part (Section 4.1) we perform a parameter adjustment to find good parameter values that maximize the entropy of the output image after applying the proposed method.

Parameter Tuning
In this section, the goal is to find a good combination of values of the parameters of ω and the number of iterations n. Parameter ω has real values. As we cannot perform tests for all real values, we take a selection criteria for values that we consider representative to get good outcomes for ω and n. The search for more optimal values of these parameters could be approached in future work as an optimization problem. For this experiment we applied the proposed method in the selected dataset. Since we are seeking to optimize the entropy of the resulting image, we use such Equation (1) as evaluation metrics.
The parameter values of the proposed method are presented in Table 1. As shown, we tested different values of the number of iterations n and w. For n, we changed the value from 2 to 10.
No larger values were considered because the larger the value is, the more the image becomes distorted. The parameter w was changed in the range of [0, 1] in increments of 0.05. A value of 0 gives as result the original image. The initial structuring elements G and G are squares of 3 × 3 and 15 × 15, respectively. In each iteration the two structuring elements will side increase in sizes of two. Table 2 presents the results obtained. Each column refers to the corresponding iteration n while each row corresponds to a different value of ω. Higher results are highlighted in bold. The highest result is achieved with n = 8 and ω = 0.35. It is worth stressing that the entropy increases when the iteration rises its value until the local optima and from there, values start to decrease. In Figure 5 we can see that images of the same scene with similar entropy, but with different configurations of ω and n, get similar visual results. For the other experiments, we select the configuration that has the best average.

Performance of Proposed Method per Iteration
In this section we compare the results per iteration between proposed method and MMIIE method, using the 450 infrared thermal images. We compare the performance of the entropy (Equation (1)) and with the following metrics: • The Standard Deviation (SD), which quantifies the global contrast of the infrared images, is defined as [16]: where k is the pixel value of the image I, L − 1 is the maximum gray level, the average intensity of the image is represented by A(I), and p(k) is the probability of occurrence of the value k. If SD(I E ) is greater than SD(I), then there is contrast enhancement.

•
The metric adopted to measure the signal-to-noise ratio of an image is the PSNR.
Given the original infrared image I and the infrared image with enhancement I EN where the size of the images is M × N, the PSNR between I and I EN is given by [30]: The Mean Squared Error (MSE) is defined as: • The Absolute Mean Brightness Error (AMBE) [11], which quantifies the conservation of the mean brightness of the processed image, is given by: where I and I E represent the input infrared image and the image enhancement, respectively, A(I) and A(I E ) represent the mean brightness of the input infrared image and the image enhancement. The lower the AMBE value, the better the mean brightness of the image is preserved.

•
The linear blur index γ [4] is used to measure the performance of the infrared image enhancement. It is defined as follows: where M × N is the size of the infrared image. I(u, v) is the gray pixel value (u, v). L − 1 is the maximum gray value of I. The performance of the algorithm is better if the value of γ is small.
Following the recommendations of Bai [4], we set the following parameter values for MMIIE method. The number of iterations n was set to 10, the weights to w 1 = 0.6, w 2 = w 3 = 1.5, and the initial structuring element B was fixed to 3 × 3. For the proposed strategy and taking into account the parameter tuning, we fixed w to 0.35 and considered the same parameter values as in the previous experiment; n = 10 and G and G to 3 × 3 and 15 × 15 respectively. In each iteration the two structuring elements will increase in sizes of two. The average entropy of the 450 original thermal infrared images is E = 6.5924. The proposed method and MMIIE was implemented using ImageJ [49].
In Table 3 it can be seen the results on average on each iteration for the 450 images with the proposed method and MMIIE method. Results in bold refer to the best results by iteration. According to the results obtained we can say that the proposed method outperforms MMIIE method in four of the five evaluation measures on every iteration, while MMIIE method achieves better results with γ. Therefore, on average, the proposed method provides better contrast enhancement and signal-to-noise ratio and higher level of detail. Furthermore, it also preserves better the brightness. On the other hand MMIIEE method provides better blur effect. The computational time of the proposed method is higher than that of the MMIIE method, but the proposed method obtains better results in fewer iterations (lower n).  Figure 6 presents an example image from the dataset with its corresponding histogram. The original image and its histogram is shown in Figure 6a,b respectively. Figure 6c is the resulting image after applying MMIIE method and Figure 6e when applying the proposed method. In both cases we have selected the iteration in which the entropy is maximum. It can be observed that the proposed method presents a better redistribution of intensity levels in bright areas and has fewer peaks according to its histogram (Figure 6d,f. It therefore leads to a better level of detail and contrast.

Comparison of the Performance of the Proposed Method with State of the Art Methods
In this section we compare the proposed method with popular methods from the literature. The methods used in this section are HE, CLAHE, IRHE2PL [6], and MMIIE. In this part we analyze two results. First we are interested in knowing the percentage of images that are enhanced compared to the original using each method. Then, we analyze the performance of each method on each different scene.
The parameters of the various methods are as follows. For CLAHE, the method was implemented with the MATLAB program, using its default values. For the IRHE2PL method the parameters are described in [6]. For MMIIE method we set the number of iteration n to 9 and the weights to w 1 = 0.6, w 2 = w 3 = 1.5. Finally, the initial structuring element B was fixed to 3 × 3 square. Results for this method use the number of iterations that maximize the entropy. Finally, for the proposed method we selected the best combination found in the first part. In this case n = 8, ω = 0.35, and the initial structuring elements G and G are squares of 3 × 3 and 15 × 15, respectively. The HE, IRHE2PL, MMIIE methods and the proposed method were implemented using the ImageJ library [49]. Table 4 shows the percentage of images that have been enhanced in terms of contrast. An image is considered improved if the value of the standard deviation of the processed image is greater than the original image. As we can see, the proposed method enhances the contrast of the 450 TII. HE has a very high value with 98.89%, followed by IRHE2PL method, CLAHE method, and MMIE method with 90.22%, 82.67%, and 47.56%, respectively. The performance of each method in each scene is presented in Table 5. For each scene the first row refers to the original image followed by the different methods used in this study. The two best values for each metric are highlighted in bold. Results of each scene are presented are averaged over all the images that belong to such scene. At the end the average over all images is also presented. Based on the averages of the metrics E, SD, PSNR, AMBE, and γ we can conclude that: • E metric: The CLAHE method and the proposed method are the methods that have the best performance in terms of entropy for scenes 1 to 8. However, in scene 9 the CLAHE and MMIIE methods have the best results. • SD metric: The HE, CLAHE, IRHE2PL methods and the proposed method enhance the contrast of the TII in the 9 scenes. The MMIIE method did not enhance the contrast of scenes 2, 4, 7, 8, and 9. The HE method is the best performing method for all scenes and the proposed method is in second place. • PSNR metric: The methods that produce the less distortion to TII are the IRHE2PL, the proposed method, and CLAHE. • AMBE metric: For all scenes, the best method in regards to maintaining the average brightness is the proposed method. • γ metric: The MMIIE method and the proposed method present the best results in terms of blurring.
In the results of scenes 7 and 9 we can see that the IRHE2PL method does not improve the entropy of the image, but has a higher PSNR than the proposed method. This is because IRHE2PL generates an image very similar to the original image. Figure 7 shows that the TII (scene 9) enhanced with the IRHE2PL method (Figure 7b) is very similar to the original image (Figure 7a), contrary to the proposed method, which improves the entropy and contrast of the image (Figure 7c).

General Analysis of Methods
In general none of the methods presented outperforms the other techniques in all evaluation criteria. In almost all cases, the proposed method is the strategy that achieves the best performance in entropy, contrast, and AMBE. Therefore, it is the one that provides better details and keeps a better brightness. HE is the algorithm that yields higher contrast according to its good performance, in all cases, with SD. The CLAHE method performs the best in entropy, so it preserves the details better. The best signal-to-noise ratio is achieved by the IRHE2PL method and, so, it is the one that provides the lowest distortion. Finally, the MMIIE method improves the blur effect in all cases. The proposed method provides the best values in AMBE in almost all cases and in E, SD, PSNR, and γ results are very competitive since it achieves high values that are close to the best value in many cases. Now we can see a couple of examples in Figures 8 and 9. For each image enhancement method, images were selected so that each method achieved the highest entropy value. In Figure 8 represents a patio scene images with Figure 8a the original image. The results of HE is in Figure 8b and it presents an excess of brightness. In Figure 8c the CLAHE method makes a moderate enhancement to the image. However, in Figure 8d the IRHE2PL method does not enhance the contrast of the TII. In Figure 8e the MMIIE method adds distortion to TII. Finally, in Figure 8f the proposed method enhances the contrast and improves the details of the TII. The second example, which represents a person with a horse, is in Figure 9. The analysis is similar to the previous case. Therefore we can emphasize the good performance of the proposed technique. Finally, in Figure 10 we analyze the level of detail of the resulting image before and after applying the proposed strategy. Numerical results suggest that the level of details increase with the proposed method and this feature can be visually corroborated. For example, the resulting image in Figure 10b presents an excellent contrast, and a well-defined detail, which makes easier its identification.

Conclusions
In this work we have introduced an iterative contrast enhancement method for TII. This approach is based on multiscale top-hat transform that improves the entropy of images, which implies an improvement in the level of detail of the resulting image. Furthermore, the proposed method not only improves the entropy but also preserves the brightness and enhances contrast.
The proposed method was compared with state of the art algorithms and has proved to be competitive. It is noteworthy that the proposed method is the only algorithm that improved the original image for all input images in terms of contrast.
Visually, the resulting image after applying the proposed method presents a higher quality than the original image. This result is consistent with the performance of the algorithm. This proposed method could be very useful for infrared thermal image analysis, object recognition, people tracking, and other applications based on infrared thermal images.