Debian Codegraph @

docs/resampling.html

raw symbols SCIP
1 <h2>Resampling</h2>
2 <p><strong>Algorithm</strong> : Upsampling<br />
3 <strong>Input</strong> :
4 <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
5 <semantics>
6 <mrow>
7 <mo stretchy="true" form="prefix">{</mo>
8 <mi>v</mi>
9 <mo stretchy="false" form="prefix">[</mo>
10 <mi>k</mi>
11 <mo stretchy="false" form="postfix">]</mo>
12 <mo>=</mo>
13 <mrow>
14 <mo stretchy="true" form="prefix">(</mo>
15 <mi>x</mi>
16 <mo stretchy="false" form="prefix">[</mo>
17 <mi>k</mi>
18 <mo stretchy="false" form="postfix">]</mo>
19 <mo>,</mo>
20 <mi>y</mi>
21 <mo stretchy="false" form="prefix">[</mo>
22 <mi>k</mi>
23 <mo stretchy="false" form="postfix">]</mo>
24 <mo>,</mo>
25 <mi>t</mi>
26 <mo stretchy="false" form="prefix">[</mo>
27 <mi>k</mi>
28 <mo stretchy="false" form="postfix">]</mo>
29 <mo stretchy="true" form="postfix">)</mo>
30 </mrow>
31 <mo>,</mo>
32 <mn>0</mn>
33 <mo>≤</mo>
34 <mi>k</mi>
35 <mo>≤</mo>
36 <mi>n</mi>
37 <mo stretchy="true" form="postfix">}</mo>
38 </mrow>
39 <annotation encoding="application/x-tex">\left\{ v\lbrack k\rbrack = \left( x\lbrack k\rbrack,y\lbrack
40 k\rbrack,t\lbrack k\rbrack \right),0 \leq k \leq n \right\}</annotation>
41 </semantics>
42 </math>
43 and a target rate <code>sampling_min_output_rate</code>, Interpolate
44 time and position between each
45 <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
46 <semantics>
47 <mi>k</mi>
48 <annotation encoding="application/x-tex">k</annotation>
49 </semantics>
50 </math>
51 by linearly adding interpolated values<br />
52 This is done by adding linearly interpolated values so that the output
53 stream is
54 <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
55 <semantics>
56 <mrow>
57 <mo stretchy="true" form="prefix">{</mo>
58 <mi>v</mi>
59 <mo stretchy="false" form="prefix">[</mo>
60 <mn>0</mn>
61 <mo stretchy="false" form="postfix">]</mo>
62 <mo>,</mo>
63 <munder>
64 <munder>
65 <mrow>
66 <msub>
67 <mi>u</mi>
68 <mn>0</mn>
69 </msub>
70 <mo stretchy="false" form="prefix">[</mo>
71 <mn>1</mn>
72 <mo stretchy="false" form="postfix">]</mo>
73 <mo>,</mo>
74 <mi>…</mi>
75 <mo>,</mo>
76 <msub>
77 <mi>u</mi>
78 <mn>0</mn>
79 </msub>
80 <mrow>
81 <mo stretchy="true" form="prefix">[</mo>
82 <msub>
83 <mi>n</mi>
84 <mn>0</mn>
85 </msub>
86 <mo>−</mo>
87 <mn>1</mn>
88 <mo stretchy="true" form="postfix">]</mo>
89 </mrow>
90 </mrow>
91 <mo accent="true">⏟</mo>
92 </munder>
93 <mrow>
94 <mspace width="0.333em"></mspace>
95 <mtext mathvariant="normal"> interpolated</mtext>
96 </mrow>
97 </munder>
98 <mo>,</mo>
99 <mi>v</mi>
100 <mo stretchy="false" form="prefix">[</mo>
101 <mn>1</mn>
102 <mo stretchy="false" form="postfix">]</mo>
103 <mo>,</mo>
104 <munder>
105 <munder>
106 <mrow>
107 <msub>
108 <mi>u</mi>
109 <mn>1</mn>
110 </msub>
111 <mo stretchy="false" form="prefix">[</mo>
112 <mn>1</mn>
113 <mo stretchy="false" form="postfix">]</mo>
114 <mo>,</mo>
115 <mi>…</mi>
116 <mo>,</mo>
117 <msub>
118 <mi>u</mi>
119 <mn>1</mn>
120 </msub>
121 <mrow>
122 <mo stretchy="true" form="prefix">[</mo>
123 <msub>
124 <mi>n</mi>
125 <mn>1</mn>
126 </msub>
127 <mo>−</mo>
128 <mn>1</mn>
129 <mo stretchy="true" form="postfix">]</mo>
130 </mrow>
131 </mrow>
132 <mo accent="true">⏟</mo>
133 </munder>
134 <mrow>
135 <mspace width="0.333em"></mspace>
136 <mtext mathvariant="normal"> interpolated</mtext>
137 </mrow>
138 </munder>
139 <mo>,</mo>
140 <mi>v</mi>
141 <mo stretchy="false" form="prefix">[</mo>
142 <mn>2</mn>
143 <mo stretchy="false" form="postfix">]</mo>
144 <mo>,</mo>
145 <mi>…</mi>
146 <mo stretchy="true" form="postfix">}</mo>
147 </mrow>
148 <annotation encoding="application/x-tex">\left\{ v\lbrack 0\rbrack,\underset{\text{
149 interpolated}}{\underbrace{u_{0}\lbrack 1\rbrack,\ldots,u_{0}\left\lbrack n_{0} - 1
150 \right\rbrack}},v\lbrack 1\rbrack,\underset{\text{ interpolated}}{\underbrace{u_{1}\lbrack
151 1\rbrack,\ldots,u_{1}\left\lbrack n_{1} - 1 \right\rbrack}},v\lbrack 2\rbrack,\ldots \right\}
152 </annotation>
153 </semantics>
154 </math>
155 Each
156 <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
157 <semantics>
158 <msub>
159 <mi>n</mi>
160 <mi>i</mi>
161 </msub>
162 <annotation encoding="application/x-tex">n_{i}</annotation>
163 </semantics>
164 </math>
165 is the minimum integer such that
166 <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
167 <semantics>
168 <mtable>
169 <mtr>
170 <mtd columnalign="right" style="text-align: right"></mtd>
171 <mtd columnalign="left" style="text-align: left">
172 <mfrac>
173 <mrow>
174 <mi>t</mi>
175 <mo stretchy="false" form="prefix">[</mo>
176 <mi>i</mi>
177 <mo stretchy="false" form="postfix">]</mo>
178 <mo>−</mo>
179 <mi>t</mi>
180 <mo stretchy="false" form="prefix">[</mo>
181 <mi>i</mi>
182 <mo>−</mo>
183 <mn>1</mn>
184 <mo stretchy="false" form="postfix">]</mo>
185 </mrow>
186 <msub>
187 <mi>n</mi>
188 <mi>i</mi>
189 </msub>
190 </mfrac>
191 <mo>&lt;</mo>
192 <msub>
193 <mi>Δ</mi>
194 <mtext mathvariant="normal">target</mtext>
195 </msub>
196 </mtd>
197 </mtr>
198 <mtr>
199 <mtd columnalign="right" style="text-align: right">
200 <mo>⇔</mo>
201 </mtd>
202 <mtd columnalign="left" style="text-align: left">
203 <msub>
204 <mi>n</mi>
205 <mi>i</mi>
206 </msub>
207 <mo>=</mo>
208 <mrow>
209 <mo stretchy="true" form="prefix">⌈</mo>
210 <mfrac>
211 <mrow>
212 <mi>t</mi>
213 <mo stretchy="false" form="prefix">[</mo>
214 <mi>i</mi>
215 <mo>+</mo>
216 <mn>1</mn>
217 <mo stretchy="false" form="postfix">]</mo>
218 <mo>−</mo>
219 <mi>t</mi>
220 <mo stretchy="false" form="prefix">[</mo>
221 <mi>i</mi>
222 <mo stretchy="false" form="postfix">]</mo>
223 </mrow>
224 <msub>
225 <mi>Δ</mi>
226 <mtext mathvariant="normal">target</mtext>
227 </msub>
228 </mfrac>
229 <mo stretchy="true" form="postfix">⌉</mo>
230 </mrow>
231 </mtd>
232 </mtr>
233 </mtable>
234 <annotation encoding="application/x-tex">\begin{aligned}
235 &amp; \frac{t\lbrack i\rbrack - t\lbrack i - 1\rbrack}{n_{i}} &lt; \Delta_{\text{target}} \\
236 \Leftrightarrow &amp; n_{i} = \left\lceil \frac{t\lbrack i + 1\rbrack - t\lbrack
237 i\rbrack}{\Delta_{\text{target}}} \right\rceil
238 \end{aligned}</annotation>
239 </semantics>
240 </math> and the linear
241 interpolation means
242 <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
243 <semantics>
244 <mrow>
245 <msub>
246 <mi>u</mi>
247 <mi>j</mi>
248 </msub>
249 <mo stretchy="false" form="prefix">[</mo>
250 <mi>k</mi>
251 <mo stretchy="false" form="postfix">]</mo>
252 <mo>=</mo>
253 <mrow>
254 <mo stretchy="true" form="prefix">(</mo>
255 <mn>1</mn>
256 <mo>−</mo>
257 <mfrac>
258 <mi>k</mi>
259 <msub>
260 <mi>n</mi>
261 <mi>j</mi>
262 </msub>
263 </mfrac>
264 <mo stretchy="true" form="postfix">)</mo>
265 </mrow>
266 <mi>v</mi>
267 <mo stretchy="false" form="prefix">[</mo>
268 <mi>j</mi>
269 <mo stretchy="false" form="postfix">]</mo>
270 <mo>+</mo>
271 <mfrac>
272 <mi>k</mi>
273 <msub>
274 <mi>n</mi>
275 <mi>i</mi>
276 </msub>
277 </mfrac>
278 <mi>v</mi>
279 <mo stretchy="false" form="prefix">[</mo>
280 <mi>j</mi>
281 <mo>+</mo>
282 <mn>1</mn>
283 <mo stretchy="false" form="postfix">]</mo>
284 </mrow>
285 <annotation encoding="application/x-tex">u_{j}\lbrack k\rbrack = \left( 1 - \frac{k}{n_{j}} \right)v\lbrack
286 j\rbrack + \frac{k}{n_{i}}v\lbrack j + 1\rbrack</annotation>
287 </semantics>
288 </math><br />
289 <strong>Output</strong> :
290 <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML">
291 <semantics>
292 <mrow>
293 <mo stretchy="true" form="prefix">{</mo>
294 <mrow>
295 <mo stretchy="true" form="prefix">(</mo>
296 <mi>x</mi>
297 <mi>′</mi>
298 <mo stretchy="false" form="prefix">[</mo>
299 <mi>k</mi>
300 <mi>′</mi>
301 <mo stretchy="false" form="postfix">]</mo>
302 <mo>,</mo>
303 <mi>y</mi>
304 <mi>′</mi>
305 <mo stretchy="false" form="prefix">[</mo>
306 <mi>k</mi>
307 <mi>′</mi>
308 <mo stretchy="false" form="postfix">]</mo>
309 <mo>,</mo>
310 <mi>t</mi>
311 <mi>′</mi>
312 <mo stretchy="false" form="prefix">[</mo>
313 <mi>k</mi>
314 <mi>′</mi>
315 <mo stretchy="false" form="postfix">]</mo>
316 <mo stretchy="true" form="postfix">)</mo>
317 </mrow>
318 <mo>,</mo>
319 <mn>0</mn>
320 <mo>≤</mo>
321 <mi>k</mi>
322 <mo>;</mo>
323 <mo>≤</mo>
324 <mi>n</mi>
325 <mi>′</mi>
326 <mo stretchy="true" form="postfix">}</mo>
327 </mrow>
328 <annotation encoding="application/x-tex">\left\{ \left( x\prime\lbrack k\prime\rbrack,y\prime\lbrack
329 k\prime\rbrack,t\prime\lbrack k\prime\rbrack \right),0 \leq k; \leq n\prime \right\}</annotation>
330 </semantics>
331 </math>
332 the upsampled position and times. This verifies
333 <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
334 <semantics>
335 <mrow>
336 <mo>∀</mo>
337 <mi>k</mi>
338 <mi>′</mi>
339 <mo>,</mo>
340 <mi>t</mi>
341 <mi>′</mi>
342 <mo stretchy="false" form="prefix">[</mo>
343 <mi>k</mi>
344 <mi>′</mi>
345 <mo stretchy="false" form="postfix">]</mo>
346 <mo>−</mo>
347 <mi>t</mi>
348 <mi>′</mi>
349 <mo stretchy="false" form="prefix">[</mo>
350 <mi>k</mi>
351 <mi>′</mi>
352 <mo>−</mo>
353 <mn>1</mn>
354 <mo stretchy="false" form="postfix">]</mo>
355 <mo>&lt;</mo>
356 <msub>
357 <mi>Δ</mi>
358 <mrow>
359 <mtext mathvariant="normal">target </mtext>
360 <mspace width="0.333em"></mspace>
361 </mrow>
362 </msub>
363 <mo>=</mo>
364 <mfrac>
365 <mn>1</mn>
366 <mtext>sampling_min_output_rate</mtext>
367 </mfrac>
368 </mrow>
369 <annotation encoding="application/x-tex">\forall k\prime,t\prime\lbrack k\prime\rbrack - t\prime\lbrack
370 k\prime - 1\rbrack &lt; \Delta_{\text{target }} = \frac{1}{\text{sampling_min_output_rate}}</annotation>
371 </semantics>
372 </math><br />
373 <strong>Remark</strong> : As this is a streaming algorithm, we only
374 calculate this interpolation with respect to the latest stroke
375 position.
376 </p>