A POSHE-Based Optimum Clip-Limit Contrast Enhancement Method for Ultrasonic Logging Images

Enabled by piezoceramic transducers, ultrasonic logging images often suffer from low contrast and indistinct local details, which makes it difficult to analyze and interpret geologic features in the images. In this work, we propose a novel partially overlapped sub-block histogram-equalization (POSHE)-based optimum clip-limit contrast enhancement (POSHEOC) method to highlight the local details hidden in ultrasonic well logging images obtained through piezoceramic transducers. The proposed algorithm introduces the idea of contrast-limited enhancement to modify the cumulative distribution functions of the POSHE and build a new quality evaluation index considering the effects of the mean gradient and mean structural similarity. The new index is designed to obtain the optimal clip-limit value for histogram equalization of the sub-block. It makes the choice of the optimal clip-limit automatically according to the input image. Experimental results based on visual perceptual evaluation and quantitative measures demonstrate that the proposed method yields better quality in terms of enhancing the contrast, emphasizing the local details while preserving the brightness and restricting the excessive enhancement compared with the other seven histogram equalization-based techniques from the literature. This study provides a feasible and effective method to enhance ultrasonic logging images obtained through piezoceramic transducers and is significant for the interpretation of actual ultrasonic logging data.


Introduction
In the past decades, piezoceramic transducers with the unique capacity of actuating and sensing in a wide-frequency band [1][2][3][4][5], play important roles in ultrasonic techniques, enabling structural health monitoring (SHM) [6][7][8][9] and nondestructive testing (NDT) [10][11][12][13] in many fields [14][15][16][17], and one of them is oil and gas exploration [18][19][20]. Piezoceramic transducers are often used to generate and detect ultrasonic waves [21][22][23][24] that travel through different mediums with reflection and refraction, based on which images of mediums can be obtained [25][26][27][28][29][30], and this practice is commonly used in well logging [31][32][33]. In the process of ultrasonic imaging logging, acoustic imaging instruments use a rotating piezoceramic transducer to emit and receive ultrasonic pulses traveling through borehole fluid. The acoustic wave amplitude attenuation and the acoustic wave travel time are both recorded and converted into color images. The acoustic travel time and amplitude attenuation signals can reflect characteristics about borehole shape and variation in rock properties. Further, Histogram equalization (HE) is considered one of the most popular techniques to improve contrast because of its simplicity and ease of implementation. It generates a uniform output histogram by means of stretching the dynamic range of the input image histogram, thereby improving the image contrast [45,46]. However, HE often produces undesirable artifacts because of over enhancement when a few consecutive gray levels occupy substantial areas in an image and considerably changes the mean brightness of the input image [45][46][47][48][49]. In addition, HE may also cause loss of details since some gray levels with a smaller proportion pixel number are combined to form a certain gray level [49]. To avoid shortcomings of the classic HE, many techniques and improved algorithms on the basis of histogram equalization have been proposed in the past and have been widely utilized in the field of image enhancement [41,42,. Since preservation of the original brightness is crucial to avoid undesirable artifacts, the brightness preserving bi-histogram equalization (BBHE) [50] is developed to preserve the original brightness to a certain extent by individually equalizing two sub-histograms based on the mean value of the images. To obtain a Histogram equalization (HE) is considered one of the most popular techniques to improve contrast because of its simplicity and ease of implementation. It generates a uniform output histogram by means of stretching the dynamic range of the input image histogram, thereby improving the image contrast [45,46]. However, HE often produces undesirable artifacts because of over enhancement when a few consecutive gray levels occupy substantial areas in an image and considerably changes the mean brightness of the input image [45][46][47][48][49]. In addition, HE may also cause loss of details since some gray levels with a smaller proportion pixel number are combined to form a certain gray level [49]. To avoid shortcomings of the classic HE, many techniques and improved algorithms on the basis of histogram equalization have been proposed in the past and have been widely utilized in the field of image enhancement [41,42,. Since preservation of the original brightness is crucial to avoid undesirable artifacts, the brightness preserving bi-histogram equalization (BBHE) [50] is developed to preserve the original brightness to a certain extent by individually equalizing two sub-histograms based on the mean value of the images. To obtain a higher degree of preservation, contrast enhancement using recursive mean-separate histogram equalization for scalable brightness preservation (RMSHE) [51] is presented and the mean brightness of the original input image is preserved to some extent by iteratively applying BBHE to the sub-histograms. When the recursion level becomes excessively large, the output mean eventually converges to the input mean. Nevertheless, it is hard to determine the optimal recursion level. Minimum mean brightness error bi-histogram equalization (MMBEBHE) [52], the extension of BBHE, was presented by Chen and Ramli to provide maximum brightness preservation. As it focuses on preservation of mean brightness, its contrast enhancement capability is not notable. An exposure based sub-image HE algorithm (ESIHE) [53] for low exposure gray scale image is presented by Singh and Kapoor, in which the histogram is split into over-exposed and under-exposed areas based on the image exposure thresholds. Further, Singh and Kapoor also proposed extensions of the ESIHE, referred to as RS-ESIHE [54]. The RS-ESIHE method is designed to perform the separation of image histogram recursively based on sub-histograms' respective exposure thresholds, and each sub-histogram is then equalized individually. Clipping of the histogram is utilized in ESIHE and RS-ESIHE methods to avoid excessive enhancement.
The recursive division algorithms may not yield natural-looking results owing to inappropriate sub-divisions. In order to overcome the above-mentioned shortcomings, a contrast-enhancement approach called entropy-based dynamic sub-histogram equalization (EDSHE) [55] is proposed. It provides a stopping criterion to find the optimal division number of sub-histograms by recursively segmenting the histogram based on the entropy. There is no need to set any parameter and specify the level of divisions in this approach. Yet, the EDSHE method is at cost of calculating the entropy of sub-histogram many times. However, enhancement methods based on histogram division fail to expand some sections of the histogram. Thus, dynamic histogram equalization (DHE) [56] splits the image histogram by searching local minima and assigns specific gray level ranges for each sub-histogram before equalizing them individually. It can enhance the image without the loss of details. In recent years, the methods based on the histogram modification for controlling the enhancement effect have been proposed, such as adaptive gamma correction with weighting distribution (AGCWD) [57], histogram modification framework (HMF) [58], gradient and intensity histogram equalization (GIHE) [59], among others. AGCWD smoothens the fluctuant problem by means of the weighting distribution function and thus restricts the over enhancement of the gamma correction. Nevertheless, AGCWD tends to result in a loss of details in the bright areas of the input image if high peaks appear in the input histogram. AGCWD is suitable for the dimmed images. For the HMF method, the modified histogram is regarded as a solution to solve the optimization problem that minimizes a cost function. Penalty terms are incorporated into the optimization problem to adjust the level of contrast enhancement. GIHE makes use of gradient and intensity information of the image to modify the histogram. Thus, it alleviates over-enhancement.
Although these above discussed global techniques are appropriate to enhance the content of the whole input image, the power of highlighting details of the local regions is relatively low [48]. Nevertheless, local image enhancement is also needed in some applications including medicine, surveillance, remote sensing and consumer electronics [60]. A local histogram equalization (LHE)-based method is subsequently developed, which can also be termed a block-overlapped histogram equalization (BOHE) [61,62]. In this method, a rectangular sub-block of the input image is first defined and the center pixel of the region is updated using this histogram-equalized function of the current sub-block. The rectangular region is then moved pixel by pixel; then, the histogram equalization is repeated so as to obtain high contrast for all locations in the image. However, since LHE must be operated on each pixel for the whole image, the computation complexity is considerably high. Non-overlapped block histogram equalization (NOBHE) [60,62] is often used to reduce computation, but this method usually produces undesirable blocking effects. To address the above-mentioned limitation, Kim, et al. presented partially overlapped sub-block histogram-equalization (POSHE) [63], which can produce a similar contrast enhancement effect with BOHE and greatly reduce computation complexity and eliminate blocking effects. However, similar to other LHE methods, POSHE tends to generate an over-enhancement phenomenon, leading to noise amplification in partial regions. In order to overcome the noise amplification and blocking effects, contrast-limited adaptive histogram equalization (CLAHE) [64,65] was proposed, which first divides the image into many non-overlapped sub-blocks, then enhances each sub-block individually and finally employs an interpolation scheme to reduce the blocking effects. It is necessary to adjust the size of the sub-block and the clip-limit value in CLAHE. This method also needs to eliminate blocking effects, which make the method more complicated for implementation. For the same purpose, the multiple layers block overlapped histogram equalization (MLBOHE) [60] method is developed, which successfully overcomes noise amplification and intensity distortion problems. Unfortunately, the enhanced image is blurred to some extent since the median filters are adopted to reduce the noise.
Yan et al. [66] used the idea of sub-histogram equalization within a local window to process the logging images and then eliminate the blocking effects using morphing technology effectively. This method increases computation complexity due to introducing morphing technology. Tu et al. [42] enhanced ultrasonic logging images using the modified BOHE method, in which the data of the local depth range for the well is used to calculate the histogram, and the data are updated line by line. In a similar way, Halliburton's XRMI (Extended Range Micro Imager) images are dynamically enhanced to improve the distinguishing ability of geological information in the literature [67]. This approach can achieve better results than the global histogram equalization algorithm in enhancing local details of image. However, it results in a small amount of noise amplification and over enhancement in the smooth region. Fu et al. [41] presents a novel image enhancement method based on CLAHE (CLAHE-PL) for ultrasonic logging images; the clip-limit value and power-law transformation parameters need to be adjusted to obtain desired results. We can see from the literature survey, it still remains a less explored area and challenge to enhance contrast, highlight the local details of the ultrasonic well logging images and achieve naturally looking results without excessive enhancement and undesirable artifacts. Therefore, a novel POSHE-based optimum clip-limit contrast enhancement method for ultrasonic logging images (POSHEOC) is proposed in this paper. The algorithm introduces the idea of contrast-limited enhancement to modify the cumulative distribution functions of the POSHE. The clip-limit value is a key issue influencing the enhancement effect. Hence, to obtain optimal clip-limit value for histogram equalization of the sub-block, a new quality evaluation index is devised considering the effects of the mean gradient and mean structural similarity. It selects the optimal clip-limit automatically according to different image data. In summary, our proposed method in this paper aims to enhance contrast, reveal the small and local details hidden in the ultrasonic logging images while preserving the naturalness of the original image without excessive enhancement and undesirable artifacts.
The rest of the paper is organized as follows. Section 2 discusses the traditional histogram equalization and POSHE. Section 3 presents our proposed POSHEOC contrast enhancement method in detail. Section 4 shows some experimental results and discussion of applying POSHEOC and other existing approaches to different ultrasonic logging images and Section 5 concludes the paper.

Related Work
This section covers the details of previous work which is related to the proposed POSHEOC method, including histogram equalization and POSHE; the discussion is based on the literature [62,68,69] and [63], respectively.

Histogram Equalization
The basic idea of histogram equalization is to transform the histogram of the original image into a uniform distribution. In this way, the dynamic range of gray value is broadened, thus achieving the effect of enhancing the overall contrast of the input image. In histogram equalization, assume that the input image has L gray levels. If r k is used to represent the kth gray level, then the L gray levels can be Sensors 2018, 18, 3954 5 of 24 described as {r 0 , r 1 , ..., r L−1 }; the probability density function (PDF) corresponding to the gray level distribution of the original image, p(r k ), is given by where N k and N represent the number of pixels with gray level r k and the total number of pixels of the input image X, respectively. Then, the cumulative distribution function (CDF), c(r k ), is calculated from the original PDF as follows: Histogram equalization is a methodology that maps the input image into the whole dynamic range (r 0 , r L−1 ) using the CDF as a transformation function. The formula of the transformation function f (r k ) is given as: Let Y represent the output image produced by histogram equalization; it can be given by the following expression: where X(i, j) represents the gray level at the spatial coordinates (i, j) for a specific pixel in the image, and X(i, j) ∈ X.

POSHE
To obtain local higher contrast and lessen the computation complexity in the process of local histogram equalization, partially overlapped sub-block histogram equalization (POSHE) is proposed [63] as a well-known LHE-based algorithm. Using POSHE, the computational complexity can be reduced while obtaining the same advantage of high contrast enhancement effects for all local regions as BOHE. Further, the common blocking effect problem accompanied with NOBHE can be reduced or eliminated. Hence, POSHE can be normally regarded as a synthesis of NOBHE and BOHE. The main idea behind this method is to move the sub-block at a certain step size, and this strategy results in the sub-block being partially overlapped. We then perform histogram equalization for the current sub-block. Finally, the transformation function for the overlapped areas can be generated by calculating the weighted sum of neighboring sub-blocks' histograms equalization.
The specific steps of POSHE, which have been established based on Ref. [63], are given as follows.
Step 1: Let us define an image with size M × N.
Step 2: Assign an m × n sub-block at the top left corner. For computational simplicity, the size of the sub-block is selected to be equal to the quotient of the input image size divided by a multiple of two.
Step 3: Perform local histogram equalization for the current sub-block.
Step 4: The sub-block moves from left to right and from top to bottom by the horizontal step size and the vertical step size. Repeat Step 3 until POSHE covers the entire input image plane.
Step 5: After sub-block histogram equalization is completed, because each pixel is obviously histogram equalized more than once, accumulated equalization results on each pixel can be divided by its histogram equalization frequency and then produce each pixel value in the output image array.
To make the procedure more understandable, Figure 2 provides an example of POSHE. Assume the sub-block (m = n) is the area surrounded by a dashed box, as shown in Figure 2. The step size is selected to be a half of the sub-block size (m/2). The sub-block moves in the direction of the arrow for the regions a, b, c, d, e, f, g, h and i, which are composed of four partially overlapped sub-blocks. They are sub-block 1 (a, b, d, e, formed), sub-block 2 (b, c, e, f, formed), sub-block 3 (d, e, g, h, formed), and sub-block 4 (e, f, h, i, formed). The four sub-blocks are processed using POSHE with a step size of m/2. Suppose that the histogram equalization functions for each sub-block are T 1 (r k ), T 2 (r k ), T 3 (r k ) and T 4 (r k ), respectively. The sub-region e is the histogram equalized by four sub-blocks 1, 2, 3 and 4. It is obvious that the pixels in sub-region e are processed four times during this procedure. Then, the POSHE transformation function of the sub-region e can be defined as follows: where s k e is the gray values after POSHE for the pixels with value of k in the region e, and r k e is the pixels with the value of k in the region e. Each histogram equalization function can be described as = n j e +n j f +n j h +n j i 4n 9 (9) where n denotes the number of pixels in the full region, n j x represents the number of pixels in sub-region x with jth level, and x = a, b, . . . , i.
T r and 4 ( ) k T r , respectively. The sub-region e is the histogram equalized by four sub-blocks 1, 2, 3 and 4. It is obvious that the pixels in sub-region e are processed four times during this procedure. Then, the POSHE transformation function of the sub-region e can be defined as follows: where e k s is the gray values after POSHE for the pixels with value of k in the region e, and e k r is the pixels with the value of k in the region e. Each histogram equalization function can be described as

The Proposed Contrast Enhancement Method
The main purpose of our proposed algorithm is to improve contrast, enhance detail information hidden in the ultrasonic logging images, and achieve naturally looking results while reducing the

The Proposed Contrast Enhancement Method
The main purpose of our proposed algorithm is to improve contrast, enhance detail information hidden in the ultrasonic logging images, and achieve naturally looking results while reducing the over-enhancement and undesirable artifact effects. From the above analysis, if HE is directly used in the POSHE, over-enhancement problem will occur in the equalized sub-block image. This issue is resolved by limiting the contrast as indicated in the description of the CLAHE [64,65] method. The slope of the histogram equalization function related to the gray level distribution is confined. This goal can be achieved by allowing only a maximum number of pixels for each gray level. After clipping of the histogram is completed, in order to make the total histogram count identical to original number, the pixels that were clipped are evenly redistributed over the whole histogram, and therefore produce limited contrast enhancement. Inspired by the CLAHE method, we introduced the idea of contrast-limited enhancement to the POSHE and proposed a novel POSHE-based optimum clip-limit contrast enhancement method for improving ultrasonic logging images (POSHEOC). The clip-limit value is a key factor to control the enhancement effect. Hence, the mean gradient and mean structural similarity are taken into account to build a new quality evaluation index, which is used to obtain optimal clip-limit value for histogram equalization of the sub-block. It selects the optimal clip-limit automatically according to different image data. This proposed POSHEOC method consists of two main steps, namely, clipped histogram equalization and optimum clip-limit strategies. The description of each step is presented in detail in the following subsections.

Clipped Histogram Equalization
The POSHE algorithm employs the conventional histogram equalization (HE) algorithm to process each sub-block. Although the classic HE may provide the best visual performance under certain conditions, its major drawback is over-enhancement when high peaks occur in the PDF of the histogram for an image. As given in Equation (2) in Section 2.1, the enhancement from histogram equalization is heavily dependent on CDF. This is to say, if the curve of CDF is too steep, the HE will stretch the dynamic range of the high concentration regions excessively and will result in over-enhancement phenomenon. On the other hand, if the region of interest in the image occupies only a small percentage, it will not be appropriately enhanced. Therefore, the enhancement degree is proportional to the slope of c(r k ) (defined in Section 2.1). The slope of c(r k ) is given by The enhancement rate can be adjusted by reducing or increasing the value of p(r k ). In order to limit the contrast to a desired level, a technique proposed in the CLAHE method [64,65] is restraining the slope of CDF for the original image, and it can be achieved by clipping the histogram with values over a predefined threshold, and the residual is redistributed uniformly to the histogram. The maximum slope is limited using a clip limit β to clip all histograms; β can be defined as follows [64,70]: where N t and L t are total numbers of pixels and gray-levels in each region, respectively, s max is the maximum allowable slope, and a is the clip factor. If α = 0, the minimum clip limit β is equal to ( N t L t ) which can reach the maximum value of (s max · N t L t ) for α = 100. It is clear that various s max values will affect the processed results. Normally, s max is set to four for the application of still X-ray images as reported in Ref. [64]. However, for other applications, it is recommended that a good selection for s max is obtained by practical experiment.
When the POSHE algorithm is used, the histogram should be clipped before sub-block equalization and then evenly distributed to each gray-level. By limiting the histogram height, the slope of the CDF curve can be reduced, that is, the contrast enhancement can be reduced to restrain the noise amplification and local over-enhancement. The clipping and redistribution processes are described in the following steps: Step 1: Define h(k) as the pixel number of gray-level k (k = 0, 1, . . . , L t − 1) and set the average number of pixels per grayscale as N av for any sub-block with size m × n. Then, N t = m · n, for an 8-bit grayscale image, L t = 256, and N av = N t L t = m×n 256 . The total number of pixels whose histogram values exceed the clip limit β is represented as Excess with the initial value being 0.
Step 2: Clip the histogram with the value beyond the clip limit β; i.e., if h(k) > β, k = 0, 1, . . . , L t − 1, then, Excess = Excessβ + h(k), h(k) = β. This step modifies the histogram by preserving the histograms that are less than or equal to β, while clipping the ones that exceed β.
Step 3: Accumulate exceeded pixel counts Excess obtained from Step 2 and redistribute them to all the histogram bins. If N m is used to represent the number of pixels that should be equally assigned to each gray-level, then N m = Excess/L t . The histogram h(k) after the redistribution is given by Equation (12), and Excess after the redistribution is generated as in Equation (13): In this step, excess pixel counts that exceed the clip limit are recursively distributed among pixels with numbers less than or equal to β.
Step 4: Cyclic allocation of remaining clipped pixels; if Excess is still more than zero after Step 3, then the resultant clipped pixels that have not been allocated are redistributed again. If h(k) < β, then, h(k) = h(k) + 1, Excess = Excess − 1, and the process is repeated until Excess is equal to zero. Thus, the procedure of histogram reassignment is completed and a new histogram with limited contrast is generated. For each region, the grayscale mapping function can be calculated by using Equation (3) in Section 2.1 for its modified histogram. Figure 3 shows an example of vehicle surveillance image enhanced results by the HE and the clipped HE method. Figure 3a is the original image with size 500 × 374 pixels, in which most of the pixels are located in the low-level region and it has a dimmed appearance. Figure 3b is the enhanced result by the HE method. To improve overall contrast enhancement of the input image, HE generates a uniform probability distribution of the gray-level by means of expanding the dynamic range of the input image histogram. Unfortunately, over-enhancement occurs in some parts as shown inside the regions of the red rectangle, which result in excessive brightness on the ground and loss of digital information in the license plate in Figure 3b. Figure 3c,d is enhanced images of the clipped HE method with β being equal to 2.5 and 1.5 times of the average number of pixels per grayscale N av , respectively. The over-enhancement phenomenon is avoided to different degrees with different β values, as presented in Figure 3c,d. It is clear that the enhanced image quality highly depends on the selection of β value, whose value can be chosen empirically. The clipping and redistribution processes are depicted in Figure 4. Figure 4a is the corresponding histogram of Figure 3a, where the horizontal axis and vertical axis represent the intensity values and the probability of occurrence of intensity levels, respectively. Let us assume that the clip limit β be given by the horizontal dotted line. Figure 4b shows the histogram of the original input image in Figure 3a and the modified limited histogram after redistribution according to the clipping and redistribution procedure mentioned above. The comparison curves of the cumulative density function for the original and the modified limited histogram with β = 2.5 N av and β = 1.5 N av are illustrated in Figure 4c,d, respectively. It is obvious that the slope of the clip-limited CDF (dotted line) is less than the original CDF (solid line) in the range of the 20-100 gray-level, in which most pixels for the original image are concentrated. The input gray values in the range of 20-100 are extended to the full range by the original CDF and a narrower range of output values by the clip limited CDF, which is the reason for the excessive enhancement shown in Figure 3b but avoided in Figure 3c,d. Comparing CDF curves in Figure 4c,d, the smaller the clip limit value, the lower the slope of CDF, thus, the higher the ability to restrain the contrast, whereas, higher values of the clip limit result in more contrast enhancement. Figure 4d shows the higher limit ability with a smaller β. From the corresponding enhancement image in Figure 3d, it effectively overcomes the over-enhancement problem appeared in Figure 3b, while a very slight over-enhancement phenomenon still occurs with a bigger β in Figure 3c. Since this clipped histogram equalization is still a global approach that is useful to enhance the content of the entire input image, it fails to highlight details of the local regions. narrower range of output values by the clip limited CDF, which is the reason for the excessive enhancement shown in Figure 3b but avoided in Figure 3c,d. Comparing CDF curves in Figure 4c,d, the smaller the clip limit value, the lower the slope of CDF, thus, the higher the ability to restrain the contrast, whereas, higher values of the clip limit result in more contrast enhancement. Figure 4d shows the higher limit ability with a smaller β. From the corresponding enhancement image in Figure 3d, it effectively overcomes the over-enhancement problem appeared in Figure 3b, while a very slight over-enhancement phenomenon still occurs with a bigger β in Figure 3c. Since this clipped histogram equalization is still a global approach that is useful to enhance the content of the entire input image, it fails to highlight details of the local regions.  narrower range of output values by the clip limited CDF, which is the reason for the excessive enhancement shown in Figure 3b but avoided in Figure 3c,d. Comparing CDF curves in Figure 4c,d, the smaller the clip limit value, the lower the slope of CDF, thus, the higher the ability to restrain the contrast, whereas, higher values of the clip limit result in more contrast enhancement. Figure 4d shows the higher limit ability with a smaller β. From the corresponding enhancement image in Figure 3d, it effectively overcomes the over-enhancement problem appeared in Figure 3b, while a very slight over-enhancement phenomenon still occurs with a bigger β in Figure 3c. Since this clipped histogram equalization is still a global approach that is useful to enhance the content of the entire input image, it fails to highlight details of the local regions.

Optimum Clip-Limit Strategies
From the discussion in Section 3.1, the major shortcoming of the existing clipped histogram equalization method is that a pre-defined clip limit value is set to limit the input histograms, and in most of the cases the user has to manually select the clip limit to achieve a good enhancement result. This operation makes these methods not appropriate for automatic systems. To enhance the image properly, in this paper, the proposed POSHEOC algorithm employs two measures to find the optimal clip-limit. It selects the optimal clip-limit automatically according to different image data. They are the mean gradient (MG) [45] and mean structural similarity index (MSSIM) [76]. MG is considered as one of the most robust and functionally accurate image quality measures [45,71,72] and is defined by where , i j x ∇ denotes the image gradient magnitude at pixel (i, j), which is calculated within a local 3 × 3 square window using the Sobel operators, and M × N is the image size. In general, MG rises when both the quantity and intensity of gradients of an image increase; a large MG indicates the image has strong local contrast or texture variation, However, MG that is too high is often accompanied by an unnatural look because of over-enhancement and the quality of the image is decreased. Although the mentioned measure can provide a rough estimation of the image contrast, it fails to evaluate the quality under the condition of over-enhanced images. Since in this case, the structure of the original image cannot be preserved, employing some other quantities index that can evaluate the structural similarity between the original and the enhanced images becomes necessary. Hence, MSSIM is employed. It is a quality assessment for measuring the similarity between two images [73,74,76].
where the terms μx and μy, are the mean intensity, σx and σy are the standard deviation and σxy is the covariance of images x and y, respectively, and c1, c2 are the constant values. The local parameters μx, μy, σx, σy and σxy are calculated within a local 8 × 8 square window, and the square window slides from pixel to pixel over the whole image. At each step, the SSIM index together with the local parameters are computed within the local window. Based on the value of SSIM, MSSIM can be calculated by

Optimum Clip-Limit Strategies
From the discussion in Section 3.1, the major shortcoming of the existing clipped histogram equalization method is that a pre-defined clip limit value is set to limit the input histograms, and in most of the cases the user has to manually select the clip limit to achieve a good enhancement result. This operation makes these methods not appropriate for automatic systems. To enhance the image properly, in this paper, the proposed POSHEOC algorithm employs two measures to find the optimal clip-limit. It selects the optimal clip-limit automatically according to different image data. They are the mean gradient (MG) [45] and mean structural similarity index (MSSIM) [76]. MG is considered as one of the most robust and functionally accurate image quality measures [45,71,72] and is defined by where ∇x i,j denotes the image gradient magnitude at pixel (i, j), which is calculated within a local 3 × 3 square window using the Sobel operators, and M × N is the image size. In general, MG rises when both the quantity and intensity of gradients of an image increase; a large MG indicates the image has strong local contrast or texture variation, However, MG that is too high is often accompanied by an unnatural look because of over-enhancement and the quality of the image is decreased. Although the mentioned measure can provide a rough estimation of the image contrast, it fails to evaluate the quality under the condition of over-enhanced images. Since in this case, the structure of the original image cannot be preserved, employing some other quantities index that can evaluate the structural similarity between the original and the enhanced images becomes necessary. Hence, MSSIM is employed. It is a quality assessment for measuring the similarity between two images [73,74,76]. Suppose x and y are two nonnegative image signals for calculating the MSSIM, first we need to calculate SSIM (structural similarity index) [76] using where the terms µ x and µ y , are the mean intensity, σ x and σ y are the standard deviation and σ xy is the covariance of images x and y, respectively, and c 1 , c 2 are the constant values. The local parameters µ x , µ y , σ x , σ y and σ xy are calculated within a local 8 × 8 square window, and the square window slides from pixel to pixel over the whole image. At each step, the SSIM index together with the local parameters are computed within the local window. Based on the value of SSIM, MSSIM can be calculated by where X and Y are the input and enhanced image, respectively, x i , y i are used to describe the image contents for the ith local window; and N represents the total number of local windows of the image. In general, a high MSSIM value for an enhanced image represents a good similarity index. We assume clip limit value β = nN av before performing sub-block equalization in the proposed POSHEOC algorithm according to the analysis in Section 3.1 and the minimum value of n is one. It is obvious that the POSHEOC algorithm cannot enhance the image sufficiently if n is set to a small value whereas it may result in over-enhancement when n is too big; therefore, n is set to be in the range of [1,10]. Figure 5 shows an example of the relationships between the two mentioned measures and n. Figure 5a,b plots the metrics MG and MMSIM of enhanced image with different n, respectively. Opposite varying tendencies of the two measures with the clip-limit value are observed. Considering the effects of the two factors, finally, we combine the two metrics, and a new index can be built by means of the product of the mean gradient and mean structural similarity (PMGSIM), which is defined by the following Equation (17). It is used to calculate the optimal n value. The optimal value of n in the range of [1,10] can be obtained by Equation (18).  (16) where X and Y are the input and enhanced image, respectively, xi, yi are used to describe the image contents for the ith local window; and N represents the total number of local windows of the image. In general, a high MSSIM value for an enhanced image represents a good similarity index. We assume clip limit value β = nNav before performing sub-block equalization in the proposed POSHEOC algorithm according to the analysis in section 3.1 and the minimum value of n is one. It is obvious that the POSHEOC algorithm cannot enhance the image sufficiently if n is set to a small value whereas it may result in over-enhancement when n is too big; therefore, n is set to be in the range of [1,10]. Figure 5 shows an example of the relationships between the two mentioned measures and n. Figure 5a,b plots the metrics MG and MMSIM of enhanced image with different n, respectively. Opposite varying tendencies of the two measures with the clip-limit value are observed. Considering the effects of the two factors, finally, we combine the two metrics, and a new index can be built by means of the product of the mean gradient and mean structural similarity (PMGSIM), which is defined by the following Equation (17). It is used to calculate the optimal n value. The optimal value of n in the range of [1,10] can be obtained by Equation (18).  Figure 6 shows an illustration of the selection of the optimal parameter n. Figure 6a is the original ultrasonic logging image with size 174 × 187 pixels for the model well, Figure 6b plots the PMGSIM of the enhanced image with different n values in terms of Equation (17), and Figure 6c-e shows the enhanced images of POSHEOC with n equal to 1.5, 3 and 6, respectively. As can be noticed from Figure 6b, PMGSIM depicts the obvious maximum value with n being equal to 3. The corresponding enhanced image yields the highest subjective quality as shown in Figure 6c. It improves the contrast, and reveals the hidden details; e.g., the small hole at the lower left of the image. Figure 6b is the POSHEOC result with n = 1.5. It enhances the contrast of original image insufficiently, unable to explore more textural details. In Figure 6c, the POSHEOC result with α = 6 shows a higher contrast but it has a noise addition problem in the homogeneous regions because of over-enhancement. In most cases, the optimal parameter n gained using Equation (18) generates good visual quality in extensive experiments.  Figure 6 shows an illustration of the selection of the optimal parameter n. Figure 6a is the original ultrasonic logging image with size 174 × 187 pixels for the model well, Figure 6b plots the PMGSIM of the enhanced image with different n values in terms of Equation (17), and Figure 6c-e shows the enhanced images of POSHEOC with n equal to 1.5, 3 and 6, respectively. As can be noticed from Figure 6b, PMGSIM depicts the obvious maximum value with n being equal to 3. The corresponding enhanced image yields the highest subjective quality as shown in Figure 6c. It improves the contrast, and reveals the hidden details; e.g., the small hole at the lower left of the image. Figure 6b is the POSHEOC result with n = 1.5. It enhances the contrast of original image insufficiently, unable to explore more textural details. In Figure 6c, the POSHEOC result with α = 6 shows a higher contrast but it has a noise addition problem in the homogeneous regions because of over-enhancement. In most cases, the optimal parameter n gained using Equation (18) generates good visual quality in extensive experiments.

Experimental Results and Discussion
In this section, ultrasonic logging images of both the model well and open borehole are utilized to test the performance of the proposed OC POSHE algorithm. The experimental results produced by seven HE and HE-based methods, including HE [62], BBHE [50], RMSHE [51], CLAHE-PL [41], POSHE [63], BOHE [61], MLBOHE [60], are compared with our proposed POSHEOC method.

Subjective Evaluation
To demonstrate the performance of the proposed method, we first take the processing results of the model well as an example. Figure 7 shows the processed results of ultrasonic logging image for the model well, which was captured by the ultrasonic image-logging instrument CBIL that uses piezoceramic transducers. The original image and the enhanced images using different enhancement methods along with their corresponding histograms are illustrated in Figure 7a-i. For each histogram, the horizontal axis represents intensity values and the vertical axis corresponds to the number of occurrence of intensity levels. The original image contains the number 8, V shape, arc shape, several circular holes, vertical strips, and some other details. It can be observed from the histogram distribution in Figure 7a that most of the pixels of the original image are concentrated in the high level of intensity. In this case, the image with narrow dynamic range of gray values exhibits low contrast. The HE method directly stretches the histogram of the original image, although the contrast of overall image was enhanced, various undesirable artifacts were produced in the homogeneous background regions due to over enhancement, as indicated in Figure 7b. The over-enhancement phenomenon cannot be avoided in BOHE and POSHE, which also result in unnatural look, as shown in Figure 7c,d. The mentioned three methods increased the contrast and

Experimental Results and Discussion
In this section, ultrasonic logging images of both the model well and open borehole are utilized to test the performance of the proposed OC POSHE algorithm. The experimental results produced by seven HE and HE-based methods, including HE [62], BBHE [50], RMSHE [51], CLAHE-PL [41], POSHE [63], BOHE [61], MLBOHE [60], are compared with our proposed POSHEOC method.

Subjective Evaluation
To demonstrate the performance of the proposed method, we first take the processing results of the model well as an example. Figure 7 shows the processed results of ultrasonic logging image for the model well, which was captured by the ultrasonic image-logging instrument CBIL that uses piezoceramic transducers. The original image and the enhanced images using different enhancement methods along with their corresponding histograms are illustrated in Figure 7a-i. For each histogram, the horizontal axis represents intensity values and the vertical axis corresponds to the number of occurrence of intensity levels. The original image contains the number 8, V shape, arc shape, several circular holes, vertical strips, and some other details. It can be observed from the histogram distribution in Figure 7a that most of the pixels of the original image are concentrated in the high level of intensity. In this case, the image with narrow dynamic range of gray values exhibits low contrast. The HE method directly stretches the histogram of the original image, although the contrast of overall image was enhanced, various undesirable artifacts were produced in the homogeneous background regions due to over enhancement, as indicated in Figure 7b. The over-enhancement phenomenon cannot be avoided in BOHE and POSHE, which also result in unnatural look, as shown in Figure 7c,d. The mentioned three methods increased the contrast and revealed some hidden details. However, the size of some detailed information is amplified along with background noise (see the small holes at the lower left of the image). We notice that the shape of the histograms generated from HE, BOHE, and POSHE are greatly different from their corresponding input histograms. It means that the original brightness is distorted, as can be seen in Figure 7b-d. Figure 7e shows the enhancement results produced by the MLBOHE. This algorithm is actually an advanced version of BOHE, which introduced multiple layers of the block overlapped histogram equalization to successfully overcome noise amplification and intensity distortion problems. Unfortunately, the enhanced image was blurred to some extent because the median filters are adopted to reduce the noise. BBHE slightly preserved the shape of the input histogram, but the middle part is relatively sparse, thus losing some detailed information of intensity. The small holes at the lower left and the arc-shaped at the upper left of the image cannot be displayed completely, as illustrated in Figure 7f. RMSHE further preserved the shape of the input histogram on the basis of BBHE in order to maintain the mean intensity of the original image, yet the contrast was insufficient, and some details hidden in the image are still not brought out, as shown in Figure 7g. Figure 7h is the enhancement result using CLAHE-PL. This technique produces the enhanced image with a good contrast, and the small hole and the arc-shaped located on the above of "digit 8" appeared except that the right half of the image is a slightly dark. Nevertheless, the clip-limit value and power-law transformation parameters in the CLAHE-PL method need to be adjusted to the most appropriate value manually. Figure 7i displays the enhanced image produced by the proposed POSHEOC method. In all experiments, for the input image of size M × N, the sub-block is set to M/8 × N/8, the horizontal step size and the vertical step size are both set to M/64, by inspection; it produces better visual quality when compared with the previous approaches. The over-enhancement phenomenon is avoided and the contrast is enhanced properly. The small and local details hidden in the image are revealed while the shape of the input histogram is preserved. with background noise (see the small holes at the lower left of the image). We notice that the shape of the histograms generated from HE, BOHE, and POSHE are greatly different from their corresponding input histograms. It means that the original brightness is distorted, as can be seen in Figure 7b-d. Figure 7e shows the enhancement results produced by the MLBOHE. This algorithm is actually an advanced version of BOHE, which introduced multiple layers of the block overlapped histogram equalization to successfully overcome noise amplification and intensity distortion problems. Unfortunately, the enhanced image was blurred to some extent because the median filters are adopted to reduce the noise. BBHE slightly preserved the shape of the input histogram, but the middle part is relatively sparse, thus losing some detailed information of intensity. The small holes at the lower left and the arc-shaped at the upper left of the image cannot be displayed completely, as illustrated in Figure 7f. RMSHE further preserved the shape of the input histogram on the basis of BBHE in order to maintain the mean intensity of the original image, yet the contrast was insufficient, and some details hidden in the image are still not brought out, as shown in Figure 7g. Figure 7h is the enhancement result using CLAHE-PL. This technique produces the enhanced image with a good contrast, and the small hole and the arc-shaped located on the above of "digit 8" appeared except that the right half of the image is a slightly dark. Nevertheless, the clip-limit value and power-law transformation parameters in the CLAHE-PL method need to be adjusted to the most appropriate value manually. Figure Figure 8 shows an example of the processed results of the ultrasonic logging image for Changqingyi well, which was captured by the piezoceramic ultrasonic imaging logging instrument BHTV. Figure 8a illustrates the original amplitude image with size 161 × 312 pixels for the Changqingyi well and its corresponding histogram, and, as can be seen, it exhibits low contrast which is not conducive to the analysis and recognition of geological features. In Figure 8b, HE is used directly to equalize the input histogram for generating an enhanced image with high contrast; the histogram seems to be relatively sparse. This is due to the fact that some pixels with low probability of occurrence are merged, which leads to the fact that bright regions of the middle part in the image are submerged. It also makes the regions with low intensity even darker and excessively  Figure 8 shows an example of the processed results of the ultrasonic logging image for Changqingyi well, which was captured by the piezoceramic ultrasonic imaging logging instrument BHTV. Figure 8a illustrates the original amplitude image with size 161 × 312 pixels for the Changqingyi well and its corresponding histogram, and, as can be seen, it exhibits low contrast which is not conducive to the analysis and recognition of geological features. In Figure 8b, HE is used directly to equalize the input histogram for generating an enhanced image with high contrast; the histogram seems to be relatively sparse. This is due to the fact that some pixels with low probability of occurrence are merged, which leads to the fact that bright regions of the middle part in the image are submerged. It also makes the regions with low intensity even darker and excessively bright in high gray level regions because of excessive contrast enhancement. Although the enhancement results of both the BOHE and POSHE methods highlight the local detailed information, the regions with over-enhancement still appear. In particular, the regions with relatively low intensity are changed into large areas of dark regions and the mean brightness is heavily shifted, leading to an unnatural look. Similar to the histogram distribution in Figure 8c,d, they are very different from the corresponding input histogram. MLBOHE significantly preserves the shape of the input histogram and removes the background noise. However, it produces an obscure enhanced image, as indicated in Figure 8e. The result of the BBHE is similar to that of the HE. It enhances overall contrast while missing local details, as shown in Figure 8f. RMSHE preserves the mean brightness of the original input image to some extent by iteratively applying BBHE to the sub-histograms. The local details are still not clear, as displayed in Figure 8g. In Figure 8h, CLAHE obtains a good enhancement without over-enhancement, and local details hidden in the bright area appear. Figure 8i shows the enhanced image using the proposed POSHEOC method. It generates a good visual quality without unnatural artifacts, and the contrast is enhanced properly. Local details hidden in the bright regions are revealed and the horizontal textures located on the lower half part of the image are more distinguishable. Although the enhanced results between the CLAHE-PL and POSHEOC approaches are competitive, it can be observed that the latter has better ability to preserve the shape of the input histogram. Therefore, the proposed POSHEOC method is more effective than all the previous techniques. Advantages in objective metrics will be provided in the next subsection. bright in high gray level regions because of excessive contrast enhancement. Although the enhancement results of both the BOHE and POSHE methods highlight the local detailed information, the regions with over-enhancement still appear. In particular, the regions with relatively low intensity are changed into large areas of dark regions and the mean brightness is heavily shifted, leading to an unnatural look. Similar to the histogram distribution in Figure 8c,d, they are very different from the corresponding input histogram. MLBOHE significantly preserves the shape of the input histogram and removes the background noise. However, it produces an obscure enhanced image, as indicated in Figure 8e. The result of the BBHE is similar to that of the HE. It enhances overall contrast while missing local details, as shown in Figure 8f. RMSHE preserves the mean brightness of the original input image to some extent by iteratively applying BBHE to the sub-histograms. The local details are still not clear, as displayed in Figure 8g. In Figure 8h, CLAHE obtains a good enhancement without over-enhancement, and local details hidden in the bright area appear. Figure 8i shows the enhanced image using the proposed POSHEOC method. It generates a good visual quality without unnatural artifacts, and the contrast is enhanced properly. Local details hidden in the bright regions are revealed and the horizontal textures located on the lower half part of the image are more distinguishable. Although the enhanced results between the CLAHE-PL and POSHEOC approaches are competitive, it can be observed that the latter has better ability to preserve the shape of the input histogram. Therefore, the proposed POSHEOC method is more effective than all the previous techniques. Advantages in objective metrics will be provided in the next subsection.  Figure 9 shows another example of the processed results of the ultrasonic logging image for Changqingli well and it was captured by the ultrasonic imaging logging instrument CBIL. Figure 9a is the original amplitude image with fracture information and its corresponding histogram, while Figure 9b-i demonstrate enhanced images with different methods, and the size of the test image is 144 × 270. It is observed from the histogram distribution of Figure 9a that the contrast of the whole input image is better than that of the previous two examples; however, the fractured belts in the middle part of the image are still in low contrast. Although the contrast of the whole image is significantly increased by the HE, BOHE, POSHE and BBHE methods and the image of the fractured belts is clearer than the original one, some adverse effects were generated. For example, the left and right sides of the lower half part in the image become too dark, as shown in Figure 9b-d,f. Similar to the previous examples in Figures 7 and 8, MLBOHE eliminated the background noise but blurred the image, as displayed in Figure 9e. Obviously, the contrast of the whole image along with fractured belts is not well enhanced by the RMSHE, as shown in Figure 9g. CLAHE-PL and the proposed POSHEOC obtained a good enhancement results without over-enhancement, but the two methods have better ability of brightness preservation and produce fewer artifacts as demonstrated by Figure 9h,i.  Figure 9 shows another example of the processed results of the ultrasonic logging image for Changqingli well and it was captured by the ultrasonic imaging logging instrument CBIL. Figure 9a is the original amplitude image with fracture information and its corresponding histogram, while Figure 9b-i demonstrate enhanced images with different methods, and the size of the test image is 144 × 270. It is observed from the histogram distribution of Figure 9a that the contrast of the whole input image is better than that of the previous two examples; however, the fractured belts in the middle part of the image are still in low contrast. Although the contrast of the whole image is significantly increased by the HE, BOHE, POSHE and BBHE methods and the image of the fractured belts is clearer than the original one, some adverse effects were generated. For example, the left and right sides of the lower half part in the image become too dark, as shown in Figure 9b-d,f. Similar to the previous examples in Figures 7 and 8, MLBOHE eliminated the background noise but blurred the image, as displayed in Figure 9e. Obviously, the contrast of the whole image along with fractured belts is not well enhanced by the RMSHE, as shown in Figure 9g. CLAHE-PL and the proposed POSHEOC obtained a good enhancement results without over-enhancement, but the two methods have better ability of brightness preservation and produce fewer artifacts as demonstrated by Figure 9h,i.

Objective Evaluation
In addition to the subjective evaluation, quantitative measures are also crucial in comparing the performance of different image enhancement approaches. In this paper, the product of mean gradient and mean structural similarity (PMGSIM) given by Equation (17), the peak signal to noise ratio (PSNR) [59,60,74], the information entropy (IE) [53,68], the absolute mean brightness error (AMBE) [59,60,74], and the local contrast (LC) [75] values are employed here for the objective evaluation. Assuming that the size of the original image X is M × N, and Y is the enhanced image. PSNR is then defined as, where fmax is the maximum intensity of the input image, for the common 8-bit gray-level image with 256 possible gray level values, as it is known that fmax = 255. Generally, PSNR is used to estimate the artifacts or noise produced in the process of contrast enhancement. It is expected that a good enhancement method will generate a high PSNR value. AMBE is the absolute mean brightness error between the input and output image, which is described as:

Objective Evaluation
In addition to the subjective evaluation, quantitative measures are also crucial in comparing the performance of different image enhancement approaches. In this paper, the product of mean gradient and mean structural similarity (PMGSIM) given by Equation (17), the peak signal to noise ratio (PSNR) [59,60,74], the information entropy (IE) [53,68], the absolute mean brightness error (AMBE) [59,60,74], and the local contrast (LC) [75] values are employed here for the objective evaluation. Assuming that the size of the original image X is M × N, and Y is the enhanced image. PSNR is then defined as, where f max is the maximum intensity of the input image, for the common 8-bit gray-level image with 256 possible gray level values, as it is known that f max = 255. Generally, PSNR is used to estimate the artifacts or noise produced in the process of contrast enhancement. It is expected that a good enhancement method will generate a high PSNR value. AMBE is the absolute mean brightness error between the input and output image, which is described as: where, µ X and µ Y are the mean intensity values of X and Y, respectively. The lower the value of AMBE, the better is the brightness preservation and vice versa. IE is an effective way to evaluate the amount of information content within an image; for the image with the gray level in the range [0, L − 1], the entropy of the image can be expressed as where p(s i ) represents probability density function for a given image at gray level s i . In general, a larger value of the entropy indicates more richness of details is available in the image. The local contrast criterion is defined in Equation (22) where I max i,j and I min i,j are the maximum and minimum gray values of a specific block (5 × 5 in this work) center on pixel (i, j), and c is a small constant with the value equals to 0.0001 to avoid dividing by 0. A large local contrast value represents a strong contrast. Table 1 lists the corresponding quantitative measures PMGSIM, PSNR, IE, AMBE and LC results of different enhancement algorithms for ultrasonic logging images of the model well in Figure 7. The proposed POSHEOC produces the highest PMGSIM values when compared to all the other techniques, since the proposed POSHEOC enhances the contrast of image effectively while taking into account of the negative impacts of over-enhancement. Comparison with PSNR, AMBE shows that the performance of the proposed POSHEOC method on the image is better than the other six methods except for RMSHE. In the process of RMSHE, the output mean is closer to the input mean as the recursion level becomes larger, and the original mean brightness can be preserved to reduce artifacts at a greater degree through increasing the level of histogram division. Therefore, it obtains the highest PSNR and lowest AMBE values; however, its contrast enhancement capability was not notable, as can be noticed from the LC value in Table 1, resulting in poor quality. By inspection, the IE and LC values of BOHE, POSHE are relatively higher than the other methods. Since an image with uniform distribution histogram has the maximum information entropy, a high value of IE owing to the gray level is evenly distributed in POSHE and BOHE, as can be seen from histogram distribution in Figure 7c-d. However, the values of PMGSIM, PSNR, AMBE for BOHE, POSHE show the poorer performance among the tested methods. This is due to more emphasis on local details which also results in a high LC value; those coarse details are the results from background noise amplification. Therefore, the higher IE and LC values of BOHE, POSHE do not represent better quality; we can observe enhanced results accompanied by undesired artifacts in Figure 7c-d. A median value of IE and LC for the proposed POSHEOC obtains better quality, since the very high and very low value of the two aforementioned indexes represents excessive enhancement and insufficient enhancement, respectively. Further, when visual quality between the CLAHE-PL and the proposed POSHEOC are almost the same, all the objective metrics of the proposed POSHEOC are better than those of CLAHE-PL except for the slightly higher IE value of CLAHE-PL. Tables 2 and 3 summarize corresponding performance measure values of PMGSIM, PSNR, IE, AMBE and LC for ultrasonic logging image of Changqingli well in Figures 8 and 9 using eight different methods. The variation tendency of simulation data is almost in accordance with that of data in Table 1. The proposed algorithm is demonstrated to have the best enhancement effect when compared with other existing approaches from Tables 2 and 3.

Conclusions
In this work, a novel POSHE-based optimum clip-limit contrast enhancement method to improve the ultrasonic well logging images (POSHEOC) is proposed. The algorithm introduces the idea of contrast-limitation to modify the cumulative distribution functions of the partially overlapped sub-block histogram equalization and obtains optimal clip-limit by considering the effects of the mean gradient and mean structural similarity. The proposed algorithm makes the choice of optimal clip-limit automatically according to the different input image. The proposed POSHEOC shows better performance in enhancing the contrast, emphasizing the local details while preserving the brightness and restricting the excessive enhancement compared with several other histogram equalization-based techniques from the literature. This is demonstrated in experimental results based on visual perceptual evaluation and quantitative measures. We anticipate that this study also helps to provide a feasible and efficient approach to improve well logging images and is significant for the interpretation of actual ultrasonic logging data. In addition, future research will involve the development of simpler methods to obtain the optimal clip-limit value.