# A Multi-Stage Method for Logo Detection in Scanned Official Documents Based on Image Processing
## 3 Materials and Methods
### Noise Estimation and Image Enhancement  
Noise is one of the main impediments for a logotype-extraction algorithm to perform well with certain input images. In this context, noise is defined as spurious foreground pixels that can prevent true logos from being recognized, because a great part of the logotype extraction methods available in the literature is based on some properties of foreground pixels. Additionally, this high number of extraneous foreground pixels also makes the algorithm consume more processing time than necessary. On the other hand, image enhancement cannot be applied uniformly to the entire image set because noise is, by nature, a non-uniform feature of images. Our proposal for image enhancement is preceded by a split of the image set into two categories: images with a high level of random noise and images with a low level of random noise. Image-enhancement techniques for reducing image noise are only applied to images in the first set, not the second one. The first step considered in order to attempt the normalization of the image is to apply Local Normalization. Local Normalization tends to uniformize the mean and variance of an image around a local neighborhood [32]. In order to estimate the level of noise in an image, we use the method presented first by [33]. A second derivative Laplacian operator \(K\), used in contour extraction, is applied to the entire image:  
\[K= \begin{bmatrix}1&-2&1\\ -2&4&-2\\ 1&-2&1\end{bmatrix}  \tag{1}\]  
The standard deviation of the noise, \(\sigma_{n}\), is calculated as the sum of the absolute values of the intensity image convolved with this Laplacian operator. We use the coefficients proposed by [33] to compute the scaled-down value, where \(W\) and \(H\) are the image width and height, respectively:  
\[\sigma_{n}=\sqrt{\frac{\pi/2}{6*(W-2)*(H-2)}*\sum|I(x,y)*K|} \tag{2}\]  
[PERSON]'s noise-estimation algorithm is applied to the image set in order to obtain an estimation of the standard deviation of the noise for each image. We assume that images with a high level of noise can be considered outliers in a random document test set. Thus, the set of standard deviations of the noise is processed using [PERSON]'s Tau criterion [34] to detect outliers. The threshold is set to the median of the outliers, and the group of images is divided in two categories, one for \"noisy\" documents (those with a \(\sigma_{n}\) value greater than the threshold) and one for \"non-noisy\" documents (those with a \(\sigma_{n}\) value less than or equal to the threshold). Images in the \"noisy\" category are enhanced by the application of the following operations:* A bilateral filter operation, which is a non-linear, edge-preserving and noise-reducing filter, is first applied to the raw image. We used it with a spatial spread of 10 and a pixel value spread of 0.2, in order to reduce the number of noise spots that will interfere with the extended feature rectangle algorithm. Bilateral filtering was selected because of its property of smoothing images while preserving edges, which are very important for the logos to be correctly extracted. According to our experimentation, a spatial spread value of 10 better respected the logotype edges and smoothed larger features of the image. A pixel value spread of 0.2 reduced false positives by 2% with respect to larger values. * Next, an opening operation (erosion followed by dilation) is applied on the inverted image, where the background appears in black and the logo, noise, and text in white, using a disk-shaped structuring element. This operation will eliminate elements from the image whose radius is less than the radius of the structuring element. The structuring element that we used was a disk of radius 5. We chose that circular element because we consider the geometric forms of image noise to be random, so there is no strong evidence to use a particular shape over the others. Moreover, it acts equally in all spatial directions where noise can appear.