Skip to content

Commit bb87921

Browse files
authored
Change folder structure of convolutions (#861)
This puts every chapters' code into its own directory, which is useful for automatic validation.
1 parent cc457b9 commit bb87921

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

contents/convolutions/1d/1d.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ With this in mind, we can almost directly transcribe the discrete equation into
5353

5454
{% method %}
5555
{% sample lang="jl" %}
56-
[import:27-46, lang:"julia"](../code/julia/1d_convolution.jl)
56+
[import:27-46, lang:"julia"](code/julia/1d_convolution.jl)
5757
{% endmethod %}
5858

5959
The easiest way to reason about this code is to read it as you might read a textbook.
@@ -184,30 +184,30 @@ Here it is again for clarity:
184184

185185
{% method %}
186186
{% sample lang="jl" %}
187-
[import:27-46, lang:"julia"](../code/julia/1d_convolution.jl)
187+
[import:27-46, lang:"julia"](code/julia/1d_convolution.jl)
188188
{% endmethod %}
189189

190190
Here, the main difference between the bounded and unbounded versions is that the output array size is smaller in the bounded case.
191191
For an unbounded convolution, the function would be called with a the output array size specified to be the size of both signals put together:
192192

193193
{% method %}
194194
{% sample lang="jl" %}
195-
[import:58-59, lang:"julia"](../code/julia/1d_convolution.jl)
195+
[import:58-59, lang:"julia"](code/julia/1d_convolution.jl)
196196
{% endmethod %}
197197

198198
On the other hand, the bounded call would set the output array size to simply be the length of the signal
199199

200200
{% method %}
201201
{% sample lang="jl" %}
202-
[import:61-62, lang:"julia"](../code/julia/1d_convolution.jl)
202+
[import:61-62, lang:"julia"](code/julia/1d_convolution.jl)
203203
{% endmethod %}
204204

205205
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.
206206
This can be done by modifying the following line:
207207

208208
{% method %}
209209
{% sample lang="jl" %}
210-
[import:35-35, lang:"julia"](../code/julia/1d_convolution.jl)
210+
[import:35-35, lang:"julia"](code/julia/1d_convolution.jl)
211211
{% endmethod %}
212212

213213
Here, `j` counts from `i-length(filter)` to `i`.
@@ -239,7 +239,7 @@ In code, this typically amounts to using some form of modulus operation, as show
239239

240240
{% method %}
241241
{% sample lang="jl" %}
242-
[import:4-25, lang:"julia"](../code/julia/1d_convolution.jl)
242+
[import:4-25, lang:"julia"](code/julia/1d_convolution.jl)
243243
{% endmethod %}
244244

245245
This is essentially the same as before, except for the modulus operations, which allow us to work on a periodic domain.
@@ -254,7 +254,7 @@ For the code associated with this chapter, we have used the convolution to gener
254254

255255
{% method %}
256256
{% sample lang="jl" %}
257-
[import, lang:"julia"](../code/julia/1d_convolution.jl)
257+
[import, lang:"julia"](code/julia/1d_convolution.jl)
258258
{% endmethod %}
259259

260260
At a test case, we have chosen to use two sawtooth functions, which should produce the following images:

contents/convolutions/2d/2d.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ In code, a two-dimensional convolution might look like this:
2020

2121
{% method %}
2222
{% sample lang="jl" %}
23-
[import:4-28, lang:"julia"](../code/julia/2d_convolution.jl)
23+
[import:4-28, lang:"julia"](code/julia/2d_convolution.jl)
2424
{% sample lang="py" %}
25-
[import:5-19, lang:"python"](../code/python/2d_convolution.py)
25+
[import:5-19, lang:"python"](code/python/2d_convolution.py)
2626
{% endmethod %}
2727

2828
This is very similar to what we have shown in previous sections; however, it essentially requires four iterable dimensions because we need to iterate through each axis of the output domain *and* the filter.
@@ -49,9 +49,9 @@ At this stage, it is important to write some code, so we will generate a simple
4949

5050
{% method %}
5151
{% sample lang="jl" %}
52-
[import:30-47, lang:"julia"](../code/julia/2d_convolution.jl)
52+
[import:30-47, lang:"julia"](code/julia/2d_convolution.jl)
5353
{% sample lang="py" %}
54-
[import:21-33, lang:"python"](../code/python/2d_convolution.py)
54+
[import:21-33, lang:"python"](code/python/2d_convolution.py)
5555
{% endmethod %}
5656

5757
Though it is entirely possible to create a Gaussian kernel whose standard deviation is independent on the kernel size, we have decided to enforce a relation between the two in this chapter.
@@ -138,9 +138,9 @@ In code, the Sobel operator involves first finding the operators in $$x$$ and $$
138138

139139
{% method %}
140140
{% sample lang="jl" %}
141-
[import:49-63, lang:"julia"](../code/julia/2d_convolution.jl)
141+
[import:49-63, lang:"julia"](code/julia/2d_convolution.jl)
142142
{% sample lang="py" %}
143-
[import:36-52, lang:"python"](../code/python/2d_convolution.py)
143+
[import:36-52, lang:"python"](code/python/2d_convolution.py)
144144
{% endmethod %}
145145

146146
With that, I believe we are at a good place to stop discussions on two-dimensional convolutions.
@@ -153,9 +153,9 @@ We have also added code to create the Gaussian kernel and Sobel operator and app
153153

154154
{% method %}
155155
{% sample lang="jl" %}
156-
[import, lang:"julia"](../code/julia/2d_convolution.jl)
156+
[import, lang:"julia"](code/julia/2d_convolution.jl)
157157
{% sample lang="py" %}
158-
[import, lang:"python"](../code/python/2d_convolution.py)
158+
[import, lang:"python"](code/python/2d_convolution.py)
159159
{% endmethod %}
160160

161161
<script>

contents/convolutions/convolutional_theorem/convolutional_theorem.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This means that the convolution theorem is fundamental to creating fast convolut
3131

3232
{% method %}
3333
{% sample lang="jl" %}
34-
[import:5-8, lang:"julia"](../code/julia/convolutional_theorem.jl)
34+
[import:5-8, lang:"julia"](code/julia/convolutional_theorem.jl)
3535
{% endmethod %}
3636

3737
This method also has the added advantage that it will *always output an array of the size of your signal*; however, if your signals are not of equal size, we need to pad the smaller signal with zeros.
@@ -41,7 +41,7 @@ Also note that the Fourier Transform is a periodic or cyclic operation, so there
4141

4242
{% method %}
4343
{% sample lang="jl" %}
44-
[import, lang:"julia"](../code/julia/convolutional_theorem.jl)
44+
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
4545
{% endmethod %}
4646

4747
<script>

0 commit comments

Comments
 (0)