Abstract
In this paper, the problem of image block similarity measuring in noisy environment is considered. In different practical applications often is necessary to find groups of similar image blocks within an ample search area. In such situation, the full search algorithm is very slow; apart, its accuracy is low due to the presence of noise. New algorithms for similar image block matching in noisy environment are presented. The algorithms are based on the dissimilarity measure calculated as the distance between image patches in the discrete cosine transform domain. The proposed algorithms perform the hierarchical search for the similar image blocks and hereby have a reduced complexity in comparison to the full search algorithm. Adjusting the radius of the distance calculation for spectral coefficient matching, the characteristics of the block matching algorithm can easily be adjusted to obtain a better accuracy of the matched block group. A higher accuracy is obtained using the local adaptation of the radius for the distance calculation outperforming the existing algorithms used to find groups of similar blocks in different applications, such as image noise filtering and image clustering. The performance of the different block matching algorithms were evaluated on the base of the proposed accuracy measure that uses as a reference the list of patches obtained with the full search algorithm in the absence of noise.
Keywords
Introduction
The problem of image template location in a considered image is very common in different applications such as video compression, image clustering, vector quantization, nonlocal noise reduction [1–5]. To match templates, various measures of similarity/dissimilarity can be applied [1]. Among them, the most simple and popular measure is square L2 norm or square Euclidean distance usually calculated as the sum of squared differences of corresponding pixels in two templates or image blocks. Despite its simplicity, the calculation of the square distances can cause significant computational load to find the best block matching in video compression [3] or modern noise suppression algorithm such as BM3D [5] and LPG-PCA [6], image inpainting [7]. The direct computation of all the matching requires O (KMNr2) operations [8], where M × N is the number of image pixels, r2 denotes the patch size, K is the maximum offset.
In [3], an ample review of different existing block matching algorithms of reduced complexity are described: techniques based on a reduced set of candidates, techniques based on a reduced-complexity block distortion measure, techniques based on a subsampled block-motion field, hierarchical search techniques, fast full-search techniques. Among them, it was found that the fastest technique is the hierarchical search that usually performs on a mean pyramid calculated applying low-pass filtering and subsampling to the considered image(s) [3].
For many years, the patch matching based on the cross-correlation in Fourier transform domain [9, 12] was a state-of-the-art method [10]. This method requires approximately O (KMN log 2 (M)) operations [11] that is faster than the exhaustive search when r2 > 30 log 2 (M) [10]. However, when K is much larger than r, the direct method is faster than Fourier transform based method; the transform method is more efficient when r approaches K [11].
A fast method for image block dissimilarity computation of the sum of squared differences of pixel values within the patches is presented in [8]. It based on the integral image calculation [10] that permits to reduce the total time complexity independently from the patch size to O ((M - r) (N - r)) [8] operations at the expense of some flexibility and errors caused by limited numerical precision [8]. Besides, block matching using integral images has limited performance gain with respect to exhaustive block matching for small patch sizes [8].
From other hand, the matched blocks using the aforementioned methods become less similar when the image(s) are contaminated by noise. Obviously, the image data can be previously filtered to provide better matching but it can be inconvenient in some practical situations. For this reason, a similarity/dissimilarity measure robust to noise presence is required to find similar patches in noisy images.
In this paper, the feature vectors are formed as the patches in the discrete cosine transform domain that describe well the considered image blocks to perform fast block matching with the accuracy near to the full search technique or higher in the case of noise presence.
Patch dissimilarity measures
There exist a number of similarity/dissimilarity measures that can be applied to image processing. Here, only the simplest and fastest to calculate measures are described.
The standard dissimilarity measure between two image blocks of size r
x
, r
y
, sum of squared distances (SSD), can be formulated as
where u (x, y) is the image pixel at the coordinate x, y, o
x
, o
y
∈ K denote the shift between the compared image blocks in the horizontal and vertical directions, respectively. The best matching is the minimum of the SSD found within the search window:
where the search area K = K
x
· K
y
is limited by offsets K
x
, K
y
in the horizontal and vertical directions, respectively. Often, the task is to find the set of the l best matched patches; this task is common in patch based filtering algorithms [5, 6]. Usually, it requires to calculate SSD (1) between all the blocks within the offset K, sort them and store the shortest block distances and their coordinates in the list
The number of operations to find
where d s denotes SSD calculated on the smoothed image u s .
The image smoothing can be performed in spatial domain applying a low pass filter or in a transform domain. Such filtering apart from the complexity reduction introduces some robustness to the noise present in the contaminated images that improves the accuracy of block matching when searching for the minimum (2) or forming the list of patches
In this paper, for the low pass filtering is performed in discrete cosine transform (DCT) and consists in zeroing high frequency coefficients. Or similarly, one can take the first DCT coefficients that represent signal low frequencies and these coefficients can be efficiently used to calculate the dissimilarities between the image patches. Recall that 2D DCT for small r can be performed efficiently by matrix multiplications:
where
The distances between the different patches in DCT domain may be calculated as
where u
T
(x, y, ω
x
, ω
y
) is the ω
x
, ω
y
-th spectral coefficient of the image DCT patch
A simple modification of the distance Equation (6) is
The distance Equation (7) may be useful, for example, to find the image clusters of homogeneous regions and edges, and is expected to be useful for deriving the spectral/statistical properties of the considered image blocks to improve the noise suppression of the modern noise suppression algorithms, such as BM3D or LG-PCA [5, 6].
In this paper, the distance Equation (6) is used to form the list
As shown below in Section 4, the properties of the measure Equation (6) are sometimes insufficient to determine with more precision the list
To this end, the hierarchical approach may be useful: firstly, the algorithm searches for a rough approximation of the final list; secondly, a more exact search is performed over the provisional list found at the previous step.
Simple hierarchical search algorithm
In this paper, the following simple hierarchical algorithm that consists of two stages is used for comparative purposes.
At the first stage, the patches of the reduced size by subsampling of the image smoothed by an antialiasing filter are formed; their differences Equation (1) with the reference patch in the list are calculated:
where u
s
(x, y) denotes the x, y-th pixel of the smoothed image. The list of the sorted in ascending order differences is formed:
where
At the second stage, the patches of the original image patches in the list
and the first l
NN
patches nearest to the considered image block with the coordinates (x, y) are included in the final list
The idea of the hierarchical search can easily be implemented in DCT domain. The simple (but not the best) algorithm of hierarchical search in DCT domain (DCTBM algorithm) can be formulated as follows.
Firstly, the provisional extended list
and the list of the differences sorted in ascending order is formed:
As in the case of the simple hierarchical search, the coordinates (o
x
, o
y
) of first 8l
NN
patches having the minimal differences with the reference patch form the provisional extended list
At the second stage, the patches in the list
to form the ordered list of patches
By experiments, it was found that the performance of the DCTBM algorithm is not always satisfactory and need to be modified according to different signal/noise ratios. The following modified algorithm ADCTBM of the DCT-based dissimilarity measure performs better on the noisy images with different noise variance.
As it is shown below in Section 4, the accuracy of a DCT-based block matching algorithm depends on the signal/nose ratio and radius r ω in Equation (6). When the noise variance is high, the DCT-based block matching algorithm DCTBM, Equations (11–13), performs satisfactory because it consider only the low frequencies where the signal energy is high and does not take into account high spatial components where noise energy is greater than the signal energy. And when the noise variance is low, the signal energy in higher frequencies is greater than of the noise, and more calculations must be used to form the lists of patches at both stages. These relations between signal and noise components also depend on image type: for plain regions, lower values of r ω are better; contrary, for textural images the radius r ω has to be shorter.
Taking into account these observations, a locally adaptive block matching algorithm ADCTBM is proposed. The algorithm take into account the local data activity and compare it to the noise variance; if the data activity is greater than a threshold, the radius r ω is longer, else a shorter radius is taken. This way, the base DCTBM algorithm is modified as:
Firstly, the local data activity is estimated and compared to the noise variance to make the decision about the length of the radius r
ω
:
Secondly, the length of the radiuses rω1, rω2 for the first and the second stage of the base algorithm DCTBM, Equations13) are selected:
Additionally, the number of patches in the list
To improve the performance of the described DCT-based block matching algorithms, the use of weighted DCT coefficients is proposed. According to Wiener filtering theory [9, 12], the frequency response of the optimal filter in the transform domain is
where P
s
(ω) is the power spectral density of a noise-free data and P
n
(ω) is the power spectral density of noise. Assuming noise in white Gaussian, P
n
(ω) is equal to the noise variance, σ2. In practice, noise variance is known or can be easily estimated; in such conditions, the DCT coefficients can be weighted as
Of course, Equation (17) is not the best way to remove noise from patches because the noisy data [u T (ω x , ω y )] 2 are used as a signal spectral density estimate instead of exact P s (ω) values. However, the weighting (16) is considered to be sufficient to improve the results of block matching on noisy images.
The weighted according to Equation (17) DCT coefficients u W (ω x , ω y ) can substitute the non-weighted coefficients u T (ω x , ω y ) in block matching algorithms DCTBM and ADCTBM, Equations (11–15); such improved algorithms are named as WDCTBM and WADCTBM.
In this Section the results of quantitative evaluation of the performance of different block matching algorithms described in Section 3 are presented.
To evaluate the results of dissimilarity calculation applied to block matching problem, the measure of similarity between two lists of the matched blocks
Additional measure of similarity/dissimilarity between two lists may be the distance between the patches with the same coordinates; and if the image restoration algorithm takes into account these distances for weighting, it affects the filtering results. Here, it is assumed that the non-local filtering algorithm does not use any weighting depending on the distances between the patches and does not take into account the values of these distances because the weighting may vary depending on the filtering algorithm.
Taking into account these observations, a measure for direct evaluation of the performance of different block matching algorithms is proposed. The algorithm ability to find similar block can be expressed in terms of a mean number of the coincided coordinates in the lists of the matched blocks
where
Figures 1 and 2 illustrate the typical behavior of the accuracy of the block matching based on the distance Equation (6) in dependence of the radius r ω and the noise variance. These results were obtained for the test image “Lenna” and “Baboon” for image block size r2 = 8 ×8. As one can observe from these figures, the accuracy is decreased when the variance is growing for all radius lengths. However, the accuracy can be increased with the shorter r ω for high noise levels. This increasing depends on the image data: for an image with plain areas, such as “Lenna” image, the results can be improved selecting r ω = 3 for the noise variance σ2 > 100. Contrary, for textural images, such as “Baboon”, the improvement is observed only for r ω = 5, r ω = 6. And only when the variance is greater 225, the results can be improved selecting r ω = 4. This is due to the fact that the textural images contain high spatial frequencies, and suppressing these features with short r ω results in a reduced accuracy of the block matching. In other words, the choice of the radius r ω length depends on the local image block signal/noise ratio at the spatial frequencies that might be suppressed with a short r ω .

Behavior of the accuracy Equation (18) of the simple block matching based on the distance Equation (6) depending on the radius r ω and the noise variance for the test image “Lenna”, image block size is 8×8, search area K = 21×21.

Behavior of the accuracy Equation (18) of the simple block matching based on the distance Equation (6) depending on the radius r ω and the noise variance for the test image “Baboon”, image block size is 8×8, search area K = 21×21.
A special case is when the radius r ω = r and the size of the image block is equal to the size of DCT patch. In such conditions, the accuracy of the block matching based on the distance Equation (6) calculation is equal to the accuracy obtained with the Euclidean distance Equation (1), i.e., the performance is identical to the performance of the full search block matching, μ = 1.
To evaluate quantitatively and compare the accuracy of the of the proposed known image block matching algorithm to the known algorithms in noisy environment, their performance according to criterion Equation (18) was tested on the standard 512 × 512 test images “Lena”, “F-16”, “Peppers”, “Aerial”, “Baboon” and “Bridge” in the absence and presence of white additive Gaussian noise of different variance. The simulation results were obtained for image block size r2 = 8 ×8 and the search area K = 21 × 21. As a reference, the lists of the matched blocks calculated by the full search algorithm on the noise free test images The proposed algorithms DCTMB, WDCTBM, ADCTBMandWADCTBM outperform the known algorithms (full search, integral image, hierarchical search) in the presence of noise in data; The best results are obtained with the locally adaptive algorithms ADCTBMandWADCTBM, only in the case of the test image “Bridge” the non-adaptive proposed algorithm WDCTBM that uses weighting of the spectral coefficients according to the Equation (17) produced a slightly better results than the adaptive algorithms; The spectral coefficient weighting only slightly improves the accuracy of the block matching and not always; The worst result in all cases were obtained with the hierarchical algorithm, Equation (10); When the noise is absent, the full search algorithm is the best, but very slow; in such conditions, the proposed algorithms has a reduced complexity because they perform a hierarchical search but the best accuracy comparing to the integral image algorithm [10].
Accuracy, Equation (18), of the proposed algorithms DCTBM, WDCTBM, ADCTBM and WADCTBM block matching algorithms for different noise levels and images, when compared with known methods. The best results are marked as bold
New algorithms for similar image block matching in noisy environment have presented. The algorithms are based on the dissimilarity measure calculated as the distance between image patches in the discrete cosine transform domain. The algorithms perform the hierarchical search for the similar image blocks and hereby have a reduced complexity in comparison to the full search algorithm. Adjusting the radius of the distance calculation for spectral coefficient matching, the characteristics of the block matching algorithm can easily be adjusted to obtain a better accuracy of the matched block group. A higher accuracy is obtained using the local adaptation of the radius for the distance calculation outperforming the existing algorithms used to find groups of similar blocks. The performance of the different block matching algorithms were evaluated on the base of the proposed accuracy measure that uses as a reference the list of patches obtained with the full search algorithm in the absence of noise. The proposed locally adaptive algorithms ADCTBM, WADCTBM may be useful in different applications, such as image noise filtering, clustering and vector quantization. The evaluation of the proposed algorithm performance in such applications may be the subject of a future work.
Footnotes
Acknowledgments
This work has been partly supported supported by Instituto Politécnico Nacional as a part of the research project SIP 20180878.
