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

Function ExpandImageTop

deps/tesseract/textord/imagefind.cpp:890–921  ·  view source on GitHub ↗

Search for the bottommost text that overlaps horizontally and is above the given box, but within the given top limit.

Source from the content-addressed store, hash-verified

888// Search for the bottommost text that overlaps horizontally and is above
889// the given box, but within the given top limit.
890static int ExpandImageTop(const TBOX& box, int top_limit,
891 ColPartitionGrid* part_grid) {
892 ColPartitionGridSearch search(part_grid);
893 ColPartition* part;
894 // Search right to left for any text that overlaps.
895 search.StartVerticalSearch(box.left(), box.right(), box.top());
896 while ((part = search.NextVerticalSearch(false)) != NULL) {
897 if (part->flow() == BTFT_STRONG_CHAIN || part->flow() == BTFT_CHAIN) {
898 const TBOX& part_box(part->bounding_box());
899 if (part_box.x_gap(box) < 0) {
900 if (part_box.bottom() < top_limit && part_box.bottom() > box.top())
901 top_limit = part_box.bottom();
902 break;
903 }
904 }
905 }
906 if (part != NULL) {
907 // Search for the nearest text up to the one we already found.
908 TBOX search_box(box.left(), box.top(), box.right(), top_limit);
909 search.StartRectSearch(search_box);
910 while ((part = search.NextRectSearch()) != NULL) {
911 if (part->flow() == BTFT_STRONG_CHAIN || part->flow() == BTFT_CHAIN) {
912 const TBOX& part_box(part->bounding_box());
913 if (part_box.x_gap(box) < 0) {
914 if (part_box.bottom() < top_limit && part_box.bottom() > box.top())
915 top_limit = part_box.bottom();
916 }
917 }
918 }
919 }
920 return top_limit;
921}
922
923// Expands the image box in the given direction until it hits text,
924// limiting the expansion to the given limit box, returning the result

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