测试代码显示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Buffer2D<Float3> Denoiser::Filter(const FrameInfo &frameInfo) {
int height = frameInfo.m_beauty.m_height;
int width = frameInfo.m_beauty.m_width;
Buffer2D<Float3> filteredImage = CreateBuffer2D<Float3>(width, height);
int kernelRadius = 32;
#pragma omp parallel for
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
// TODO: Joint bilateral filter
// filteredImage(x, y) = frameInfo.m_beauty(x, y);

int x_start = std::max(0, x - kernelRadius);
int x_end = std::min(width - 1, x + kernelRadius);
int y_start = std::max(0, y - kernelRadius);
int y_end = std::min(height - 1, y + kernelRadius);

auto center_postion = frameInfo.m_position(x, y);
auto center_normal = frameInfo.m_normal(x, y);
auto center_color = frameInfo.m_beauty(x, y);

Float3 final_color;
auto total_weight = .0f;

for (int m = x_start; m <= x_end; m++) {
for (int n = y_start; n <= y_end; n++) {

auto postion = frameInfo.m_position(m, n);
auto normal = frameInfo.m_normal(m, n);
auto color = frameInfo.m_beauty(m, n);

auto d_position = SqrDistance(center_postion, postion) /
(2.0f * m_sigmaCoord * m_sigmaCoord);
auto d_color = SqrDistance(center_color, color) /
(2.0f * m_sigmaColor * m_sigmaColor);
auto d_normal = SafeAcos(Dot(center_normal, normal));
d_normal *= d_normal;
d_normal / (2.0f * m_sigmaNormal * m_sigmaNormal);

float d_plane = .0f;
if (d_position > 0.f) {
d_plane = Dot(center_normal, Normalize(postion - center_postion));
}
d_plane *= d_plane;
d_plane /= (2.0f * m_sigmaPlane * m_sigmaPlane);

float weight = std::exp(-d_plane - d_position - d_color - d_normal);
total_weight += weight;
final_color += color * weight;
}
}

filteredImage(x, y) = final_color / total_weight;
}
}
return filteredImage;
}

测试公式

测试图片

hexo图片引用方式有三种,推荐使用第二种方式,并在开头加上 typora-root-url:{title}

1
2
3
4
5
{% asset_img test.png 图片引用方法一 %}

![图片引用方法二](test.png)

![图片引用方法三](./images/test.png)

如下

图片引用方法二

图片引用方法三