Skip to content

Commit

Permalink
⦛1: finish
Browse files Browse the repository at this point in the history
  • Loading branch information
OverflowCat committed May 29, 2024
1 parent fab9484 commit e71ff31
Show file tree
Hide file tree
Showing 29 changed files with 632 additions and 409 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.pdf
node_modules

private.typ
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
}
})))
Binary file added expt01/Images/5x5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/correct-neighbor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/k0=.16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/k0=.3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/k0=.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/直方图.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expt01/Images/规一化的直方图.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 31 additions & 20 deletions expt01/blockcode.typ
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
#import "@preview/codelst:2.0.1": sourcecode
#import "@preview/showybox:2.0.1": showybox

#let bc = (body, filename: "") => {
showybox(
breakable: true,
frame: (
title-color: black.lighten(25%),
body-color: black.lighten(98%),
border-color: black.lighten(80%),
thickness: 1pt,
radius: 3pt,
),
title: [
#set text(font: "Roboto Slab", size: .85em)
#filename
],
sourcecode(frame: none)[#body],
)
}
#import "@preview/codelst:2.0.1": sourcecode
#import "@preview/showybox:2.0.1": showybox

#let bc = (body, filename: "", type: "normal") => {
let color = {
if type == "wrong" {
red.lighten(92%)
} else if type == "right" {
green.lighten(92%)
} else {
black.lighten(98%)
}
}
showybox(
breakable: true,
frame: (
title-color: black.lighten(25%),
body-color: color,
border-color: black.lighten(80%),
thickness: 1pt,
radius: 3pt,
),
title: [
#set text(font: "Roboto Slab", size: .85em)
#filename
],
)[
#show raw: set text(font: "IBM Plex Mono", size: 1.01em)
#sourcecode(frame: none)[#body]
]
}
30 changes: 15 additions & 15 deletions expt01/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
"check": "svelte-check"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@sveltejs/adapter-static": "^3.0.1",
"@tsconfig/svelte": "^3.0.0",
"rollup": "^3.15.0",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.1.2",
"svelte": "^3.55.0",
"svelte-check": "^3.0.0",
"svelte-preprocess": "^5.0.0",
"tslib": "^2.5.0",
"typescript": "^4.9.0"
"@tsconfig/svelte": "^5.0.4",
"rollup": "^4.18.0",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-svelte": "^7.2.0",
"svelte": "^4.2.17",
"svelte-check": "^3.8.0",
"svelte-preprocess": "^5.1.4",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
},
"dependencies": {
"@martinstark/throttle-ts": "^1.3.0",
"sirv-cli": "^2.0.0",
"sirv-cli": "^2.0.2",
"svelte-echarts": "^0.1.1",
"svelte-katex": "^0.1.2"
}
Expand Down
1 change: 0 additions & 1 deletion expt01/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<title>第一次实验</title>

<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="stylesheet" href="global.css" />
<link rel="stylesheet" href="build/bundle.css" />
<link
Expand Down
Loading

0 comments on commit e71ff31

Please sign in to comment.