Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
d9fd7fd
add features folder
nosalt99 Jun 8, 2018
ab8af20
readme.md
nosalt99 Jun 8, 2018
d2d1f1b
add test.sh
zn-cn Jun 8, 2018
1fbf606
add test.sh
zn-cn Jun 8, 2018
07347cf
Merge branch 'agroup'
zn-cn Jun 8, 2018
ac839ba
Create README
TalentedMUSE Jun 10, 2018
6de785d
Update and rename README to README.md
U201617006 Jun 10, 2018
9e87fad
Merge pull request #1 from U201617006/master
TalentedMUSE Jun 10, 2018
f9326d6
Update README.md
U201617006 Jun 10, 2018
1c6b468
Merge pull request #2 from U201617006/master
TalentedMUSE Jun 10, 2018
ec1b325
Update and rename README.md to Algorithm.md
TalentedMUSE Jun 10, 2018
10d36db
Update Algorithm.md
TalentedMUSE Jun 10, 2018
cbe72d1
Add files via upload
TalentedMUSE Jun 10, 2018
8d24200
Delete 20170811211927385.png
TalentedMUSE Jun 10, 2018
31e6d08
Add files via upload
TalentedMUSE Jun 10, 2018
94d48c9
Add files via upload
TalentedMUSE Jun 10, 2018
2c19589
Add files via upload
TalentedMUSE Jun 10, 2018
0f92053
Update DOO-SABIN.py
dawn-Neight Jun 10, 2018
8330cf6
Merge pull request #3 from dawn-Neight/master
TalentedMUSE Jun 10, 2018
63cf88d
spatial denoising
Jun 11, 2018
e4182b8
add __init__.py
zn-cn Jun 11, 2018
88d165a
Update DOO-SABIN.py
TalentedMUSE Jun 12, 2018
f333e6c
Create loopReference.md
TalentedMUSE Jun 12, 2018
c153923
去噪测试
Jun 14, 2018
9d5860f
readme更新
Jun 14, 2018
e2bdea3
修改user信息
nansanhao Jun 15, 2018
12f053c
修改user信息
nansanhao Jun 15, 2018
8c87af8
修改user信息之后
nansanhao Jun 15, 2018
b10c53a
Merge pull request #4 from nansanhao/bgroup
wenjiewang98228 Jun 15, 2018
d37110f
Update README.md
wenjiewang98228 Jun 15, 2018
a497b83
Update README.md
wenjiewang98228 Jun 15, 2018
84f7dad
Merge pull request #6 from nansanhao/bgroup
zn-cn Jun 15, 2018
0ce3fd5
添加统计代码量说明
zn-cn Jun 15, 2018
b674bb1
Delete loopReference.md
TalentedMUSE Jun 16, 2018
43d078e
Update DOO-SABIN.py
TalentedMUSE Jun 16, 2018
140c80b
Update DOO-SABIN.py
TalentedMUSE Jun 16, 2018
0d71175
Add files via upload
TalentedMUSE Jun 16, 2018
c5a7b5f
Update test.py
TalentedMUSE Jun 16, 2018
0f8462e
Create README.md
TalentedMUSE Jun 16, 2018
12a2437
删除多余未运行代码
nansanhao Jun 16, 2018
8b2c4f1
解决冲突,完善readme文件
nansanhao Jun 16, 2018
dfd4883
完善readme文件
nansanhao Jun 16, 2018
bcf3790
修改代码使之覆盖率为100%
nansanhao Jun 16, 2018
72f6620
delete teapot spatialDenoising
zn-cn Jun 17, 2018
e6dce6d
Merge pull request #1 from wenjiewang98228/bgroup
RenShuhuai-Andy Jun 17, 2018
f68a9df
注释掉main函数
nansanhao Jun 17, 2018
daed69a
wqq add readme and change code
wqqljt Jun 17, 2018
af14d14
Update README.md
zn-cn Jun 17, 2018
49b4c4d
add bumping_map.py in features/bumping-map
Llhai Jun 17, 2018
028856b
add normal.png in features/bumping-map
Llhai Jun 17, 2018
ae9d74c
Update README.md
Llhai Jun 17, 2018
8a000f8
Update README.md
Llhai Jun 17, 2018
a00a074
Merge pull request #28 from nansanhao/bgroup
zn-cn Jun 17, 2018
964782b
添加
Jun 17, 2018
3bac15e
Merge pull request #1 from TenWoods/master
Llhai Jun 17, 2018
67ea5a7
Merge pull request #26 from Llhai/master
zn-cn Jun 17, 2018
6c3b5fe
修改1.0
Jun 17, 2018
d1d1136
修改2.0
Jun 17, 2018
10b33fd
修改3.0
Jun 17, 2018
2b0b93e
Merge pull request #2 from TenWoods/master
Llhai Jun 17, 2018
df9be48
finish2.0
Jun 17, 2018
e4aeded
Merge pull request #3 from TenWoods/master
Llhai Jun 17, 2018
a6cf4cf
Update README.md
alderpaw Jun 17, 2018
22d673c
Merge pull request #4 from alderpaw/master
Llhai Jun 17, 2018
3e3a6ae
just a try,the codes are not completed
Jun 17, 2018
f2865ab
change some bugs
Jun 17, 2018
595ce50
test is ok, cover 100%
Jun 17, 2018
0beed25
test is ok, cover 100%
Jun 17, 2018
d40ffd0
teapot
nosalt99 Jun 17, 2018
c8fb7b9
Update gamma_correction.py
707554736 Jun 17, 2018
0cd0f2f
Update gamma_correction.py
707554736 Jun 17, 2018
1c77633
Update gamma_correction.py
707554736 Jun 17, 2018
810c3ba
Update gamma_correction.py
707554736 Jun 17, 2018
489325f
Update gamma_correction.py
707554736 Jun 17, 2018
72b3ff0
bgroup merge teapot
nosalt99 Jun 17, 2018
bc53c43
Rename DOO-SABIN.py to DOO_SABIN.py
TalentedMUSE Jun 18, 2018
c6c071e
Merge pull request #30 from Llhai/master
zn-cn Jun 18, 2018
b3939bd
Update test.py
TalentedMUSE Jun 18, 2018
28759cd
Merge pull request #2 from wenjiewang98228/bgroup
RenShuhuai-Andy Jun 18, 2018
718cdce
Update gamma_correction.py
MagiCatz Jun 18, 2018
59a7a13
Update test.py
TalentedMUSE Jun 18, 2018
ab56cd0
第8组-motionon_blur-bgroup
RenShuhuai-Andy Jun 18, 2018
207c64d
Update gamma_correction.py
Phantomhive123 Jun 18, 2018
5cc1b4b
check the codes
Phantomhive123 Jun 18, 2018
f889912
change some words
crystal313 Jun 18, 2018
47045aa
add some
crystal313 Jun 18, 2018
898a3fc
again
crystal313 Jun 18, 2018
9e2475f
注释了runTest
RenShuhuai-Andy Jun 18, 2018
cf49960
Merge pull request #35 from RenShuhuai-Andy/bgroup
zn-cn Jun 18, 2018
d1cacad
Rename test.py to test_doosabin.py
TalentedMUSE Jun 18, 2018
9994dc5
Merge pull request #3 from MagiCatz/bgroup
Jun 18, 2018
d7c3bf8
Merge branch 'bgroup' into bgroup
Jun 18, 2018
afe7b1f
Merge pull request #2 from wqqljt/bgroup
Jun 18, 2018
bb17175
Merge branch 'bgroup' into bgroup
Jun 18, 2018
3e86ff2
Merge pull request #4 from Phantomhive123/bgroup
Jun 18, 2018
cc004a9
Merge branch 'bgroup' into bgroup
Jun 18, 2018
6c281ac
Merge pull request #5 from crystal313/bgroup
Jun 18, 2018
0a490c0
Merge branch 'bgroup' into patch-1
Jun 18, 2018
6321fb4
Merge pull request #6 from 707554736/patch-1
Jun 18, 2018
97bfbc3
test
akatheater Jun 18, 2018
4218a2b
Merge branch 'bgroup' into bgroup
Jun 18, 2018
8e34f77
Merge pull request #7 from akatheater/bgroup
Jun 18, 2018
d2ea923
NO.7 group_gamma_correction_Bgroup finish!
Jun 18, 2018
5af4919
Rename README.md to README-DOSABIN.md
TalentedMUSE Jun 19, 2018
b48b108
Add files via upload
TalentedMUSE Jun 19, 2018
7a51f4f
Add files via upload
TalentedMUSE Jun 19, 2018
7ad4a8c
Create README-LOOP.md
TalentedMUSE Jun 19, 2018
4610ae6
Update DOO_SABIN.py
TalentedMUSE Jun 19, 2018
31bfd61
Merge branch 'bgroup' of https://github.com/wenjiewang98228/relaxrend…
Jun 19, 2018
a788816
Merge branch 'wenjiewang98228-bgroup' into bgroup
Jun 19, 2018
8d3467b
push again
Jun 19, 2018
c020424
Merge pull request #55 from LWJ312/bgroup
zn-cn Jun 19, 2018
6bfd29c
Merge pull request #51 from TalentedMUSE/master
zn-cn Jun 19, 2018
1571d40
update statistics.txt
zn-cn Jun 21, 2018
9a6de87
Add files via upload
lisnmn Jun 21, 2018
eaa6d97
Merge pull request #69 from lisnmn/bgroup
zn-cn Jun 22, 2018
3972d22
update statistics.txt
zn-cn Jun 22, 2018
3f2089b
add readme
pzn62026 Jun 22, 2018
6b2c404
pzn62026 Jun 22, 2018
5b72012
Delete blur.py
pzn62026 Jun 22, 2018
87c5014
Signed-off-by: pzn62026 <1114332572@qq.com>
pzn62026 Jun 22, 2018
0a0ce71
xiaotian's change
15827387385 Jun 22, 2018
0933c53
Signed-off-by: djq806323956 <806323956@qq.com>
djq806323956 Jun 22, 2018
8663b5b
Signed-off-by: CargoH <294233249@qq.com>
cargoh Jun 22, 2018
fca67f8
Signed-off-by: Sydukee <337255891@qq.com>
Sydukee Jun 22, 2018
446a3d8
Add files via upload
sin7777 Jun 22, 2018
e85fcb5
Add files via upload
sin7777 Jun 22, 2018
fed5f20
readme
pzn62026 Jun 22, 2018
f70a309
Signed-off-by: Isey666 <350432454@qq.com>
Isey666 Jun 22, 2018
a4f98cd
fix a bug
pzn62026 Jun 23, 2018
92607e1
Merge pull request #77 from pzn62026/bgroup
zn-cn Jun 23, 2018
eaf216c
fix 冲突
zn-cn Jun 23, 2018
9853564
Merge pull request #4 from wenjiewang98228/bgroup
RenShuhuai-Andy Jun 23, 2018
6b1f54b
修改了readme
RenShuhuai-Andy Jun 23, 2018
a3242da
finish
chiellini Jun 23, 2018
83e4705
Merge pull request #84 from RenShuhuai-Andy/bgroup
zn-cn Jun 24, 2018
b0f6f49
Update README.md
RenShuhuai-Andy Jun 24, 2018
05fa692
Update clear_noise.py
chenjixuan20 Jun 24, 2018
062ea37
Merge pull request #1 from lbkqkdcjx/patch-1
nansanhao Jun 24, 2018
3ce749b
Update clear_noise.py
chenjixuan20 Jun 24, 2018
67efe4f
Merge pull request #2 from lbkqkdcjx/patch-1
nansanhao Jun 24, 2018
f7681c4
Update clear_noise.py
bitzhangmo Jun 24, 2018
b5b0be2
Merge pull request #3 from bitzhangmo/patch-2
nansanhao Jun 24, 2018
daf1df5
Update clear_noise.py
bitzhangmo Jun 24, 2018
e9c2fcd
Merge pull request #4 from bitzhangmo/patch-3
nansanhao Jun 24, 2018
98336e2
Update clear_noise.py
CuteSmallZq Jun 24, 2018
4581901
Merge pull request #5 from CuteSmallZq/patch-1
nansanhao Jun 24, 2018
270bab6
Update clear_noise.py
CuteSmallZq Jun 24, 2018
0f5dd59
Merge pull request #6 from CuteSmallZq/patch-2
nansanhao Jun 24, 2018
ad713c4
Merge pull request #5 from wenjiewang98228/bgroup
RenShuhuai-Andy Jun 24, 2018
24c5b6c
new
4057492 Jun 24, 2018
2309134
change
4057492 Jun 24, 2018
dca9ad1
合并测试
nansanhao Jun 24, 2018
a308f67
Merge pull request #88 from RenShuhuai-Andy/bgroup
wenjiewang98228 Jun 24, 2018
71915ee
合并冲突
nansanhao Jun 24, 2018
45d2854
some changes
Udinazf Jun 24, 2018
ce8cc02
again
Udinazf Jun 24, 2018
0b55090
Merge pull request #89 from nansanhao/bgroup
wenjiewang98228 Jun 24, 2018
2223609
Readme ini
chiellini Jun 24, 2018
52607ec
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
chiellini Jun 24, 2018
8d7049b
fix some
chiellini Jun 24, 2018
bbab088
FINISH ALL
chiellini Jun 24, 2018
82ce4b2
fix entrance
chiellini Jun 24, 2018
0aa52e4
Create readme.md
lqm0408 Jun 24, 2018
4eae221
Create halfton.py
lqm0408 Jun 24, 2018
ef22bef
Add files via upload
lqm0408 Jun 24, 2018
f944641
Update halfton.py
yuxinyyy Jun 24, 2018
55d2021
Update halfton.py
Teresa9907 Jun 24, 2018
df31501
Create test_halfton.py
zxm1114 Jun 24, 2018
f6048ee
Update halfton.py
wss0303 Jun 24, 2018
08d67bf
Update readme.md
lqm0408 Jun 24, 2018
8e9c6a2
Rename halfton.py to halftone.py
lqm0408 Jun 24, 2018
e70f0d8
Merge pull request #93 from lqm0408/bgroup
zn-cn Jun 24, 2018
b955104
Update readme.md
lqm0408 Jun 24, 2018
052e62d
Update readme.md
lqm0408 Jun 24, 2018
5ba0813
Merge pull request #95 from lqm0408/bgroup
zn-cn Jun 24, 2018
fff23e0
Create light.py
zz313147877 Jun 24, 2018
9b9b214
完成覆盖率测试 完成readme
chiellini Jun 24, 2018
14dd439
Add files via upload
zz313147877 Jun 24, 2018
e27525b
Merge pull request #10 from wenjiewang98228/bgroup
Jun 24, 2018
156343c
Update light.py
TianZishen Jun 24, 2018
8684894
Merge pull request #1 from zz313147877/bgroup
pan-1229 Jun 24, 2018
2d6e6aa
Merge pull request #1 from tzs0831/bgroup
zz313147877 Jun 24, 2018
b9f00d1
Update light.py
pan-1229 Jun 24, 2018
d1a492d
Merge pull request #2 from PanLei1997/bgroup
zz313147877 Jun 24, 2018
5f57c83
fix readme
chiellini Jun 24, 2018
bf9305d
Update README
Jun 24, 2018
276e565
Add files via upload
jgszxlyh Jun 24, 2018
1e5d24a
Merge pull request #3 from jgszxlyh/bgroup
zz313147877 Jun 24, 2018
5f5f42e
Update objloader.py
zhaodashu Jun 24, 2018
b3b6fbd
Merge pull request #4 from zhaodashu/bgroup
zz313147877 Jun 24, 2018
c4f3fef
Merge pull request #103 from LWJ312/bgroup
zn-cn Jun 24, 2018
995fceb
Update main.py
zz313147877 Jun 25, 2018
a6b0b06
Update test_objloader.py
zz313147877 Jun 25, 2018
36dd05f
Merge pull request #104 from zz313147877/bgroup
zn-cn Jun 25, 2018
695f7d2
Update README.md
Jun 25, 2018
484dfee
update statistics.txt
zn-cn Jun 25, 2018
6e0df95
c
4057492 Jun 25, 2018
70c9b35
test-fy
SkmtJun Jun 25, 2018
048335a
sfsaf
SkmtJun Jun 25, 2018
fc74a4e
finish
SkmtJun Jun 25, 2018
996592f
sdfdsfasf
SkmtJun Jun 25, 2018
38c1b9c
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
Udinazf Jun 25, 2018
de05c68
Add c++ reference
Minstreams Jun 25, 2018
4243b65
Delete reference
Minstreams Jun 25, 2018
2cd9ccf
121
yukiiris Jun 25, 2018
7000dfd
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
yukiiris Jun 25, 2018
137044e
qwewq
yukiiris Jun 25, 2018
ee7a6b0
1232
yukiiris Jun 25, 2018
0a6aed9
delete useless
chiellini Jun 25, 2018
0803798
123213
yukiiris Jun 25, 2018
0e269a3
12321431
yukiiris Jun 25, 2018
fa96f2e
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
chiellini Jun 25, 2018
c2fc614
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
yukiiris Jun 25, 2018
291f95e
12321
yukiiris Jun 25, 2018
7aa8ec6
change
4057492 Jun 25, 2018
5d89945
Revert "change"
4057492 Jun 25, 2018
d974437
Revert "change"
4057492 Jun 25, 2018
ef661ae
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
Udinazf Jun 25, 2018
78f9152
m
Udinazf Jun 25, 2018
a081659
Revert "m"
Udinazf Jun 25, 2018
b9d85ad
Merge branch 'bgroup' of https://github.com/chiellini/relaxrender int…
Udinazf Jun 25, 2018
94b492c
m
Udinazf Jun 25, 2018
cdfe8ae
n
Udinazf Jun 25, 2018
960a361
update statistics.txt
zn-cn Jun 25, 2018
d8c9e92
finish!!!!!!!!!!!!!!!!!!!!!
chiellini Jun 25, 2018
88976e6
Merge pull request #108 from chiellini/bgroup
zn-cn Jun 25, 2018
5f05b38
Create README.md
Jun 25, 2018
0de4d70
Update README.md
Jun 25, 2018
89b3cf7
Update README.md
Jun 25, 2018
a568b07
update statistics.txt
zn-cn Jun 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ build
.coverage
.pytest_cache/
htmlcov/
.idea/
Binary file added DOO-SABIN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,58 @@ conda install --file requirements.txt -y
pip install -e .

pytest --cov-report=html --cov=relaxrender --ignore=tests/test_relaxrender.py tests



注明:

若遇到找不到模块,或许可以采用如下运行方法,详细请看Python包管理相关知识

**Windows 运行方法之一:**

打开 cmd , cd 到项目根目录,之后设置 临时环境变量 PYTHONPATH 为当前目录,之后在根目录运行你的文件


示例:

```
# cmd
D: # 磁盘号
cd <项目根目录>
set PYTHONPATH=<relaxrender绝对目录>
python <文件路径>
```

**Linux 运行文件方法之一:**

```
cd <项目根目录>
export PYTHONPATH=<relaxrender绝对目录>
python3 <文件路径>
```

### 代码量统计并排名

在 bash 下运行如下命令,即可生成 statistics.txt (按照代码量排名)

```shell
git log --format='%aN' | sort -r -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done | sort -n -r -k 4 -t: > statistics.txt
```

若想直接观看,可以直接运行如下命令:

```shell
git log --format='%aN' | sort -r -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done | sort -n -r -k 4 -t:
```

示例如下:

```
pipehappy added lines: 1844, removed lines: 0, total lines: 1844
tofar added lines: 29, removed lines: 0, total lines: 29
pipehappy1 added lines: 21, removed lines: 0, total lines: 21
Liujiaohan added lines: 8, removed lines: 0, total lines: 8
molscar added lines: 4, removed lines: 0, total lines: 4
wenjiewang98228 added lines: 3, removed lines: 2, total lines: 1
```

Binary file added features/QMC/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 140 additions & 0 deletions features/QMC/halftone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import PIL.Image as Image
import PIL.ImageDraw as ImageDraw
import PIL.ImageStat as ImageStat
import os

"""
The bulk of this is taken from this Stack Overflow answer by fraxel:
http://stackoverflow.com/a/10575940/250962
"""


class Halftone:
def __init__(self, path):
"""
:param path: eg: ./src/1.jpeg
"""
self.path = path

def make(self, sample=10, scale=1, angles=[0, 15, 30, 45], antialias=False, style='color', percentage=0,filename_add='_halftoned'):
"""
sample: 原始图像中的样本框大小(以像素为单位)。
scale: 最大输出点直径是样本*比例
angles: 每个屏幕通道应旋转4个角度的列表
style: '颜色'或'灰度'
antialias: true or false
percentage: 从CMY频道中删除多少灰色分量并放入K频道
filename_add: 输出文件名
"""

# try:
im = Image.open(self.path)
# except IOError:
# print("Cannot open such image...")
# raise

if style == 'grayscale':
angles = angles[:1]
gray_im = im.convert('L') # mode:8位像素
dots = self.halftone(gray_im, sample, scale, angles, antialias)
new = dots[0]

else:
cmyk_im = im.convert('CMYK')
cmyk_im_merge = self.gcr(cmyk_im, percentage)
dots = self.halftone(cmyk_im_merge, sample, scale, angles, antialias)
new = Image.merge('CMYK', dots) # mode:4*8 位像素,颜色分离

f, e = os.path.splitext(self.path)
outfile = "%s%s%s" % (f, filename_add, e)
new.save(outfile)

def gcr(self, im, percentage):
"""
gcr: 灰色组件更换
返回从CMY通道中移除百分比灰色分量的CMYK图像
并放入K频道,
percentage = 80, (30, 100, 255, 0) >> (6, 76, 231, 24)
"""
if not percentage:
return im
cmyk_arr = im.split()
cmyk = []
for i in range(4):
cmyk.append(cmyk_arr[i].load())
for x in range(im.size[0]): # for x axis pixels
for y in range(im.size[1]): # for y axis pixels
gray = min(cmyk[0][x, y], cmyk[1][x, y], cmyk[2][x, y]) * percentage / 100
for i in range(3):
cmyk[i][x, y] -= int(gray)
cmyk[3][x, y] = int(gray)
return Image.merge('CMYK', cmyk_arr)

def halftone(self, cmyk, sample, scale, angles, antialias):
"""
返回cmyk图像的半色调图像列表。
因此,样品= 1将保留原始图像分辨率,
(但尺度必须大于1以允许点尺寸的变化)。
"""
if antialias is True:
antialias_scale = 4
# 按照这个比例乘以图像的大小
# 在合并时绘制和缩小
scale *= antialias_scale

dots = []

for channel, angle in zip(cmyk.split(), angles):
channel = channel.rotate(angle, expand=1)
size = channel.size[0] * scale, channel.size[1] * scale
half_tone = Image.new('L', size)
draw = ImageDraw.Draw(half_tone)
# 一次循环一个采样点,为每个采样点绘制一个圆圈:
for x in range(0, channel.size[0], sample):
for y in range(0, channel.size[1], sample):
# 我们抽样得到的等级:
box = channel.crop((x, y, x + sample, y + sample))

# 该框的平均等级(0-255)
mean = ImageStat.Stat(box).mean[0]

# 根据平均值绘制的圆的直径(0-1):
diameter = (mean / 255) ** 0.5

# 我们将在此框中绘制圆框的大小:
box_size = sample * scale

# 我们将绘制的圆的直径:
#如果sample = 10且scale = 1,则这是(0-10)
draw_diameter = diameter * box_size

# 框左上角的位置,我们将在下面画圆:
# x_pos, y_pos = (x * scale), (y * scale)
box_x, box_y = (x * scale), (y * scale)

# 位于圈子的左上角和右下角:
#最大尺寸的圆将在其边缘有边缘绘图框的#号
x1 = box_x + ((box_size - draw_diameter) / 2)
y1 = box_y + ((box_size - draw_diameter) / 2)
x2 = x1 + draw_diameter
y2 = y1 + draw_diameter

draw.ellipse([(x1, y1), (x2, y2)], fill=255)

half_tone = half_tone.rotate(-angle, expand=1)
width_half, height_half = half_tone.size

# 要裁剪的图像的左上角和右下角:
xx1 = (width_half - cmyk.size[0] * scale) / 2
yy1 = (height_half - cmyk.size[1] * scale) / 2
xx2 = xx1 + cmyk.size[0] * scale
yy2 = yy1 + cmyk.size[1] * scale

half_tone = half_tone.crop((xx1, yy1, xx2, yy2))

if antialias is True:
w = (xx2 - xx1) / antialias_scale
h = (yy2 - yy1) / antialias_scale
half_tone = half_tone.resize((int(w), int(h)), resample=Image.LANCZOS)
dots.append(half_tone)
return dots
11 changes: 11 additions & 0 deletions features/QMC/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Quasi-Monte Carlo b组

用拟蒙特卡罗方法实现半色调技术

仓库链接 https://github.com/lqm0408/relaxrender

组长 :罗清明 lqm0408
组员 :刘笛 Teresa9907
杨雨欣 yuxinyyy
张欣萌 zxm1114
王帅帅 QQ1820621360
11 changes: 11 additions & 0 deletions features/QMC/test_halfton.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest
import halftone

class Testhalftone(unittest.TestCase):
def testhalftone_gray(self):
h = halftone.Halftone('1.jpg')
h.make(style='grayscale',filename_add='1')
def testOthers(self):
h = halftone.Halftone('1.jpg')
h.make(style='color',filename_add='4',percentage=100,antialias=True)
h.make(style='color',filename_add='5',percentage=0,antialias=True)
6 changes: 6 additions & 0 deletions features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
每个小组根据自己的feature新建一个文件夹,在该文件夹下进行开发,要求有readme和test文件
例:teapot---|--- README.md

|--- render.py

|--- test__xxx.py
9 changes: 9 additions & 0 deletions features/bumping-map/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add test file test_bumping_map.py

add code file bumping_map.py

add picture normal.png

All the paths in this project are relative.

Note:normal.png is needed for bumping_map.py. If you want to change the file catalog, please remodify the file path in bumping_map.py.
152 changes: 152 additions & 0 deletions features/bumping-map/bumping_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
from functools import reduce
import numpy as np
import time
import numbers
import imageio
import random

def extract(cond, x):
if isinstance(x, numbers.Number):
return x
else:
return np.extract(cond, x)

class vec3():
def __init__(self, x, y, z):
(self.x, self.y, self.z) = (x, y, z)
def __mul__(self, other):
return vec3(self.x * other, self.y * other, self.z * other)
def __add__(self, other):
return vec3(self.x + other.x, self.y + other.y, self.z + other.z)
def __sub__(self, other):
return vec3(self.x - other.x, self.y - other.y, self.z - other.z)
def dot(self, other):
return (self.x * other.x) + (self.y * other.y) + (self.z * other.z)
def __abs__(self):
return self.dot(self)
def norm(self):
mag = np.sqrt(abs(self))
return self * (1.0 / np.where(mag == 0, 1, mag))
def components(self):
return (self.x, self.y, self.z)
def extract(self, cond):
return vec3(extract(cond, self.x),
extract(cond, self.y),
extract(cond, self.z))
def place(self, cond):
r = vec3(np.zeros(cond.shape), np.zeros(cond.shape), np.zeros(cond.shape))
np.place(r.x, cond, self.x)
np.place(r.y, cond, self.y)
np.place(r.z, cond, self.z)
return r
rgb = vec3

(w, h) = (800, 600) #图片大小
L = vec3(0, 0.9, 1) #光源位置
E = vec3(0., 0.35, -1) #视野位置
FARAWAY = 1.0e39 #无限长度

#读取法线贴图
normalsource = imageio.imread(r"normal.png");
normalMap = np.array(normalsource)
#取法线贴图分量
normalX = normalsource.take([0], axis = 2)
normalX = np.array(normalX).reshape(normalX.size)
normalY = normalsource.take([1], axis = 2)
normalY = np.array(normalY).reshape(normalY.size)
normalZ = normalsource.take([2], axis = 2)
normalZ = np.array(normalZ).reshape(normalZ.size)
#输出测试
print (normalX)
print (normalY)
print (normalZ)
#将法线贴图的数据转化为归一化的法线数据
normalX = (normalX * 2 / 255) - 1
normalY = (normalY * 2 / 255) - 1
normalZ = (normalZ * 2 / 255) - 1
#输出测试
print (normalX.size)
print (normalY.size)
print (normalZ.size)

def raytrace(O, D, scene, bounce = 0):
distances = [s.intersect(O, D) for s in scene]
nearest = reduce(np.minimum, distances)
color = rgb(0, 0, 0)
for (sphere, d) in zip(scene, distances):
hit = (nearest != FARAWAY) & (d == nearest)
if np.any(hit):
dc = extract(hit, d)
Oc = O.extract(hit)
Dc = D.extract(hit)
cc = sphere.light(Oc, Dc, dc, scene, bounce)
color += cc.place(hit)
return color

class Sphere:
def __init__(self, center, r, diffuse, mirror = 0.5):
self.c = center
self.r = r
self.diffuse = diffuse
self.mirror = mirror
Sphere.countX = 0
Sphere.countY = 0
Sphere.countZ = 0


def intersect(self, O, D):
b = 2 * D.dot(O - self.c)
c = abs(self.c) + abs(O) - 2 * self.c.dot(O) - (self.r * self.r)
disc = (b ** 2) - (4 * c)
sq = np.sqrt(np.maximum(0, disc))
h0 = (-b - sq) / 2
h1 = (-b + sq) / 2
h = np.where((h0 > 0) & (h0 < h1), h0, h1)
pred = (disc > 0) & (h > 0)
return np.where(pred, h, FARAWAY)

def diffusecolor(self, M):
return self.diffuse

def light(self, O, D, d, scene, bounce):
M = (O + D * d) # 交点
N = (M - self.c) * (1. / self.r)
normal_x = normalX[0:97012]
normal_y = normalY[0:97012]
normal_z = normalZ[0:97012]

N = vec3(normal_x, normal_y, normal_z)
toL = (L - M).norm() # 光线方向
toO = (E - M).norm() # 视野射线方向
nudged = M + N * .0001

# 阴影并计算交点是否在阴影内
light_distances = [s.intersect(nudged, toL) for s in scene]
light_nearest = reduce(np.minimum, light_distances)
seelight = light_distances[scene.index(self)] == light_nearest

# 环境光
color = rgb(0.05, 0.05, 0.05)

#兰伯特光照
lv = np.maximum(N.dot(toL) * -1, 0)
color += self.diffusecolor(M) * lv * seelight
return color
def draw():
scene = [ Sphere(vec3(0, .1, .5), .6, rgb(0.7, 0.7, 0.7))]

r = float(w) / h
S = (-1., 1. / r + .25, 1., -1. / r + .25)
x = np.tile(np.linspace(S[0], S[2], w), h)
y = np.repeat(np.linspace(S[1], S[3], h), w)

t0 = time.time()
Q = vec3(x, y, 0)
color = raytrace(E, (Q - E).norm(), scene)
print("Took", time.time() - t0)
l=[]
for c in color.components():
l.append((255 * np.clip(c, 0, 1).reshape((h, w))) .astype(np.uint8))
output=np.array(list(list([l[0][i][j],l[1][i][j],l[2][i][j]] for j in range(len(l[0][0]))) for i in range(len(l[0]))))
imageio.imwrite(r"output.png",output)
return 1
Binary file added features/bumping-map/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading