MCPcopy Create free account
hub / github.com/RylonW/DocNLC / _createPath

Method _createPath

utils/motionblur.py:111–231  ·  view source on GitHub ↗

[summary] creates a motion blur path with the given intensity. [description] Proceede in 5 steps 1. Get a random number of random step sizes 2. For each step get a random angle 3. combine steps and angles into a sequence of increments 4. create

(self)

Source from the content-addressed store, hash-verified

109 self.kernel_is_generated = False
110
111 def _createPath(self):
112 """[summary]
113 creates a motion blur path with the given intensity.
114 [description]
115 Proceede in 5 steps
116 1. Get a random number of random step sizes
117 2. For each step get a random angle
118 3. combine steps and angles into a sequence of increments
119 4. create path out of increments
120 5. translate path to fit the kernel dimensions
121
122 NOTE: "random" means random but might depend on the given intensity
123 """
124
125 # first we find the lengths of the motion blur steps
126 def getSteps():
127 """[summary]
128 Here we calculate the length of the steps taken by
129 the motion blur
130 [description]
131 We want a higher intensity lead to a longer total motion
132 blur path and more different steps along the way.
133
134 Hence we sample
135
136 MAX_PATH_LEN =[U(0,1) + U(0, intensity^2)] * diagonal * 0.75
137
138 and each step: beta(1, 30) * (1 - self.INTENSITY + eps) * diagonal)
139 """
140
141 # getting max length of blur motion
142 self.MAX_PATH_LEN = 0.75 * self.DIAGONAL * \
143 (uniform() + uniform(0, self.INTENSITY**2))
144
145 # getting step
146 steps = []
147
148 while sum(steps) < self.MAX_PATH_LEN:
149
150 # sample next step
151 step = beta(1, 30) * (1 - self.INTENSITY + eps) * self.DIAGONAL
152 if step < self.MAX_PATH_LEN:
153 steps.append(step)
154
155 # note the steps and the total number of steps
156 self.NUM_STEPS = len(steps)
157 self.STEPS = np.asarray(steps)
158
159 def getAngles():
160 """[summary]
161 Gets an angle for each step
162 [description]
163 The maximal angle should be larger the more
164 intense the motion is. So we sample it from a
165 U(0, intensity * pi)
166
167 We sample "jitter" from a beta(2,20) which is the probability
168 that the next angle has a different sign than the previous one.

Callers 1

_createKernelMethod · 0.95

Calls 1

polar2zFunction · 0.85

Tested by

no test coverage detected