|
18 | 18 | \vdots \\ |
19 | 19 | h_{k-1} \\ |
20 | 20 | h_{+k} |
21 | | - \end{bmatrix}\]</p><p>where the matrix is the filtering matrix of <span>$h$</span> <span>$F_h$</span> zero extended. The discrete convolution can be written analogously by reversing/reflecting <span>$x$</span> or <span>$h$</span>. A filtering matrix for more than one dimensions can be used similarly with a flattened kernel.</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="TransferFunctions.FilteringMatrix" href="#TransferFunctions.FilteringMatrix"><code>TransferFunctions.FilteringMatrix</code></a> — <span class="docstring-category">Type</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">FilteringMatrix{T,M,AA,KI,II} <: AbstractMatrix{T}</code></pre><p>A filtering matrix for the given <code>M</code>-dimensional array <code>A</code> and kernel indices <code>kern</code>. I.e. if <code>K</code> is an <code>M</code>-dimensional kernel with indices <code>kern</code> and <code>F</code> is the corresponding <code>FilteringMatrix</code>, then <code>F * K[:]</code> is the correlation of (or convolution if <code>reflect(K)[:]</code> where <code>reflect(K)</code> has the indices <code>kern</code>) of the <code>K</code> with <code>A</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/kunzaatko/TransferFunctions.jl/blob/2a888d80c3785a8c06677293d52f1afb75c90516/src/types/filtering-matrices.jl#L12-L17">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="TransferFunctions.filtering_matrix" href="#TransferFunctions.filtering_matrix"><code>TransferFunctions.filtering_matrix</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">filtering_matrix(A, K, [border])</code></pre><p>Construct a <a href="#TransferFunctions.FilteringMatrix"><code>FilteringMatrix</code></a> of <code>A</code> with the kernel <code>K</code> such that the <code>F'*K[:]</code> produces a filtered vector of <code>A</code>.</p><p>If border is specified, the array is padded with the strategy <a href="../border-arrays/#TransferFunctions.AbstractBorder"><code>border</code></a> so that the full extent of the array <code>A</code> is kept in the filtering output.</p><pre><code class="language-julia-repl hljs">julia> filtering_matrix(reshape(1:25, (5,5)), (-1:1, -1:1)); |
| 21 | + \end{bmatrix}\]</p><p>where the matrix is the filtering matrix of <span>$h$</span> <span>$F_h$</span> zero extended. The discrete convolution can be written analogously by reversing/reflecting <span>$x$</span> or <span>$h$</span>. A filtering matrix for more than one dimensions can be used similarly with a flattened kernel.</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="TransferFunctions.FilteringMatrix" href="#TransferFunctions.FilteringMatrix"><code>TransferFunctions.FilteringMatrix</code></a> — <span class="docstring-category">Type</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">FilteringMatrix{T,M,AA,KI,II} <: AbstractMatrix{T}</code></pre><p>A filtering matrix for the given <code>M</code>-dimensional array <code>A</code> and kernel indices <code>kern</code>. I.e. if <code>K</code> is an <code>M</code>-dimensional kernel with indices <code>kern</code> and <code>F</code> is the corresponding <code>FilteringMatrix</code>, then <code>F * K[:]</code> is the correlation of (or convolution if <code>reflect(K)[:]</code> where <code>reflect(K)</code> has the indices <code>kern</code>) of the <code>K</code> with <code>A</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/kunzaatko/TransferFunctions.jl/blob/ad4b580a592be654c42a31747464e4b95b8e29dc/src/types/filtering-matrices.jl#L12-L17">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="TransferFunctions.filtering_matrix" href="#TransferFunctions.filtering_matrix"><code>TransferFunctions.filtering_matrix</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">filtering_matrix(A, K, [border])</code></pre><p>Construct a <a href="#TransferFunctions.FilteringMatrix"><code>FilteringMatrix</code></a> of <code>A</code> with the kernel <code>K</code> such that the <code>F'*K[:]</code> produces a filtered vector of <code>A</code>.</p><p>If border is specified, the array is padded with the strategy <a href="../border-arrays/#TransferFunctions.AbstractBorder"><code>border</code></a> so that the full extent of the array <code>A</code> is kept in the filtering output.</p><pre><code class="language-julia-repl hljs">julia> filtering_matrix(reshape(1:25, (5,5)), (-1:1, -1:1)); |
22 | 22 |
|
23 | 23 | julia> filtering_matrix(reshape(1:25, (5,5)), OAs.OffsetArray(ones(3,3), -1:1, -1:1)); |
24 | 24 |
|
|
32 | 32 | 2 3 2 5 6 5 8 9 8 |
33 | 33 | 5 4 5 8 7 8 5 4 5 |
34 | 34 | 4 5 6 7 8 9 4 5 6 |
35 | | - 5 6 5 8 9 8 5 6 5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/kunzaatko/TransferFunctions.jl/blob/2a888d80c3785a8c06677293d52f1afb75c90516/src/types/filtering-matrices.jl#L63-L87">source</a></section></article><pre><code class="language-julia hljs">K = OffsetArray(ones(11,11) ./ 121, -5:5, -5:5) # origin (0,0) must be contained in the kernel |
| 35 | + 5 6 5 8 9 8 5 6 5</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/kunzaatko/TransferFunctions.jl/blob/ad4b580a592be654c42a31747464e4b95b8e29dc/src/types/filtering-matrices.jl#L63-L87">source</a></section></article><pre><code class="language-julia hljs">K = OffsetArray(ones(11,11) ./ 121, -5:5, -5:5) # origin (0,0) must be contained in the kernel |
36 | 36 | F_A_inner = filtering_matrix(A, K) |
37 | 37 | A_corr_K_inner_flat = F_A_inner' * K[:] |
38 | 38 | A_corr_K_inner = reshape(A_corr_K_inner_flat, F_A_inner.interior) |
|
41 | 41 | A_corr_K = reshape(A_corr_K_flat, size(A)) |
42 | 42 | @assert size(A_corr_K) == (512, 512) # whole domain of A is retained</code></pre><img src="../../../assets/figs/filtering_matrix.png" alt/><p>If we resize the image, we can see the structure of the filtering matrix for a matrix.</p><pre><code class="language-julia hljs">A_small = imresize(A, (20,20)) |
43 | 43 | K_small = filtering_matrix(A_small, (-10:10, -10:10), :fill)</code></pre><img src="../../../assets/figs/filtering_matrix_small.png" alt/><p>As can become apparent from the image, under some conditions on the border and the link between the length of <code>A</code> and <code>K</code>, the filtering matrix of a 2D matrix is a block <a href="https://en.wikipedia.org/wiki/Circulant_matrix">circulant matrix</a>.</p><p>If we take a column slice from the image and create a filtering matrix from it, we can observe the structure of a filtering matrix of a vector.</p><pre><code class="language-julia hljs">A_col = A_small[:, 13] |
44 | | -K_A_col = filtering_matrix(A_col, (-10:10,), :fill)</code></pre><img src="../../../assets/figs/filtering_matrix_column.png" alt/></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../circulant-tensors/">« Circulant Tensors</a><a class="docs-footer-nextpage" href="../reflected-arrays/">Reflected Arrays »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.14.1 on <span class="colophon-date" title="Saturday 6 September 2025 19:02">Saturday 6 September 2025</span>. Using Julia version 1.11.6.</p></section><footer class="modal-card-foot"></footer></div></div></div></body><div data-docstringscollapsed="true"></div></html> |
| 44 | +K_A_col = filtering_matrix(A_col, (-10:10,), :fill)</code></pre><img src="../../../assets/figs/filtering_matrix_column.png" alt/></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../circulant-tensors/">« Circulant Tensors</a><a class="docs-footer-nextpage" href="../reflected-arrays/">Reflected Arrays »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.14.1 on <span class="colophon-date" title="Saturday 6 September 2025 19:18">Saturday 6 September 2025</span>. Using Julia version 1.11.6.</p></section><footer class="modal-card-foot"></footer></div></div></div></body><div data-docstringscollapsed="true"></div></html> |
0 commit comments