You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The easiest way to think about this is to read it as you might read a textbook.
59
+
For each element in the output domain, we are summing a certain subsets of elements from `i-length(filter)` to `i` after multiplying it by the reversed filter (filter[i-j]`).
60
+
In this way, it is precisely the same as the mathematical notation mentioned before.
61
+
58
62
In contrast to the animation, where the filter continuously reappears on the left edge of the screen, the code we have written for this part of the chapter requires the user to specify what they expect the output array length to be.
59
63
Determining what should happen at the edges of the convolution is a somewhat hotly debated topic and differs depending on what the user actually wants, so we will be discussing this in greater detail later in this chapter.
60
64
@@ -166,11 +170,13 @@ Your browser does not support the video tag.
166
170
</div>
167
171
168
172
Similar to the case without boundary conditions, this convolution needs to "ramp up," but not "ramp down."
169
-
This is because the convolution output no longer extends past the bounds of the original signal.
173
+
This is because the convolution output no longer extends past the bounds of the original signal so the bounded convolution is a subset of the full convolution.
170
174
More than that, the convolution does not go all the way to 0 on the right side.
171
175
This means that we are actually ignoring a rather important part of the convolution!
172
176
173
177
This is 100% true; however, if the signal is large and the filter is small (as is the case with most of image processing), we do not really care that much about the bits of the convolution we missed.
178
+
In addition, there is a way to center the convolution by modifying the location where the filter starts.
179
+
For example, we could have half of the filter already existing and overlapping with the signal for the very first computed point of the convolution.
174
180
For this reason, simple bounds are used frequently when performing convolutions on an image.
175
181
176
182
In the previous code snippet, we were able to perform both a bounded and unbounded convolution.
@@ -196,7 +202,16 @@ On the other hand, the bounded call would set the output array size to simply be
As another note, the point we are computing for the convolution in the previous animation seems to be at the very front of the Gaussian to match the code; however, it is possible to compute the convolution at the center of the filter by giving the iterations through `j` an offset.
205
+
Finally, as we mentioned before, it is possible to center bounded convolutions by changing the location where we calculate the each point along the filter.
To center the convolution, it would need to count from `i-(length(filter)/2)` to `i+(length(filter)/2)` instead.
200
215
201
216
I think this is a good place to stop discussions on the simple boundary conditions.
202
217
Now let us talk a bit more in detail about the case where we want to filter to continuously reappear every loop.
@@ -329,13 +344,23 @@ This will be discussed in further detail when we talk about the Schonhage-Strass
329
344
## Example Code
330
345
331
346
For the full code, we have used the convolution to generate a few files for the full convolution, along with the periodic and simple boundary conditions discussed in this chapter.
332
-
At a test case, we have chosen to use a random distribution for the input signal and a Gaussian filter.
As a sanity check, make sure that the bounded convolution is a subset of the full convolution.
362
+
In this example, the bounded convolution is the start of the full convolution, but it is entirely possible it could be the middle or somewhere else entirely depending on how you counted within the inner, summation loop for the convolution.
363
+
339
364
<script>
340
365
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
341
366
</script>
@@ -357,6 +382,9 @@ The code examples are licensed under the MIT license (found in [LICENSE.md](http
357
382
- The video "[Sawtooth Square Convolution](../res/1d_sawtooth.mp4)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
358
383
- The video "[Full Random Convolution](../res/1d_rand_gaussian_full.mp4)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
359
384
- The video "[Simple Random Convolution](../res/1d_rand_gaussian_simple.mp4)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
385
+
- The image "[Simple Linear](../res/simple_linear.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
386
+
- The image "[Full Linear](../res/full_linear.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
387
+
- The image "[Cyclic](../res/cyclic.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
Copy file name to clipboardExpand all lines: contents/convolutions/2d/2d.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -144,8 +144,8 @@ We will definitely return to this topic in the future as new algorithms require
144
144
145
145
## Example Code
146
146
147
-
For the full code in this section, we have modified the code from the [one-dimensional convolution chapter](../1d/1d.md) to add a two-dimensional variant for an image of random white noise.
148
-
We have also added code to create the Gaussian kernel and Sobel operator.
147
+
For the full code in this section, we have modified the visualizations from the [one-dimensional convolution chapter](../1d/1d.md) to add a two-dimensional variant for an image of random white noise.
148
+
We have also added code to create the Gaussian kernel and Sobel operator and apply it to the circle, as shown in the text.
0 commit comments