Adaptive binarization with non-uniform image illumination

Roman Lishchuk*, Volodymyr Kucheruk**, Igor Piotr Kurytnik***

*Uman National University of Horticulture, Ukraine, **Vinnytsia National Technical University, Ukraine, ***Department of Electrical Engineering and Automation, University of Bielsko-Biała, Poland

Abstract: The article considers the image binarization process for its further recognition. During binarization of the image with non-uniform illumination some noise appears which makes it impossible to select features in the image. Considering the QR-code image as an example, Otsu method, Niblack method and Bernsen method were analyzed. Some errors in binarization of the image with non-uniform illumination were detected in the process of application of these methods. Therefore, the necessity of finding a better method arose. The presented method of adaptive binarization is a simple extension of Bernsen method, the main idea of which is the comparison of each pixel with arithmetical mean of pixels in its environment and simultaneous application of integral presentation of the image.

Keywords: integral image, binarization, Otsu method, Niblack method, Bernsen method, QR code

DOI: 10.14313/PAR_208/72

1. Introduction

Image binarization is the process of transformation of image color palette into two colors. Compared with the original, binary image is distorted and noise appears. As a result continuity failure of the structure of objects on the binary image appears. The object structure disintegration also appears as a result of the non-uniform image illumination, superposition of objects, etc.

Image binarization consists in subsumption of every image pixel to one of the two classes. Pixel’s class depends on the specific features of the problem solved, the pixel’s character and its environment. In the particular problem, it is necessary to select the area on the image which, according to certain characteristics, differs from the others, however, these characteristics are not always clearly shown.

2. Analysis of current state of knowledge

Fig. 1 shows QR-code. QR-code is a matrix code developed and presented by the Japanese company “Denso-Wave” in 1994. The main advantage of QR-code is easy recognition by scanning equipment (digital camera) which facilitates its application in different areas. For applying non-uniform illumination, this image was purposely processed with the help of a graphic editor using “Gradient” instrument.

Fig. 1. QR-code with non-uniform illumination
Rys. 1. Nierównomiernie oświetlony kod QR

Global binarization is one of the easiest methods of binarization. To use this method it is necessary to set the binarization threshold, to compare brightness indexes of each pixel with the fixed threshold and refer the pixel to the image object or background object.

The drawback of such method is that it focuses the current pixel characteristic only and uses the global one for the whole image threshold which makes it impossible to use it in practice (fig. 2). In addition, it is necessary to sort out all points of the image and this operation needs time.

Fig. 2. Result of global binarization
Rys. 2. Wynik binaryzacji globalnej

To set the object apart from the background it is necessary to carry binarization out of the whole array of image pixels. To achieve this, the analysis of the most frequently applied binarization methods such as Otsu method, Niblack method and Bernsen method should be considered and applied.

One of the most efficient methods of global binarization by both the quality and speed of operation is the Otsu method [1]. The method uses the histogram of allocation of brightness indices of a bit image. The histogram is built according to the values

where N is the total amount of pixels on the image; ni is the quantity of pixels by the level of brightness i.

The range of brightness is divided into two classes with the help of the threshold value of the brightness level k (k is the integer value from 0 to L). Relative frequencies w0 and w1: correspond to each class:

,

Average levels for each of the two image classes are calculated according to the formulae:

,

Further, the maximum value of the quality of the image division into two parts is evaluated.

where – interclass dispersion; – total dispersion of the whole image.

The drawback of the Otsu method is the line diffusion which is mostly caused by the non-uniform illumination of the binarization object.

In the Niblack method, the T threshold value is chosen within a particular environment (mask) of the pixel size N × N under (N = 2k+1), which is binarized according to the correlation

where m is the average brightness value I; is the mean square deviation within the mask; k is a constant which is selected in order to ensure the most qualitative binarization.

The size of the environment must be minimal but at the same time it must retain the local image details. However its size must be big enough to reduce the noise influence on the result. The value k determines which part of the object edge can be taken as an object. Under k = –0.2 quite good object detection is set if they are represented by the black color, and under k = +0.2 – if the objects are represented by the white color. In the areas with gradual changes of the grey levels this method results in artifacts and noises.

Bernson’s method [3] is based on the idea of comparing the brightness level of the modified pixel with the mean local value which is evaluated in its environment. The image pixels are processed in turn by comparing their intensity with the mean brightness value in the windows (masks) with centers in points Pl (l = 0, 1, …, 7) (fig. 3).

Fig. 3. Processing of pixel
Rys. 3. Przetwarzanie danych piksela

With symbol “1” meaning object element and “0” meaning background element in the resulting binary image, the modified pixel value (m, n) equals 1 when for all l = 0, 1, .., 7 the following equation is carried out

,

where t – parameter; – mean local brightness; f(ml, nl) – brightness in point Pl with coordinates (ml, nl).

Automatic and adaptive evaluation of the local t parameter value instead of applying the global value makes it possible to eliminate the mistakes of the thresholding modification. Parameter t is evaluated by means of such algorithm.

1. In the window (2K+1) × (K+1) with the center in modified pixels f (m, n) such indices are evaluated:

;

2. The indices are evaluated:

;

.

3. With Δfmax > Δfmin, the local window (2K+1) × (2K+1) includes more local low brightness, that is why

,

where α – constant of the range [0.3, ..., 0.8].

4. With Δfmax < Δfmin, the local window (2K+1) × (2K+1) includes more local high brightness, that is why

.

5. If Δfmax = Δfmin, the window size should be enlarged to (2K+3) × (2K+3) and it is necessary to repeat the operations, beginning with the first step. If even in this case Δfmax = Δfmin, pixel f(m, n) is referred to the background (or the desired parameter is selected as t = αP).

However, the speed of the given algorithm performance appeared to be low. Therefore, the necessity of searching more fast-acting decisions arose.

3. Main contests

The decision was made to present the processed image as an integral one to optimize the algorithm. The integral image can be used with the available function f(x, y), which is a certain interdependence between pixels and real numbers, for example, pixels’ brightness, and the necessity to estimate the sum of this function on some areas of the image.

To estimate the integral image, for each of the square image areas it is necessary to save number I(x, y) which is the sum of values f(x, y) for the pixels, located to the left and higher than pixel (x, y). For each pixel the following formula is true:

I(x, y) = f(x, y) – I(x–1, y–1) + I(x, y–1) + I(x–1, y).

With the available estimated integral image, the sum of function f(x, y) for any square area with the top left-hand corner in pixel (x1, y1) and lower right-hand corner in pixel (x2, y2) can quickly be estimated with the help of the expression:

The presented method of adaptive thresholding is a simple extension of Bernsen’s method, the main idea of which is based on the comparison of each pixel with the arithmetic mean of the pixels around it.

During the first step on the image an integral image is assessed. During the second step the mean in the square, sized s × s, is assessed by using the integral image for each pixel and then the comparison is made. If the value of the current pixel is t percent lower than the mean, it is set in the black color on the binary image, in the other case it is set in the white color.

The results of application of an integral matrix for adaptive binarization of the image with non-uniform illumination is presented in fig. 4.

Fig. 4. Results of application of an integral matrix for adaptive binarization of the image with non-uniform illumination

Rys. 4. Wynik zastosowania integralnej macierzy do adaptacyjnej binaryzacji nierównomiernie oświetlonego obrazu

4. Conclusions

By applying the integral image presentation we received a considerable reduction of time of the algorithm’s performance due to the fact that all the evaluation components are retained in the integral matrix and the estimation takes four appeals to the array and three arithmetic operations. The suggested method helps to avoid sharp contrast lines and ignores small gradient changes.

Bibliography

1. Otsu N., A threshold selection method from gray-level histograms, “IEEE Trans. Sys., Man.,” Cyber. 9/1979, 62–66.

2. Niblack W., An introduction to digital image processing, Englewood Cliffs Prentice Hall, N.J. 1986, 115–116.

3. Bernsen J., Dynamic Thresholding of Grey-Level Images, [in:] Proc. of the 8th Int. Conf. on Pattern Recognition, 1986.

4. Crow F., Summed-area tables for texture mapping. SIGGRAPH, 1984, 207–212.

5. Viola P., Jones M., Rapid object detection using a boosted cascade of simple features, [in:] IEEE Computer Vision and Pattern Recognition, 2001, 511–518.

Adaptacyjna binaryzacja przy nierównomiernym oświetleniu obrazu

Streszczenie: Artykuł prezentuje proces binaryzacji obrazu dla jego późniejszej analizy. Podczas binaryzacji nierównomiernie oświetlonego obrazu pojawia się szum, który uniemożliwia przetwarzanie obrazu. Na przykładzie kodu QR przeanalizowano metody Otsu, Niblacka i Bernsena. Błędy w binaryzacji obrazu z nierównomiernym oświetleniem wykryto w procesie stosowania tych metod. Pojawiła się w związku z tym konieczność znalezienia lepszej metody. Przedstawiona metoda adaptacyjnego obcinania (binaryzacji) jest prostym rozszerzeniem metody Bernsena, której główną ideą jest porównanie każdego piksela ze średnią arytmetyczną pikseli w jego środowisku i zastosowanie jednoczesnej integralnej prezentacji obrazu.

Słowa kluczowe: obraz integralny, binaryzacja, metoda Otsu, metoda Niblacka, metoda Bernsena, kod QR

Artykuł recenzowany, nadesłany 15.01.2014 r., przyjęty do druku 13.05.2014 r.

Roman Lishchuk

Applicant for a scientific degree of a candidate of technical sciences at the department of metrology and industrial automation of Vinnytsia National Technical University. Teacher of computer sciences at the department of economic cybernetics and information systems of Uman National University of Horticulture.

e-mail: roma_lir@mail.ru

prof. Volodymyr Kucheruk, DSc, PhD Eng.

Head of the Department of Metrology and Industrial Automatics in Vinnytsia National Technical University (Ukraine). In 1995 received PhD, and in 2006 DSc degree. Main scientific interests: energy technologies, systems engineering diagnostics and control, metrology and measuring equipment. Published more than 130 articles in scientific journals, 14 patents.

e-mail: volodymyr.kucheruk@gmail.com

prof. Igor Piotr Kurytnik, DSc, PhD Eng.

He received the MSc in 1968 in the Faculty of Electronics and Automation of the Lvov Polytechnic. In 1973 received PhD, and in 1987 DSc degree. In 2000 he worked at the Faculty of Mechanical Engineering and Computer Sciences of the University of Bielsko-Biała (Poland). At present he is a Head of Department of Electrical Engineering and Automation. His research activities focus on signal processing and measurements with particular interests in system analysis.

e-mail: ikuritnyk@ath.bielsko.pl