Skip to content

Change folder structure of convolutions #861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions contents/convolutions/1d/1d.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ With this in mind, we can almost directly transcribe the discrete equation into

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

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

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

Here, the main difference between the bounded and unbounded versions is that the output array size is smaller in the bounded case.
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:

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

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

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

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

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

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

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

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

{% method %}
{% sample lang="jl" %}
[import, lang:"julia"](../code/julia/1d_convolution.jl)
[import, lang:"julia"](code/julia/1d_convolution.jl)
{% endmethod %}

At a test case, we have chosen to use two sawtooth functions, which should produce the following images:
Expand Down
16 changes: 8 additions & 8 deletions contents/convolutions/2d/2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ In code, a two-dimensional convolution might look like this:

{% method %}
{% sample lang="jl" %}
[import:4-28, lang:"julia"](../code/julia/2d_convolution.jl)
[import:4-28, lang:"julia"](code/julia/2d_convolution.jl)
{% sample lang="py" %}
[import:5-19, lang:"python"](../code/python/2d_convolution.py)
[import:5-19, lang:"python"](code/python/2d_convolution.py)
{% endmethod %}

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.
Expand All @@ -49,9 +49,9 @@ At this stage, it is important to write some code, so we will generate a simple

{% method %}
{% sample lang="jl" %}
[import:30-47, lang:"julia"](../code/julia/2d_convolution.jl)
[import:30-47, lang:"julia"](code/julia/2d_convolution.jl)
{% sample lang="py" %}
[import:21-33, lang:"python"](../code/python/2d_convolution.py)
[import:21-33, lang:"python"](code/python/2d_convolution.py)
{% endmethod %}

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.
Expand Down Expand Up @@ -138,9 +138,9 @@ In code, the Sobel operator involves first finding the operators in $$x$$ and $$

{% method %}
{% sample lang="jl" %}
[import:49-63, lang:"julia"](../code/julia/2d_convolution.jl)
[import:49-63, lang:"julia"](code/julia/2d_convolution.jl)
{% sample lang="py" %}
[import:36-52, lang:"python"](../code/python/2d_convolution.py)
[import:36-52, lang:"python"](code/python/2d_convolution.py)
{% endmethod %}

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

{% method %}
{% sample lang="jl" %}
[import, lang:"julia"](../code/julia/2d_convolution.jl)
[import, lang:"julia"](code/julia/2d_convolution.jl)
{% sample lang="py" %}
[import, lang:"python"](../code/python/2d_convolution.py)
[import, lang:"python"](code/python/2d_convolution.py)
{% endmethod %}

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This means that the convolution theorem is fundamental to creating fast convolut

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

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.
Expand All @@ -41,7 +41,7 @@ Also note that the Fourier Transform is a periodic or cyclic operation, so there

{% method %}
{% sample lang="jl" %}
[import, lang:"julia"](../code/julia/convolutional_theorem.jl)
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
{% endmethod %}

<script>
Expand Down