Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
OverflowCat committed May 27, 2024
1 parent fab9484 commit bd7a297
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 0 deletions.
32 changes: 32 additions & 0 deletions chap10/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#set text(lang: "zh", cjk-latin-spacing: auto, font: "Noto Serif CJK SC")
#set page("iso-b5", numbering: "1", margin: (left: 1.4cm, right: 1.9cm))
#set par(leading: 1.1em)
#show table: set text(font: "Zhuque Fangsong (technical preview)")
#show figure.caption: set text(font: "Zhuque Fangsong (technical preview)")
#show "": ""
#show heading: set text(font: "Noto Sans CJK SC", size: 1.15em)

= 数字图像处理 第10章 形状表示与描述 作业

#quote(block: true)[
1. 教材P509页,第10.7题。第1题图如下。
]

// #box(image("media/image2.png", height: 2.7559055118110236in, width: 3.8149606299212597in))

假设我们已使用示于如图中的边缘模型代替了图10.10中的斜坡模型。请写出每个剂面的梯度和拉普拉斯算子。(教材P509页,第10.7题。)

// #box(image("media/image3.png", height: 1.5748031496062993in, width: 1.5669291338582678in))
2. 右图所示图像中的物体和背景,在标度范围 内具有的平均灰度分别为180和70。该图像被均值为0、标准差为10个灰度级的高斯噪声污染了。请提出一种正确分割率为90%或更高百分比的阈值处理方法。(回忆一下,高斯曲线下99.7%的面积位于均值的 区间内,其中 是标准差。)(教材P512页,第10.36题。)

3. 提出一个区域生长算法来分割习题10.36中的图像。

// #box(image("media/image7.png", height: 1.8503937007874016in, width: 1.8070866141732282in))(教材P512页,第10.38题。)

4. 使用10.4.2节中讨论过的分裂和聚合过程来分割右图所示的图像。如果 中的所有像素都有相同的灰度,则令 。给出对应于您的分割的四叉树。

#include "quadtree.typ"

(教材P512页,第10.39题。)

题目解答请写清题号,按照顺序写在如下空白处,页数不限。
55 changes: 55 additions & 0 deletions chap10/quadtree.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// curl "https://gist.githubusercontent.com/oliver-ni/701eec83f6cc0b7e9464c2e67e607faa/raw/abc4f03d36669bb506268a989f1cc2dfdb2ce5dd/tree.typ" -o tree.typ

#import "tree.typ": tree

#let im = (
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 1, 1, 1, 1, 0, 0),
(0, 0, 1, 1, 1, 1, 0, 0),
(0, 0, 1, 0, 0, 1, 0, 0),
(0, 0, 1, 0, 0, 1, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
)

#let same = (arr) => arr.all(x => x == arr.first())

#let split(im) = {
let h = int(im.len() / 2)
let w = int(im.at(0).len() / 2)
if h < 1 or w < 1 or same(im.flatten()) {
return im
}
// split into 4 quadrants
let q1 = im.slice(0, h).map(row => row.slice(0, w))
let q2 = im.slice(0, h).map(row => row.slice(w))
let q3 = im.slice(h).map(row => row.slice(0, w))
let q4 = im.slice(h).map(row => row.slice(w))
(q1, q2, q3, q4).map(split)
}


#let showtree(i, subtree) = {
let children = subtree.map(x => tree(i + 1, x))

tree($R_#i$, children)
}

#showtree(1, split(im))

// split(im)

#tree(
"A",
tree(
"B",
tree("D"),
tree("E")
),
tree(
"C",
tree("F"),
tree("G")
)
)
29 changes: 29 additions & 0 deletions chap10/tree.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#let tree(label, ..children) = style(styles => block(align(center, {
let label = rect(align(center + horizon)[#label])
let label_dim = measure(label, styles)

let children_widths = children.pos().map(x => measure(x, styles).width)
let all_children = stack(dir: ltr, spacing: 1em, ..children.pos())
let all_children_dim = measure(all_children, styles)

// If there are no children, stacking will result in excess space

if children.pos().len() == 0 {
label
} else {
stack(spacing: 1em, label, all_children)
}

// Draw lines

let label_bottom = (all_children_dim.width / 2, label_dim.height)
let x = 0em
let y = label_dim.height + 1em

for (i, child) in children.pos().enumerate() {
let child_dim = measure(child, styles)
let child_top = (x + child_dim.width / 2, y)
place(top + left, line(start: label_bottom, end: child_top))
x += child_dim.width + 1em
}
})))
111 changes: 111 additions & 0 deletions expt01/public/index copy.html

Large diffs are not rendered by default.

0 comments on commit bd7a297

Please sign in to comment.