Skip to content

Commit 86dc505

Browse files
committed
Edit doc
1 parent ae37373 commit 86dc505

File tree

1 file changed

+64
-10
lines changed

1 file changed

+64
-10
lines changed
Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,93 @@
1-
Convolution forms a pillar in a large number of image processing applications. It is a mathematical
2-
operation which is applied in a same manner over the entire considered region in an image.
1+
Two dimensional convolution and correlation
2+
-------------------------------------------
3+
4+
5+
What is the role of convolution in image processing?
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+
9+
Convolution forms a base pillar in a large number of image processing applications. It is a
10+
mathematical operation which is applied in a same manner over the entire considered region in an image.
311
Accessing all pixels in a similar manner creates the room for optimization in this algorithm.
412
We have thus targeted our efforts towards improving the spatial access of pixel elements during
513
2D convolution and correlation.
614

7-
There are many ways of performing 2D convolution, the naive one includes irregular access of source
15+
16+
---------------------------------
17+
18+
19+
What are we doing differently?
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
22+
23+
There are many ways of performing 2D convolution, the naive ones includes irregular access of source
824
image pixels. Due to this, a large number of cache misses occur which further in turn degrade the
925
performance. We have tried to improve this access pattern and hence reduce the number of overall
1026
cache misses.
1127

12-
What are we doing differently?
1328

1429
Our strategy involves storing relevant 2D image data in a 1D buffer container. This container will
1530
then be used for accessing required patches of pixels during convolution. These patches will be
16-
accessed by a sliding window algorithm so that their dot product with 1D aligned kernel can be stored
31+
accessed by a sliding window algorithm so that their dot product with 2D kernel can be stored
1732
in destination image.
1833

19-
But how much data should be stored inside the buffer?
34+
35+
---------------------------------
36+
37+
38+
How much data should be stored inside the buffer?
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
2041

2142
We store only that much data which will be required by kernel during its one single horizontal slide.
22-
In other words, the size of buffer container will be kernel_size * img_width + boundary_offset.
23-
Here boundary_offset is the addition in buffer size which will take place due to boundary
43+
In other words, the size of buffer container will be
44+
45+
``buffer size = kernel_size * img_width + boundary_offset``
46+
47+
where ``boundary_offset = (extrapolation_required == 1) ? ((kernel_size - 1) * kernel_size) : 0``
48+
49+
Here, boundary_offset is the addition in buffer size which will take place due to boundary
2450
extrapolation for corner pixels.
2551

52+
53+
----------------------------------
54+
55+
2656
What to do after forming the buffer container?
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
2759

2860
Once our data is present inside the buffer container, a sliding window algorithm is applied for
2961
calculating the dot product between kernel and image patch contained inside sliding window.
30-
3162
Boundary extrapolation is taken care by changing elements of buffer container suitably.
3263

64+
65+
----------------------------------
66+
67+
3368
How do we take care of variable anchor point positions?
69+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70+
3471

3572
While filling the buffer container, we will take care of this by starting/ending the filling process
3673
at suitable points in source image.
37-
3874
This will automatically take care of the problem and will achieve desired effect due to the followed
3975
pattern of pixel assignment.
76+
77+
78+
-------------------------------------------------------
79+
80+
81+
What to do with spatial separable kernels?
82+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83+
84+
85+
We have written a custom algorithm which can detect whether a two dimensional kernel can be
86+
spatially separated. It does separation as well as checking for separability
87+
simultaneously. If at any step during checking, the kernel is deemed non-separable, the separation
88+
algorithm stops, otherwise horizontal and vertical separated kernels are returned.
89+
The algorithm uses the fact that a separable 2D matrix is essentially a rank1 matrix. It further
90+
uses basic linear algebra for separating the kernel.
91+
92+
93+
-------------------------------------------------------

0 commit comments

Comments
 (0)