This repository has been archived by the owner on May 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathShinkaiMakotoFilter.py
70 lines (60 loc) · 1.79 KB
/
ShinkaiMakotoFilter.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from ompc import
@mfunction("light")
def ShinkaiMakotoFilter(src=None, target=None, sky=None):
# Summary - function version
# preparation
[M, N, C] = size(src)
# Step1: median filtering
fprintf(mstring('\\nStep1: median filtering\\n'))
blur = changeStyle(src, M * N)
# Step2: color transfer (guide)
fprintf(mstring('\\nStep2: color transfer\\n'))
color = cf_reinhard(blur, target)
# Step3: adjust (saturation, brightness)
fprintf(mstring('\\nStep3: adjust\\n'))
adjust = adjustHSV(color)
# Step4: paste sky (sky)
fprintf(mstring('\\nStep4: paste sky\\n'))
[skyMask, mask_threshold, mask_dilate, mask_erode] = findSky(src)
changeSky = pasteSky(adjust, sky, skyMask)
# Step5: add light (light source)
fprintf(mstring('\\nStep5: add light\\n'))
[light, light_filter] = addLight(src, changeSky, M, N)
# show
figure()
imshow(src)
title(mstring('src'))
figure()
imshow(blur)
title(mstring('Step1: median filtering'))
figure()
imshow(target)
title(mstring('guide'))
figure()
imshow(color)
title(mstring('Step2: color transform'))
figure()
imshow(adjust)
title(mstring('Step3: adjust'))
figure()
imshow(mask_threshold)
title(mstring('Step4-1: threshold'))
figure()
imshow(mask_dilate)
title(mstring('Step4-2: dilation'))
figure()
imshow(mask_erode)
title(mstring('Step4-3: erosion'))
figure()
imshow(skyMask)
title(mstring('Step4-3: sky mask'))
figure()
imshow(changeSky)
title(mstring('Step4: paste sky'))
figure()
imshow(light_filter)
title(mstring('light filter'))
figure()
imshow(light)
title(mstring('Step5: add light'))
end