@@ -136,8 +136,8 @@ void Image::get_skeleton()
136
136
int i, num_neighbors;
137
137
point pt, aux;
138
138
if (boundary_queue.empty ()) {
139
- std::cerr << " get_skeleton: given an empty boundary queue!!"
140
- << endl;
139
+ std::cerr << " get_skeleton: given an empty boundary queue!!"
140
+ << endl;
141
141
return ;
142
142
}
143
143
while ( !boundary_queue.empty ()) {
@@ -167,8 +167,8 @@ void Image::distance_transform()
167
167
grey distance = 1 ;
168
168
int i, npix;
169
169
if (boundary_queue.empty ()) {
170
- std::cerr << " distance_transform: given an empty boundary queue!!"
171
- << endl;
170
+ std::cerr << " distance_transform: given an empty boundary queue!!"
171
+ << endl;
172
172
return ;
173
173
}
174
174
while (!boundary_queue.empty ()) {
@@ -190,9 +190,9 @@ std::cerr << "distance_transform: given an empty boundary queue!!"
190
190
pt = boundary_queue.front ();
191
191
}
192
192
if (VERBOSE)
193
- std::cout << " distance_transform: " << npix
194
- << " pixels removed in iteration "
195
- << static_cast <int >(distance-bound) << endl;
193
+ std::cout << " distance_transform: " << npix
194
+ << " pixels removed in iteration "
195
+ << static_cast <int >(distance-bound) << endl;
196
196
boundary_queue.pop (); // remove null pixel
197
197
}
198
198
}
@@ -203,13 +203,13 @@ void Image::brute_distance_transform()
203
203
int i;
204
204
for (i=0 ,pt=start; pt<=end; ++pt,++i) {
205
205
if (i== width) {
206
- std::cout << " ." << flush;
206
+ std::cout << " ." << flush;
207
207
i = 0 ;
208
208
}
209
209
if (*pt == white) {
210
- std::cout << endl;
210
+ std::cout << endl;
211
211
*pt = distance_to_boundary (pt);
212
- std::cout << (int ) *pt << endl;
212
+ std::cout << (int ) *pt << endl;
213
213
}
214
214
}
215
215
}
@@ -252,43 +252,43 @@ void Image::euclid_transform()
252
252
}
253
253
254
254
/*
255
- void Image::skel_transform_bis()
256
- {
257
- point pt, aux;
258
- vect *vectmatrix;
259
- vect *Vaux, *Vpt;
260
- vect offsets[8] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
261
- vectmatrix = new vect[size];
262
- double d;
263
- int i, npix;
264
- for (i=0; i<size; ++i) {
265
- if (start[i] == white) {
266
- (vectmatrix[i]).x = 1000; // so that distance vector is unrealistically big
267
- (vectmatrix[i]).y = 0;
268
- } else {
269
- (vectmatrix[i]).x = 0;
270
- (vectmatrix[i]).y = 0;
271
- }
272
- }
273
- while (!boundary_queue.empty()) {
274
- pt = boundary_queue.front();
275
- Vpt = vectmatrix + (pt - start);
276
- for (i=0; i<8; ++i) {
277
- aux= pt + offset_8neighbor[i];
278
- Vaux = Vpt + offset_8neighbor[i];
279
- if (in_range(aux))
280
- if (norm(*Vaux) > (d = norm(sum(*Vpt,offsets[i])))) {
281
- *Vaux = sum(*Vpt,offsets[i]);
282
- boundary_queue.push(aux);
283
- *aux = floor(d);
284
- } else if (cos_angle(*Vaux, *Vpt) < 0.8 &&
285
- norm(dif(*Vaux,*Vpt)) > 20.0) {
286
- *aux = 111;
287
- }
288
- }
289
- boundary_queue.pop();
290
- }
291
- }
255
+ void Image::skel_transform_bis()
256
+ {
257
+ point pt, aux;
258
+ vect *vectmatrix;
259
+ vect *Vaux, *Vpt;
260
+ vect offsets[8] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
261
+ vectmatrix = new vect[size];
262
+ double d;
263
+ int i, npix;
264
+ for (i=0; i<size; ++i) {
265
+ if (start[i] == white) {
266
+ (vectmatrix[i]).x = 1000; // so that distance vector is unrealistically big
267
+ (vectmatrix[i]).y = 0;
268
+ } else {
269
+ (vectmatrix[i]).x = 0;
270
+ (vectmatrix[i]).y = 0;
271
+ }
272
+ }
273
+ while (!boundary_queue.empty()) {
274
+ pt = boundary_queue.front();
275
+ Vpt = vectmatrix + (pt - start);
276
+ for (i=0; i<8; ++i) {
277
+ aux= pt + offset_8neighbor[i];
278
+ Vaux = Vpt + offset_8neighbor[i];
279
+ if (in_range(aux))
280
+ if (norm(*Vaux) > (d = norm(sum(*Vpt,offsets[i])))) {
281
+ *Vaux = sum(*Vpt,offsets[i]);
282
+ boundary_queue.push(aux);
283
+ *aux = floor(d);
284
+ } else if (cos_angle(*Vaux, *Vpt) < 0.8 &&
285
+ norm(dif(*Vaux,*Vpt)) > 20.0) {
286
+ *aux = 111;
287
+ }
288
+ }
289
+ boundary_queue.pop();
290
+ }
291
+ }
292
292
*/
293
293
294
294
void Image::skel_transform ()
@@ -319,22 +319,22 @@ void Image::skel_transform()
319
319
if (norm (*Vaux) > (d = norm (sum (*Vpt,offsets[i])))) {
320
320
*Vaux = sum (*Vpt,offsets[i]);
321
321
boundary_queue.push (aux);
322
- // *aux = floor(d);
322
+ // *aux = floor(d);
323
323
}
324
324
}
325
325
boundary_queue.pop ();
326
326
}
327
- for (pt = start; pt < end; ++pt)
328
- if (*pt == white) {
329
- Vpt = vectmatrix + (pt - start);
330
- for (i = 0 ; i<8 ; ++i) {
331
- Vaux = Vpt + offset_8neighbor[i];
332
- if (in_range (aux = pt + offset_8neighbor[i]) &&
333
- cos_angle (*Vpt,*Vaux) < 0.8 &&
334
- norm (dif (*Vpt,*Vaux)) > 20.0 )
335
- *aux = 111 ;
336
- }
327
+ for (pt = start; pt < end; ++pt)
328
+ if (*pt == white) {
329
+ Vpt = vectmatrix + (pt - start);
330
+ for (i = 0 ; i<8 ; ++i) {
331
+ Vaux = Vpt + offset_8neighbor[i];
332
+ if (in_range (aux = pt + offset_8neighbor[i]) &&
333
+ cos_angle (*Vpt,*Vaux) < 0.8 &&
334
+ norm (dif (*Vpt,*Vaux)) > 20.0 )
335
+ *aux = 111 ;
337
336
}
337
+ }
338
338
}
339
339
340
340
@@ -346,15 +346,15 @@ void Image::euclid2_transform()
346
346
vect offsets[8 ] = {{1 ,0 },{1 ,1 },{0 ,1 },{-1 ,1 },{-1 ,0 },{-1 ,-1 },{0 ,-1 },{1 ,-1 }};
347
347
vectmatrix = new vect[size];
348
348
int i, npix;
349
- std::memset (vectmatrix, 0 , 2 *size);
349
+ std::memset (vectmatrix, 0 , 2 *size);
350
350
/* for (i=0; i<size; ++i) {
351
- (vectmatrix[i]).x = 0;
352
- (vectmatrix[i]).y = 0;
353
- }
354
- */
351
+ (vectmatrix[i]).x = 0;
352
+ (vectmatrix[i]).y = 0;
353
+ }
354
+ */
355
355
if (boundary_queue.empty ()) {
356
- std::cerr << " distance_transform: given an empty boundary queue!!"
357
- << endl;
356
+ std::cerr << " distance_transform: given an empty boundary queue!!"
357
+ << endl;
358
358
return ;
359
359
}
360
360
while (!boundary_queue.empty ()) {
@@ -385,8 +385,8 @@ std::cerr << "distance_transform: given an empty boundary queue!!"
385
385
++ npix;
386
386
pt = boundary_queue.front ();
387
387
}
388
- boundary_queue.pop (); // remove null pixel
389
- color_queue (boundary_queue, bound);
388
+ boundary_queue.pop (); // remove null pixel
389
+ color_queue (boundary_queue, bound);
390
390
}
391
391
}
392
392
@@ -395,8 +395,8 @@ void Image::erode(int n)
395
395
point pt, aux;
396
396
int i;
397
397
if (boundary_queue.empty ()) {
398
- std::cerr << " erode: given an empty boundary queue!!"
399
- << endl;
398
+ std::cerr << " erode: given an empty boundary queue!!"
399
+ << endl;
400
400
return ;
401
401
}
402
402
for ( ; n>0 ; --n) {
@@ -425,8 +425,8 @@ void Image::dilate(int n)
425
425
int i;
426
426
point pt, aux;
427
427
if (boundary_queue.empty ()) {
428
- std::cerr << " dilate: given an empty boundary queue!!"
429
- << endl;
428
+ std::cerr << " dilate: given an empty boundary queue!!"
429
+ << endl;
430
430
return ;
431
431
}
432
432
for ( ; n>0 ; --n) {
@@ -525,7 +525,7 @@ int Image::get_num_4neighbors(point pt, grey level)
525
525
// displays boundary points in queue (deletes other points)
526
526
void Image::display_points ()
527
527
{
528
- std::memset (start, black, size*sizeof (grey));
528
+ std::memset (start, black, size*sizeof (grey));
529
529
color_queue (boundary_queue, white);
530
530
}
531
531
@@ -537,7 +537,7 @@ void Image::print_point(point pt)
537
537
dif = pt-start;
538
538
row = dif / width;
539
539
col = dif % width;
540
- std::cout << " row = " << row << " ; col = " << col << " " ;
540
+ std::cout << " row = " << row << " ; col = " << col << " " ;
541
541
}
542
542
543
543
@@ -952,7 +952,7 @@ bool Image::is_ordered()
952
952
last = pt;
953
953
boundary_queue.pop ();
954
954
} else {
955
- std::cout << " is_ordered: Offending points colored" ;
955
+ std::cout << " is_ordered: Offending points colored" ;
956
956
print_point (last);
957
957
print_point (pt);
958
958
*last = *pt = skel;
0 commit comments