filter_contours_area_of_image*: also ensure validity here

This commit is contained in:
Robert Sachunsky 2025-08-21 01:33:16 +02:00
parent 42474afa4b
commit 244772f086
2 changed files with 6 additions and 6 deletions

View file

@ -3671,13 +3671,13 @@ class Eynollah:
def dilate_textregions_contours_textline_version(self, all_found_textline_polygons):
return [[np.array(make_valid(Polygon(poly[:, 0]).buffer(5)).exterior.coords[:-1],
dtype=int)[:, np.newaxis]
dtype=np.uint)[:, np.newaxis]
for poly in region]
for region in all_found_textline_polygons]
def dilate_textregions_contours(self, all_found_textline_polygons):
return [np.array(make_valid(Polygon(poly[:, 0]).buffer(5)).exterior.coords[:-1],
dtype=int)[:, np.newaxis]
dtype=np.uint)[:, np.newaxis]
for poly in all_found_textline_polygons]

View file

@ -48,8 +48,8 @@ def filter_contours_area_of_image(image, contours, hierarchy, max_area, min_area
if (area >= min_area * np.prod(image.shape[:2]) and
area <= max_area * np.prod(image.shape[:2]) and
hierarchy[0][jv][3] == -1):
found_polygons_early.append(np.array([[point]
for point in polygon.exterior.coords[:-1]], dtype=np.uint))
found_polygons_early.append(np.array(make_valid(polygon).exterior.coords[:-1],
dtype=np.uint)[:, np.newaxis])
return found_polygons_early
def filter_contours_area_of_image_tables(image, contours, hierarchy, max_area, min_area):
@ -69,8 +69,8 @@ def filter_contours_area_of_image_tables(image, contours, hierarchy, max_area, m
# hierarchy[0][jv][3]==-1
True):
# print(c[0][0][1])
found_polygons_early.append(np.array([[point]
for point in polygon.exterior.coords[:-1]], dtype=np.int32))
found_polygons_early.append(np.array(make_valid(polygon).exterior.coords[:-1],
dtype=np.uint)[:, np.newaxis])
return found_polygons_early
def find_new_features_of_contours(contours_main):