MCPcopy Create free account
hub / github.com/creatale/node-dv / ExpandImageBottom

Function ExpandImageBottom

deps/tesseract/textord/imagefind.cpp:855–886  ·  view source on GitHub ↗

Search for the topmost text that overlaps horizontally and is below the given box, but within the given bottom limit.

Source from the content-addressed store, hash-verified

853// Search for the topmost text that overlaps horizontally and is below
854// the given box, but within the given bottom limit.
855static int ExpandImageBottom(const TBOX& box, int bottom_limit,
856 ColPartitionGrid* part_grid) {
857 ColPartitionGridSearch search(part_grid);
858 ColPartition* part;
859 // Search right to left for any text that overlaps.
860 search.StartVerticalSearch(box.left(), box.right(), box.bottom());
861 while ((part = search.NextVerticalSearch(true)) != NULL) {
862 if (part->flow() == BTFT_STRONG_CHAIN || part->flow() == BTFT_CHAIN) {
863 const TBOX& part_box(part->bounding_box());
864 if (part_box.x_gap(box) < 0) {
865 if (part_box.top() > bottom_limit && part_box.top() < box.bottom())
866 bottom_limit = part_box.top();
867 break;
868 }
869 }
870 }
871 if (part != NULL) {
872 // Search for the nearest text up to the one we already found.
873 TBOX search_box(box.left(), bottom_limit, box.right(), box.bottom());
874 search.StartRectSearch(search_box);
875 while ((part = search.NextRectSearch()) != NULL) {
876 if (part->flow() == BTFT_STRONG_CHAIN || part->flow() == BTFT_CHAIN) {
877 const TBOX& part_box(part->bounding_box());
878 if (part_box.x_gap(box) < 0) {
879 if (part_box.top() > bottom_limit && part_box.top() < box.bottom())
880 bottom_limit = part_box.top();
881 }
882 }
883 }
884 }
885 return bottom_limit;
886}
887
888// Search for the bottommost text that overlaps horizontally and is above
889// the given box, but within the given top limit.

Callers 1

ExpandImageDirFunction · 0.85

Calls 5

StartVerticalSearchMethod · 0.80
NextVerticalSearchMethod · 0.80
StartRectSearchMethod · 0.80
NextRectSearchMethod · 0.80
flowMethod · 0.45

Tested by

no test coverage detected