mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-09-01 13:29:58 +02:00
filter_contours_area_of_image*: also ensure validity here
This commit is contained in:
parent
42474afa4b
commit
244772f086
2 changed files with 6 additions and 6 deletions
|
@ -3671,13 +3671,13 @@ class Eynollah:
|
||||||
|
|
||||||
def dilate_textregions_contours_textline_version(self, all_found_textline_polygons):
|
def dilate_textregions_contours_textline_version(self, all_found_textline_polygons):
|
||||||
return [[np.array(make_valid(Polygon(poly[:, 0]).buffer(5)).exterior.coords[:-1],
|
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 poly in region]
|
||||||
for region in all_found_textline_polygons]
|
for region in all_found_textline_polygons]
|
||||||
|
|
||||||
def dilate_textregions_contours(self, 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],
|
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]
|
for poly in all_found_textline_polygons]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
if (area >= min_area * np.prod(image.shape[:2]) and
|
||||||
area <= max_area * np.prod(image.shape[:2]) and
|
area <= max_area * np.prod(image.shape[:2]) and
|
||||||
hierarchy[0][jv][3] == -1):
|
hierarchy[0][jv][3] == -1):
|
||||||
found_polygons_early.append(np.array([[point]
|
found_polygons_early.append(np.array(make_valid(polygon).exterior.coords[:-1],
|
||||||
for point in polygon.exterior.coords[:-1]], dtype=np.uint))
|
dtype=np.uint)[:, np.newaxis])
|
||||||
return found_polygons_early
|
return found_polygons_early
|
||||||
|
|
||||||
def filter_contours_area_of_image_tables(image, contours, hierarchy, max_area, min_area):
|
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
|
# hierarchy[0][jv][3]==-1
|
||||||
True):
|
True):
|
||||||
# print(c[0][0][1])
|
# print(c[0][0][1])
|
||||||
found_polygons_early.append(np.array([[point]
|
found_polygons_early.append(np.array(make_valid(polygon).exterior.coords[:-1],
|
||||||
for point in polygon.exterior.coords[:-1]], dtype=np.int32))
|
dtype=np.uint)[:, np.newaxis])
|
||||||
return found_polygons_early
|
return found_polygons_early
|
||||||
|
|
||||||
def find_new_features_of_contours(contours_main):
|
def find_new_features_of_contours(contours_main):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue