mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
Update filter example
This commit is contained in:
parent
b73c601641
commit
a2fee03a8a
3 changed files with 172 additions and 17 deletions
20
tikz/convolution-linear/filter.py
Normal file
20
tikz/convolution-linear/filter.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import scipy.signal
|
||||
import numpy as np
|
||||
|
||||
image = [[104, 116, 116, 112, 58, 47, 47],
|
||||
[109, 97, 114, 116, 105, 110, 45],
|
||||
[116, 104, 111, 109, 97, 46, 100],
|
||||
[101, 47, 109, 97, 115, 116, 101],
|
||||
[114, 47, 99, 97, 116, 99, 97],
|
||||
[116, 99, 97, 116, 46, 112, 104],
|
||||
[112, 63, 118, 61, 49, 46, 48]]
|
||||
|
||||
filter_kernel = [[9, -3, -1],
|
||||
[-6, 5, 3],
|
||||
[2, -8, 0]]
|
||||
filter_kernel = np.array(filter_kernel)
|
||||
res = scipy.signal.convolve2d(image, filter_kernel[::-1, ::-1],
|
||||
mode='same', boundary='fill', fillvalue=0)
|
||||
print(res)
|
Loading…
Add table
Add a link
Reference in a new issue