# A Parallel Retinex Image Enhancement Algorithm Based on OpenMP

Shixiong Cheng, Bin Liu, Dongjian He, Jinrong He, Yuancheng Li, Yanning Du

► To cite this version:

Shixiong Cheng, Bin Liu, Dongjian He, Jinrong He, Yuancheng Li, et al.. A Parallel Retinex Image Enhancement Algorithm Based on OpenMP. 16th IFIP International Conference on Network and Parallel Computing (NPC), Aug 2019, Hohhot, China. pp.376-381, 10.1007/978-3-030-30709-7_37 hal-03770565

HAL Id: hal-03770565

https://inria.hal.science/hal-03770565v1

Submitted on 6 Sep 2022

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
A Parallel Retinex Image Enhancement Algorithm Based
on OpenMP

Shixiong Cheng¹, Bin Liu¹, ², ³ (✉), Dongjian He², ³, ⁴, Jinrong He⁵, Yuancheng Li⁶,
and Yanning Du⁷

¹College of Information Engineering, Northwest A&F University, Yangling, Shaanxi, China

²Key Laboratory of Agricultural Internet of Things (Northwest A&F University), Ministry of Agriculture and Rural Affairs, Yangling, Shaanxi 712100, China

³Shaanxi Key Laboratory of Agricultural Information Perception and Intelligent Service (Northwest A&F University), Yangling, Shaanxi 712100, China
liubin0929@nwsuaf.edu.cn

⁴College of Mechanical and Electronic Engineering, Northwest A&F University, Yangling, Shaanxi, China

⁵College of Mathematics and Computer Science, Yan'an University, Yan'an, Shaanxi, China

⁶School of Computer Science and Technology, Xi'an University of Science and Technology, Xi'an, China

⁷School of Computer Science & Engineering, Xi'an University of Technology, Xi'an, China

**Abstract.** Retinex image enhancement algorithm occupies an important position in eliminating image uneven exposure, low contrast, and smog influence. However, with the increasing of image resolution, the real-time performance of the serial Retinex algorithm has not satisfied the requirements of practical applications. This paper proposes an OpenMP-based parallel Retinex algorithm. The parallelism of the Retinex algorithm is first identified by theoretical analyses. Then, the time-consuming sub-algorithms such as Gaussian convolution and exponential transformation, of the serial algorithm are designed and executed in parallel. On Tianhe-2 supercomputer platform, the experimental results show that the speedup of the parallel algorithm is significantly improved, and the test image set achieves an average speedup of 12. It indicates that the parallel algorithm can satisfy the needs of real-time processing in image enhancement field.

**Keywords:** Image Enhancement, Parallel Algorithm, Retinex, OpenMP, Agricultural Image.

# 1 Introduction

Image enhancement algorithms are basic work in many areas especially in the public security, biomedical field, health service, and marine information field, where significant achievements have been made in [1-3]. At present, researchers have proposed a great diversity of parallel image processing algorithms, such as CUDA-based image enhancement algorithms [4], and image processing algorithms based on multicore DSP

✉Corresponding author: Bin Liu
E-mail: liubin0929@nwsuaf.edu.cn.
[5]. However, as one of the most important images processing technologies, the serial single-scale Retinex (SSR) algorithm is still too slow to finish the image enhancement tasks within an acceptable time.

In order to solve above problem, this paper proposes the parallel SSR image enhancement algorithm based on OpenMP. The parallel SSR image enhancement algorithm is implemented on the Tianhe-2 supercomputer using the OpenMP programming model, which is evaluated and achieves an average speedup of 12. The experimental results show that the proposed parallel algorithm can fulfill the needs of real-time processing in image enhancement field.

# 2 Parallel Design and Implementation

## 2.1 Parallelism analyses

SSR algorithm enhances an image through the implementation of sub-algorithms such as Gaussian template, Gaussian convolution, and exponential transformation. As the data processed by these sub-algorithms is independent of each other, SSR algorithm has good parallelism. As illustrated in Fig. 1, the following three aspects are presented to analyze the parallelism of the serial SSR algorithm.

Parallelism 1: the blurred image estimating the incident illumination component is generated by Gaussian convolution operations. During this, each pixel is not associated with others. So, the image can be divided into sub-blocks for parallel computing.

Parallelism 2: the size of the Gaussian template is determined by the input parameters. When the Gaussian weight is normalized, each pixel is divided respectively by the sum of the weights, This process can be calculated in parallel.

Parallelism 3: the operation of exponential transformation can be also executed in parallel because there is no data dependence directly in those operations.

<figure><img src="image_3.png" /><figcaption>Fig. 1. The parallelism of single-scale Retinex algorithm</figcaption></figure>

## 2.2 Parallel design and implementation of SSR algorithm

In this section, parallel design of these sub-algorithms are firstly illustrated in Fig. 2 and then parallel implement are presented.

**Parallel design and implementation of Gaussian convolution.** The subsequent operation of image segmentation into different data blocks is independent in Gaussian convolution serial algorithm. This is consistent with the parallel characteristics of OpenMP because no dependence between the data of non-direct adjacent pixels in the image. And a two-dimensional Gaussian function G(x, y) could be written as the product of two one-dimensional Gaussian functions G(x) and G(y), meaning that G(x, y) can be calculated serially by convolution of G(x)δ(y) and G(y)δ(x). However each of one-di-
mensional Gaussian functions G(x) could be executed in parallel. So the two-dimen-
sional Gaussian convolution can be generated serially by two one-dimensional Gauss-
ian convolutions performed respectively in parallel in the X and Y directions. And for
example, there is an image which size is 7×7, and the convolution kernel is 3×3. It can
be seen that the convolution operation requires 9 multiplications for each element in
the image, so the total number of multiplication operations executed in sequential algo-
rithm is 7×7×9 = 441 times. In contrast, parallel execution requires only 2×7×9 = 126
operations in the case of sufficient threads. And the execution time will be reduced and
the speed will be increased compared with sequential algorithm.

**Parallel design and implementation of Gaussian template.** The Gaussian template generation is mainly divided into two steps. The first step is that the weight sum is calculated serially, and the second step is that the normalization Gaussian template is generated in parallel. Supposing a 3 by 3 normalization Gaussian template is generated in serial algorithm with one thread and needs to be executed 9 times. However, in the case of parallelized execution with 9 threads, it only needs to be executed once.

**Parallel design and implementation of exponential transformation.** The original image and the Gaussian blurred image are set to the logarithmic domain to obtain a logarithmic image. The function of exponential transformation is to extend the image's high gray level and compress the low gray level. The most critical step in the exponential transformation is the linear mapping of each value. Assuming that the image size is 1000×1000, it takes a lot of time to go through the linear mapping. If linear mapping is performed in parallel using 24 threads, the image only needs to perform 1737 operations rather than 1,000,000 in the serial algorithm. Therefore, it is very profitable to perform each worthy linear mapping in parallel.

<figure><img src="image_4.png" /><figcaption>Fig. 2. Parallel design of single-scale Retinex algorithm</figcaption></figure>

**3 Experimental results and performance analysis**

**3.1 Experimental environment and test set**

The experiment is performed on Tianhe-2 supercomputer equipped with 16000 nodes, which each node has three coprocessors, two Xeon E5-2692 processors, 24 cores and 64 GB of memory. The experimental environment is shown in Table 1. In this section, 10 different sizes of pictures are used to demonstrate the speedup performance of the
parallel algorithm, the minimum size is 1730x883, the maximum is 4000x3000, and the format is JPG. These pictures are all agricultural images, including apples, pears, kiwis, farmland and mountain forests. They are from the shooting of the Dajiang UAV. The image test set is shown in Table 2.

<table><caption>**Table 1.** EXPERIMENTAL ENVIRONMENT</caption><thead><tr><td>Name</td><td>Description</td></tr></thead><tbody><tr><td>Computer</td><td>Tianhe-2 Supercomputer</td></tr><tr><td>Processor</td><td>Intel Xeon E5-2692V2</td></tr><tr><td>Coprocessor</td><td>Intel Xeon phi</td></tr><tr><td>OS</td><td>Red Hat 4.4.7-4</td></tr><tr><td>Compiler</td><td>GCC 4.4.7</td></tr><tr><td>Cmake</td><td>Cmake-3.2.2</td></tr><tr><td>OpenCV</td><td>OpenCV-2.4.9</td></tr></tbody></table>

<table><caption>**Table 2.** IMAGE TEST SET</caption><thead><tr><td>No</td><td>Description</td><td>Resolution</td><td>Size</td></tr></thead><tbody><tr><td>img1</td><td>Farmland 1</td><td>1767x885</td><td>620KB</td></tr><tr><td>img2</td><td>Farmland 2</td><td>1730x883</td><td>261KB</td></tr><tr><td>img3</td><td>Qingyang Apple</td><td>2448x3264</td><td>2.20MB</td></tr><tr><td>img4</td><td>Ruixue Apple</td><td>2784x1856</td><td>1.09MB</td></tr><tr><td>img5</td><td>Ruiyang Apple</td><td>3088x2056</td><td>2.07MB</td></tr><tr><td>img6</td><td>Kiwi 1</td><td>3264x2448</td><td>2.19MB</td></tr><tr><td>img7</td><td>Kiwi 2</td><td>3264x2448</td><td>1.03MB</td></tr><tr><td>img8</td><td>Farmland 3</td><td>4000x3000</td><td>4.36MB</td></tr><tr><td>img9</td><td>Mountain 1</td><td>4000x3000</td><td>5.38MB</td></tr><tr><td>img10</td><td>Mountain 2</td><td>4000x3000</td><td>4.72MB</td></tr></tbody></table>

## 3.2 Speedup comparison

The running time of serial and parallel algorithms respectively in Table 3 which Th represents thread. Within a certain range, the parallel SSR algorithm shortens the image processing time with the number of OpenMP threads increasing, and the average speedup is increased by about 12. After the parallel SSR algorithm are executed in parallel from dual thread to 24 thread, the speedup is obviously improved, and the parallel SSR algorithm can achieve near linear acceleration. The speedup curve is shown in Fig. 3. This experiment was carried out on a single node of Tianhe-2 supercomputer, each node had 24 cores, and the speedup reached a peak at 24 threads, making full use of the performance of multi-core. The speedup start to reduce at 32 threads because the number of threads at this time exceeds the number of CPU cores, but the processing time is still better than the serial algorithm. And the experimental results show that the speedup of the proposed parallel algorithm is significantly improved, and can satisfy the needs of real-time processing in image enhancement field.

<table><caption>**Table 3.** COMPARISON OF RUNNING TIME (S)</caption><thead><tr><td>Name</td><td>Serial</td><td>2Th</td><td>4Th</td><td>8Th</td><td>16Th</td><td>24Th</td><td>32Th</td></tr></thead><tbody><tr><td>img1</td><td>7</td><td>4.71</td><td>2.442</td><td>1.279</td><td>0.726</td><td>0.542</td><td>0.627</td></tr><tr><td>img2</td><td>7</td><td>4.59</td><td>2.501</td><td>1.341</td><td>0.784</td><td>0.531</td><td>0.681</td></tr><tr><td>img3</td><td>39</td><td>24.799</td><td>12.746</td><td>6.733</td><td>3.897</td><td>2.86</td><td>3.445</td></tr><tr><td>img4</td><td>24</td><td>15.977</td><td>7.944</td><td>4.202</td><td>2.325</td><td>1.719</td><td>1.816</td></tr><tr><td>img5</td><td>30</td><td>19.089</td><td>9.985</td><td>5.128</td><td>2.888</td><td>2.072</td><td>2.39</td></tr><tr><td>img6</td><td>39</td><td>24.151</td><td>12.443</td><td>6.995</td><td>3.667</td><td>2.624</td><td>2.809</td></tr><tr><td>img7</td><td>39</td><td>24.437</td><td>12.281</td><td>6.609</td><td>3.619</td><td>2.626</td><td>2.837</td></tr><tr><td>img8</td><td>58</td><td>38.306</td><td>21.468</td><td>10.172</td><td>5.65</td><td>4.188</td><td>5.065</td></tr><tr><td>img9</td><td>59</td><td>36.762</td><td>18.923</td><td>9.598</td><td>5.549</td><td>4.779</td><td>4.743</td></tr><tr><td>img10</td><td>59</td><td>38.968</td><td>18.781</td><td>10.13</td><td>5.525</td><td>4.089</td><td>4.243</td></tr></tbody></table>

<figure><img src="image_5.png" /><figcaption>**Fig. 3.** Speedup comparison</figcaption></figure>
## 4 Conclusion

This paper proposes a parallel SSR algorithm based on OpenMP. Compared to the serial Retinex algorithm, the proposed parallel algorithm can achieve an average speedup of 12, which represents a significant decrease in execution time. Experimental results show that the proposed parallel algorithm can acquire a significant increase in speedup and can better meet the requirements of real-time processing of the image enhancement algorithm in the image processing field.

**Acknowledgment.** This research is supported by the National Natural Science Foundation of China under Grant No.61602388, by the Natural Science Basic Research Plan in Shaanxi Province of China under Grant No.2017JM6059, by the Fundamental Research Funds for the Central Universities 2452019064, by the China Postdoctoral Science Foundation under Grant No.2017M613216, by the Postdoctoral Science Foundation of Shaanxi Province of China under Grant No.2016BSHEDZZ121, by the Fundamental Research Funds for the Central Universities under Grants No. 2452016081, by the Key Program of the National Natural Science Foundation of China under Grant No.61834005, by China Postdoctoral Science Foundation No.2018M633585, by Natural Science Basic Research Plan in Shaanxi Province of China No.2018JQ6060, by the Natural Science Basic Research Plan in Shaanxi Province of China under Grant No.2015JM6355, and by Doctoral Starting up Foundation of Yan'an University YDBK2019-06.

## References

1. Salazar-Colores, S., Cabal-Yepez, E., Ramos-Arreguin, J.M., Botella, G., Ledesma-Carrillo, L.M., Ledesma, S.: A Fast Image Dehazing Algorithm Using Morphological Reconstruction. IEEE Transactions on Image Processing 28(5), 2357-2366 (2019).

2. Muslim, H.S.M, Khan, S.A., Hussain, S., Jamal A., Qasim, H. S. A.: A Knowledge-Based Image Enhancement and Denoising Approach. Computational and Mathematical Organization Theory, 1-14 (2018).

3. Bhowmik, M., Ghoshal, D., Bhowmik, S.: An Improved Method for The Enhancement of Under Ocean Image. In: 2015 International Conference on Communications and Signal Processing, pp. 1739-1742. IEEE, Melmaruvathur, India, (2015).

4. Li, H., Xie, W.H., Wang, X.G., Liu, S.S., Gai, Y.Y., Yang, L.: GPU Implementation of Multi-Scale Retinex Image Enhancement Algorithm. In: 2016 IEEE/ACS 13th International Conference of Computer Systems and Applications, pp. 1-5. IEEE, Agadir, Morocco, (2016).

5. Wang, G., Liu, X.: A Parallel Image Processing Platform based on Multi-Core DSP. In: 2017 IEEE/ACIS 16th International Conference on Computer and Information Science, pp. 775-779. IEEE, Wuhan, China, (2017).