MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / dt

Function dt

dep/agg/include/agg_span_gradient_contour.h:151–191  ·  view source on GitHub ↗

DT algorithm by: Pedro Felzenszwalb

Source from the content-addressed store, hash-verified

149
150 // DT algorithm by: Pedro Felzenszwalb
151 void dt(float* spanf, float* spang, float* spanr, int* spann, int length)
152 {
153 int k = 0;
154 float s;
155
156 spann[0] = 0;
157 spang[0] = -FLT_MAX;
158 spang[1] = FLT_MAX;
159
160 for (int q = 1; q <= length - 1; q++)
161 {
162 s = ((spanf[q] + square(q)) -
163 (spanf[spann[k]] + square(spann[k]))) /
164 (2 * q - 2 * spann[k]);
165
166 while (s <= spang[k])
167 {
168 k--;
169 s = ((spanf[q] + square(q)) -
170 (spanf[spann[k]] + square(spann[k]))) /
171 (2 * q - 2 * spann[k]);
172 }
173
174 k++;
175 spann[k] = q;
176 spang[k] = s;
177 spang[k + 1] = FLT_MAX;
178 }
179
180 k = 0;
181
182 for (int q = 0; q <= length - 1; q++)
183 {
184 while (spang[k + 1] < q)
185 {
186 k++;
187 }
188
189 spanr[q] = square(q - spann[k]) + spanf[spann[k]];
190 }
191 }
192
193 // DT algorithm by: Pedro Felzenszwalb
194 int8u* gradient_contour::contour_create(path_storage* ps)

Callers 1

contour_createMethod · 0.85

Calls 1

squareFunction · 0.85

Tested by

no test coverage detected