@@ -19,16 +19,12 @@ Check it on [Pypi](https://pypi.org/project/BlurGenerator/).
19
19
## Usage
20
20
21
21
``` bash
22
- usage: blurgenerator [-h] [--input INPUT] [--output OUTPUT] [--type TYPE] [--motion_blur_size MOTION_BLUR_SIZE] [--motion_blur_angle MOTION_BLUR_ANGLE]
23
- [--lens_radius LENS_RADIUS] [--lens_components LENS_COMPONENTS] [--lens_exposure_gamma LENS_EXPOSURE_GAMMA]
24
- [--gaussian_kernel GAUSSIAN_KERNEL]
25
-
26
- optional arguments:
27
- -h, --help show this help message and exit
28
- --input INPUT Specific path of image as ` input` .
29
- --output OUTPUT Specific path for ` output` . Default is ` ./result.png` .
30
- --type TYPE Blur type of ` motion` , ` lens` , or ` gaussian` . Default is ` motion` .
31
- --motion_blur_size MOTION_BLUR_SIZE
22
+ blurgenerator --help
23
+ ```
24
+
25
+ ``` bash
26
+ usage: blurgenerator [-h] [--input INPUT] [--input_depth_map INPUT_DEPTH_MAP] [--output OUTPUT] [--type TYPE] [--motion_blur_size MOTION_BLUR_SIZE] [--motion_blur_angle MOTION_BLUR_ANGLE] [--lens_radius LENS_RADIUS] [--lens_components LENS_COMPONENTS]
27
+ [--lens_exposure_gamma LENS_EXPOSURE_GAMMA] [--gaussian_kernel GAUSSIAN_KERNEL] [--depth_num_layers DEPTH_NUM_LAYERS] [--depth_min_blur DEPTH_MIN_BLUR] [--depth_max_blur DEPTH_MAX_BLUR]
32
28
Size for motion blur. Default is 100.
33
29
--motion_blur_angle MOTION_BLUR_ANGLE
34
30
Angle for motion blur. Default is 30.
@@ -40,13 +36,23 @@ optional arguments:
40
36
Exposure gamma for lens blur. Default is 2.
41
37
--gaussian_kernel GAUSSIAN_KERNEL
42
38
Kernel for gaussian. Default is 100.
39
+ --depth_num_layers DEPTH_NUM_LAYERS
40
+ Layer for depth blur. Default is 3.
41
+ --depth_min_blur DEPTH_MIN_BLUR
42
+ Min. blur for depth blur. Default is 1.
43
+ --depth_max_blur DEPTH_MAX_BLUR
44
+ Max. blur for depth blur. Default is 100.
43
45
```
44
46
45
47
## Example and Result
46
48
49
+ ### Common use
50
+
47
51
- Original image
48
52
49
- ![ original image] ( https://github.com/NatLee/Blur-Generator/blob/main/doc/test.png?raw=true )
53
+ ![ original image] ( ./doc/test.png )
54
+
55
+ #### Usage
50
56
51
57
- Motion blur
52
58
@@ -57,9 +63,10 @@ import cv2
57
63
from blurgenerator import motion_blur
58
64
img = cv2.imread(' test.png' )
59
65
result = motion_blur(img, size = 100 , angle = 30 )
66
+ cv2.imwrite(' ./output.png' , result)
60
67
```
61
68
62
- ![ motion blur image] ( https://github.com/NatLee/Blur-Generator/blob/main/ doc/motion.png?raw=true )
69
+ ![ motion blur image] ( ./ doc/motion.png)
63
70
64
71
- Lens blur
65
72
@@ -70,9 +77,10 @@ import cv2
70
77
from blurgenerator import lens_blur
71
78
img = cv2.imread(' test.png' )
72
79
result = lens_blur(img, radius = 5 , components = 4 , exposure_gamma = 2 )
80
+ cv2.imwrite(' ./output.png' , result)
73
81
```
74
82
75
- ![ lens blur image] ( https://github.com/NatLee/Blur-Generator/blob/main/ doc/lens.png?raw=true )
83
+ ![ lens blur image] ( ./ doc/lens.png)
76
84
77
85
- Gaussian blur
78
86
@@ -83,6 +91,88 @@ import cv2
83
91
from blurgenerator import gaussian_blur
84
92
img = cv2.imread(' test.png' )
85
93
result = gaussian_blur(img, 100 )
94
+ cv2.imwrite(' ./output.png' , result)
95
+ ```
96
+
97
+ ![ gaussian blur image] ( ./doc/gaussian.png )
98
+
99
+ ### With depth map
100
+
101
+ Feature from this [ issue] ( https://github.com/NatLee/Blur-Generator/issues/1 ) .
102
+
103
+ - Original image
104
+
105
+ ![ photo] ( ./doc/depth-test.jpg )
106
+
107
+ - Depth map
108
+
109
+ ![ depth map] ( ./doc/depth-map-test.png )
110
+
111
+ #### Usage
112
+
113
+ - Motion blur with depth map
114
+
115
+ ` blurgenerator --input .\doc\depth-test.jpg --type motion --input_depth_map .\doc\depth-map-test.png --depth_num_layers 5 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-motion-output.png `
116
+
117
+ ``` python
118
+ import cv2
119
+ from blurgenerator import motion_blur_with_depth_map
120
+ img = cv2.imread(' test.jpg' )
121
+ depth_img = cv2.imread(' test-depth.png' )
122
+ result = motion_blur_with_depth_map(
123
+ img,
124
+ depth_map = depth_img,
125
+ angle = 30 ,
126
+ num_layers = 10 ,
127
+ min_blur = 1 ,
128
+ max_blur = 50
129
+ )
130
+ cv2.imwrite(' ./output.png' , result)
131
+ ```
132
+
133
+ ![ depth motion blur image] ( ./doc/depth-motion-output.png )
134
+
135
+ - Lens blur with depth map
136
+
137
+ ` blurgenerator --input .\doc\depth-test.jpg --type lens --input_depth_map .\doc\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-lens-output.png `
138
+
139
+ ``` python
140
+ import cv2
141
+ from blurgenerator import lens_blur_with_depth_map
142
+ img = cv2.imread(' test.jpg' )
143
+ depth_img = cv2.imread(' test-depth.png' )
144
+ result = lens_blur_with_depth_map(
145
+ img,
146
+ depth_map = depth_img,
147
+ components = 5 ,
148
+ exposure_gamma = 5 ,
149
+ num_layers = 10 ,
150
+ min_blur = 1 ,
151
+ max_blur = 50
152
+ )
153
+ cv2.imwrite(' ./output.png' , result)
154
+ ```
155
+
156
+ ![ depth lens blur image] ( ./doc/depth-lens-output.png )
157
+
158
+ - Gaussian blur with depth map
159
+
160
+ ` blurgenerator --input .\doc\depth-test.jpg --type gaussian --input_depth_map .\doc\depth-map-test.png --depth_num_layers 3 --depth_min_blur 1 --depth_max_blur 50 --output .\doc\depth-gaussian-output.png `
161
+
162
+ ``` python
163
+ import cv2
164
+ from blurgenerator import gaussian_blur_with_depth_map
165
+ img = cv2.imread(' test.jpg' )
166
+ depth_img = cv2.imread(' test-depth.png' )
167
+ result = gaussian_blur_with_depth_map(
168
+ img,
169
+ depth_map = depth_img,
170
+ sigma = 5 ,
171
+ num_layers = 10 ,
172
+ min_blur = 1 ,
173
+ max_blur = 50
174
+ )
175
+ cv2.imwrite(' ./output.png' , result)
86
176
```
87
177
88
- ![ gaussian blur image] ( https://github.com/NatLee/Blur-Generator/blob/main/ doc/gaussian.png?raw=true )
178
+ ![ depth gaussian blur image] ( ./ doc/depth- gaussian-output .png)
0 commit comments