Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b806ed1

Browse filesBrowse files
committed
Update readme: demonstrate
1 parent f0d4650 commit b806ed1
Copy full SHA for b806ed1

File tree

Expand file treeCollapse file tree

2 files changed

+34
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+34
-5
lines changed

‎计算机图像学/labs/README.md

Copy file name to clipboardExpand all lines: 计算机图像学/labs/README.md
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,33 @@
9191
结果如下
9292
![](result/lab4-rect1.png)
9393
![](result/lab4-rect2.png)
94+
95+
96+
## 实验总结
97+
- 使用 python 的话,img 像素值类型为 `uint8`, 直接相加减可能造成 溢出, 结果在 mod 256 的域中, 所以在可能出现溢出的情况下,我在前面用 `0+` 后面的结果,这样可以将类型提升为 int 的运算而不会出现溢出。
98+
- 在实现滤波器的,更新窗口的时候,我只更新变换的列, 只需要 O(w) 的复杂度,如果更新整个窗口,需要 O(w^2) 的复杂度。
99+
- 对于 c++ 实现的 快速傅里叶变换,接口定义如下
100+
```c++
101+
typedef complex<double> comp ;
102+
103+
class dft
104+
{
105+
public:
106+
dft();
107+
~dft();
108+
bool dft1d(vector<comp>&, vector<comp> const &);
109+
bool dft2d(vector<comp>&, vector<comp> const &);
110+
bool idft1d(vector<comp>&, vector<comp> const &);
111+
bool dft::_dft2d(vector<vector<comp>>& dst, vector<vector<comp>> const &src,bool isInvert=false)
112+
bool dft::dft2d(vector<vector<comp>>& dst, vector<vector<comp>> const &src)
113+
bool dft::idft2d(vector<vector<comp>>& dst, vector<vector<comp>> const &src)
114+
};
115+
```
116+
实现的思路是:
117+
首先实现 一维的 dft, idft。 使用 快速傅里叶算法 fft,
118+
对每一层, 计算倒序数,进行计算,一个 log(n) 层,每一层计算 n次, 则一维 fft时间复杂度为 `O(nlog(n))`
119+
然后利用傅里叶变换的可分离性,计算二维 傅里叶变换2d dft
120+
可以先对每行进行 1d dft, 然后对每列进行 1d dft
121+
逆变换同理。
122+
123+

‎计算机图像学/labs/lab2.py

Copy file name to clipboardExpand all lines: 计算机图像学/labs/lab2.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from random import randint
2+
from random import random
33
from collections import Iterable
44

55
import cv2
@@ -8,11 +8,10 @@
88
from matplotlib import pyplot as plt
99

1010

11-
def noise(img):
11+
def noise(img, rate=0.03):
1212
'''3% 的椒盐噪音'''
1313
img2 = np.zeros(img.shape, img.dtype)
1414
n, m = img.shape
15-
rate = 3
1615
mn = 255
1716
mx = 0
1817
for i in range(n):
@@ -23,8 +22,8 @@ def noise(img):
2322
mx = img[i][j]
2423
for i in range(n):
2524
for j in range(m):
26-
if randint(1, 100) <= rate:
27-
if randint(0, 1) == 0:
25+
if random() <= rate:
26+
if random() <= 0.5:
2827
img2[i][j] = mn
2928
else:
3029
img2[i][j] = mx

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.