#include "blobbox.h"
#include <algorithm>
#include <cstdint>
#include "allheaders.h"
#include "blobs.h"
#include "coutln.h"
#include "environ.h"
#include "helpers.h"
#include "host.h"
#include "points.h"
Go to the source code of this file.
|
void | find_cblob_limits (C_BLOB *blob, float leftx, float rightx, FCOORD rotation, float &ymin, float &ymax) |
|
void | find_cblob_vlimits (C_BLOB *blob, float leftx, float rightx, float &ymin, float &ymax) |
|
void | find_cblob_hlimits (C_BLOB *blob, float bottomy, float topy, float &xmin, float &xmax) |
|
C_BLOB * | crotate_cblob (C_BLOB *blob, FCOORD rotation) |
|
TBOX | box_next (BLOBNBOX_IT *it) |
|
TBOX | box_next_pre_chopped (BLOBNBOX_IT *it) |
|
void | vertical_cblob_projection (C_BLOB *blob, STATS *stats) |
|
void | vertical_coutline_projection (C_OUTLINE *outline, STATS *stats) |
|
void | plot_blob_list (ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour) |
|
◆ PROJECTION_MARGIN
#define PROJECTION_MARGIN 10 |
◆ box_next()
TBOX box_next |
( |
BLOBNBOX_IT * |
it | ) |
|
Definition at line 636 of file blobbox.cpp.
638 {
641
642 blob = it->data ();
644 do {
645 it->forward ();
646 blob = it->data ();
647 if (blob->
cblob() ==
nullptr)
648
650 }
651
653 return result;
654}
const TBOX & bounding_box() const
bool joined_to_prev() const
◆ box_next_pre_chopped()
TBOX box_next_pre_chopped |
( |
BLOBNBOX_IT * |
it | ) |
|
Definition at line 665 of file blobbox.cpp.
667 {
670
671 blob = it->data ();
673 do {
674 it->forward ();
675 blob = it->data ();
676 }
677
679 return result;
680}
◆ crotate_cblob()
Definition at line 611 of file blobbox.cpp.
614 {
615 C_OUTLINE_LIST out_list;
616
617 C_OUTLINE_IT in_it = blob->
out_list ();
618
619 C_OUTLINE_IT out_it = &out_list;
620
621 for (in_it.mark_cycle_pt (); !in_it.cycled_list (); in_it.forward ()) {
622 out_it.add_after_then_move (
new C_OUTLINE (in_it.data (), rotation));
623 }
624 return new C_BLOB (&out_list);
625}
C_OUTLINE_LIST * out_list()
◆ find_cblob_hlimits()
void find_cblob_hlimits |
( |
C_BLOB * |
blob, |
|
|
float |
bottomy, |
|
|
float |
topy, |
|
|
float & |
xmin, |
|
|
float & |
xmax |
|
) |
| |
Definition at line 576 of file blobbox.cpp.
581 {
582 int16_t stepindex;
586
587 C_OUTLINE_IT out_it = blob->
out_list ();
588
589 xmin = static_cast<float>(INT32_MAX);
590 xmax = static_cast<float>(-INT32_MAX);
591 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
592 outline = out_it.data ();
594 for (stepindex = 0; stepindex < outline->
pathlength (); stepindex++) {
595
596 if (pos.
y () >= bottomy && pos.
y () <= topy) {
598 }
599 vec = outline->
step (stepindex);
600 pos += vec;
601 }
602 }
603}
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
ICOORD step(int index) const
const ICOORD & start_pos() const
int32_t pathlength() const
int16_t y() const
access_function
int16_t x() const
access function
◆ find_cblob_limits()
void find_cblob_limits |
( |
C_BLOB * |
blob, |
|
|
float |
leftx, |
|
|
float |
rightx, |
|
|
FCOORD |
rotation, |
|
|
float & |
ymin, |
|
|
float & |
ymax |
|
) |
| |
Definition at line 499 of file blobbox.cpp.
505 {
506 int16_t stepindex;
510
511 C_OUTLINE_IT out_it = blob->
out_list ();
512
513 ymin = static_cast<float>(INT32_MAX);
514 ymax = static_cast<float>(-INT32_MAX);
515 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
516 outline = out_it.data ();
519 for (stepindex = 0; stepindex < outline->
pathlength (); stepindex++) {
520
521 if (pos.
x () >= leftx && pos.
x () <= rightx) {
523 }
524 vec = outline->
step (stepindex);
526 pos += vec;
527 }
528 }
529}
void rotate(const FCOORD &vec)
◆ find_cblob_vlimits()
void find_cblob_vlimits |
( |
C_BLOB * |
blob, |
|
|
float |
leftx, |
|
|
float |
rightx, |
|
|
float & |
ymin, |
|
|
float & |
ymax |
|
) |
| |
Definition at line 539 of file blobbox.cpp.
544 {
545 int16_t stepindex;
549
550 C_OUTLINE_IT out_it = blob->
out_list ();
551
552 ymin = static_cast<float>(INT32_MAX);
553 ymax = static_cast<float>(-INT32_MAX);
554 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
555 outline = out_it.data ();
557 for (stepindex = 0; stepindex < outline->
pathlength (); stepindex++) {
558
559 if (pos.
x () >= leftx && pos.
x () <= rightx) {
561 }
562 vec = outline->
step (stepindex);
563 pos += vec;
564 }
565 }
566}
◆ plot_blob_list()
Definition at line 1086 of file blobbox.cpp.
1089 {
1090 BLOBNBOX_IT it = list;
1091 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1092 it.data()->plot(win, body_colour, child_colour);
1093 }
1094}
◆ vertical_cblob_projection()
void vertical_cblob_projection |
( |
C_BLOB * |
blob, |
|
|
STATS * |
stats |
|
) |
| |
Definition at line 868 of file blobbox.cpp.
871 {
872
873 C_OUTLINE_IT out_it = blob->
out_list ();
874
875 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
877 }
878}
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
◆ vertical_coutline_projection()
void vertical_coutline_projection |
( |
C_OUTLINE * |
outline, |
|
|
STATS * |
stats |
|
) |
| |
Definition at line 888 of file blobbox.cpp.
891 {
894 int32_t length;
895 int16_t stepindex;
896 C_OUTLINE_IT out_it = outline->
child ();
897
900 for (stepindex = 0; stepindex < length; stepindex++) {
901 step = outline->
step (stepindex);
903 stats->
add (pos.
x (), -pos.
y ());
904 }
else if (step.
x () < 0) {
905 stats->
add (pos.
x () - 1, pos.
y ());
906 }
907 pos += step;
908 }
909
910 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
912 }
913}
void add(int32_t value, int32_t count)
◆ kComplexShapePerimeterRatio
const double kComplexShapePerimeterRatio = 1.5 |
◆ kCosSmallAngle
const double kCosSmallAngle = 0.866 |
◆ kDefiniteAspectRatio
const double kDefiniteAspectRatio = 2.0 |
◆ kMaxMediumSizeRatio
const double kMaxMediumSizeRatio = 4.0 |
◆ kMinMediumSizeRatio
const double kMinMediumSizeRatio = 0.25 |