Image processing with sparse masks

We will talk about the usual spatial processing of images by applying simple masks. Sometimes this process is called two-dimensional aperture correction. As you know, the principle of such processing is as follows: a pixel of a new image is formed on the basis of the same pixel of the old image and its surroundings with different weights. A lot of masks and tricks with them have been invented over the years of digital image processing, this type of processing has its pros and cons. We will consider the effects of rarefied masks.
We will process the image section of the test television table in order to consider small details.



For example, take the usual low-pass mask [1]:

1 2 1
2 4 2
1 2 1




The effect of small masks is not isotropic, since the distance between the central element of the mask and vertical / horizontal elements is conditionally 1, and the root of 2 between the central element of the mask and diagonal elements. This leads to some geometric distortions. The obvious solution is to increase the size of the mask to ensure isotropy. When image processing on computers was just mastered, and the time spent on maintenance was critical, increasing the size of the mask led to an increase in the amount of computation, so it was customary to fill in the “extra” elements with zeros. These ideas were developed in the 80s by comrade L.P. Yaroslavsky, but in Russian he published three large books, where he did not address this issue, but I could not find his small articles or monographs.
By the way, I will quote to the heap: “any small-sized object has many points in a certain compact area (it can be a circle, rectangle, cross, rhombus, etc.). Around the central element there is a "brake zone". If the size of this zone is twice as large as the size of the object, then the object stands out without distortion [2]. "
The same low-pass filter for a mask of 5 * 5 elements will take the form:

1 0 2 0 1
0 0 0 0 0
2 0 4 0 2
0 0 0 0 0
1 0 2 0 1




However, the blurring effect is many times stronger, since farther neighbors participate in the formation of the central pixel of the new image.
The same low-pass filter for a mask of 7 * 7 elements:

0 0 0 2 0 0 0
0 1 0 0 0 1 0
0 0 0 0 0 0 0
2 0 0 4 0 0 2
0 0 0 0 0 0 0
0 1 0 0 0 1 0
0 0 0 2 0 0 0




Compare the processing results (in order - the original image, 3 * 3, 5 * 5, 7 * 7):



Next, we consider the impact of the sharpening mask, calculated by my spiritual mentor, Galchuk I.V., and published in [3].
3 * 3 sharpening filter:

-0.1 -0.1 -0.1
-0.1   2   -0.1
-0.1 -0.1 -0.1

Clarity filter 5 * 5:

-0.1 0 -0.1 0 -0.1
0 0 0 0 0
-0.1 0 2 0  -0.1
0 0 0 0 0
-0.1 0 -0.1 0 -0.1

Clarity Filter 7 * 7:

0 0 0 -0.1 0 0 0
0 -0.1 0 0 0 -0.1 0
0 0 0 0 0 0 0
-0.1 0 0 2 0 0 -0.1
0 0 0 0 0 0 0
0 -0.1 0 0 0 -0.1 0
0 0 0 -0.1 0 0 0

And, for extreme, 15 * 15 high-definition filter:

0 0 0 0 0 0 0 -0.1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -0.1 0 0 0 0 0 0 0 0 0 -0.1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-0.1 0 0 0 0 0 0 2 0 0 0 0 0 0 -0.1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -0.1 0 0 0 0 0 0 0 0 0 -0.1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 -0.1 0 0 0 0 0 0 0

And, actually, the results (in order - the original image, 3 * 3, 5 * 5, 7 * 7, 15 * 15):







Actually, the results for the 15 * 15 mask are obvious, since for large objects the effect of distorting the boundaries of objects with large differences in brightness, as well as the mixing of parts of different objects with each other and the destruction of some details of the images. As mentioned above, this is due to the fact that the brightness values ​​of the pixels of the processed image are formed from elements that are far from the center point.
Having made measurements for s / w and cch, I found out that the optimal mask size for this group of images is 7 * 7.

A remarkable feature of large, sparse masks is in enhancing the effect with increasing size.


This is the main conclusion of the article.

Of course, you can make large filled masks (there are no zero elements, everywhere there are some calculated coefficients), but here it becomes difficult to calculate these very elements, because creating a mask for some purpose is a very non-trivial and time-consuming task that gives the greatest effect, as a rule, for images obtained in similar systems under approximately the same conditions. Processing time, respectively, also increases.

Implementation Features
I used ImageJ to create images for the article - for beginners, it’s very good, and most importantly, fast. The ability to create your own masks and even complex processing algorithms is present (there seems to be a certain built-in module for writing something with macros, but I have not tried it).

In stationary research I use matlab. The code for masking is very simple:

input=imread('C:\input.jpg'); 
input=double(input);
kernel=[-0.1 -0.1 -0.1;-0.1 2 -0.1;-0.1 -0.1 -0.1]/1.2;     %Пишется маска - по сути, двумерный массив нужного размера
% kernel=[0 0 -0.1 0 0;0 -0.1 0 -0.1 0;-0.1 0 2 0 -0.1;0 -0.1 0 -0.1 0;0 0 -0.1 0 0]/1.2;     %Незаполненная маска 5*5, для примера
output = imfilter(input, kernel);
figure, imshow((output));


In tribute to Soviet science
In search of material, I came across an article in 1982 [4], which described the mask as much as 5 * 10 (like that, although canonically such things were never recommended), created for:
- removal of the constant component,
- reduction of the dynamic range of the signal from point objects (like that they cunningly fought with impulse noise).

{the heart tells you, this mask also displays the geometry on severe CRT tubes such as oscillographic equalization}

List of references
1. Gonzalez R., Woods R. Digital image processing. - M .: Technosphere, 2005 .-- 1072 p.
2. Kuryachiy M.I. Digital Signal Processing: A Study Guide. - Tomsk: Department of Technical University, TUSUR, 2012 .-- 172 p.
3. Konyukhov A.L., Galchuk I.V., Kuryachy M.I. Increasing the resolution of active-pulse television-computer systems using two-dimensional aperture correction and iterative algorithms. Kursk, materials of the conference "Recognition - 2012".
4. Mandrazh V.P. The effectiveness of two-dimensional filtering of signals when determining the coordinates of point objects. - M.: Technique of communications. Series "Technique of television." Issue 5 (No. 42), 1982

PS or what else
In the article I did not give numbers and calculated characteristics. There are many methods for determining image quality, and all of them are somewhat biased or inconvenient. In addition, the techniques vary for black and white and color images.
While processing black-and-white images of technical vision systems, I suffered for a long time with quality criteria, because the subjective look is always subjective, and a computer does not distinguish a tree from rain or grass from any kind of interference from a power source, unless the programmer has the will to do so.
In the future, at the request of the workers, I can write a review on the evaluation of signal-to-noise and other objective (calculated) quality parameters for black and white images, methods for calculating contrast (a trivial task, however, there are almost no adequate methods for low-quality images), by homomorphic filtering and where she works, well, maybe we’ll come up with something else.
Thanks for attention!

Also popular now: