mirror of
https://github.com/qurator-spk/sbb_pixelwise_segmentation.git
synced 2025-06-09 20:00:05 +02:00
layout visualization updated
This commit is contained in:
parent
13c6d28aaa
commit
834cf19cb9
2 changed files with 11 additions and 2 deletions
|
@ -418,7 +418,7 @@ def visualize_textline_segmentation(dir_xml, dir_out, dir_imgs):
|
||||||
help="directory of images where textline segmentation will be overlayed", )
|
help="directory of images where textline segmentation will be overlayed", )
|
||||||
|
|
||||||
def visualize_layout_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
def visualize_layout_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
assert xml_file and dir_xml, "A single xml file -xml or a dir of xml files -dx is required not both of them"
|
assert xml_file or dir_xml, "A single xml file -xml or a dir of xml files -dx is required not both of them"
|
||||||
if dir_xml:
|
if dir_xml:
|
||||||
xml_files_ind = os.listdir(dir_xml)
|
xml_files_ind = os.listdir(dir_xml)
|
||||||
else:
|
else:
|
||||||
|
@ -442,7 +442,7 @@ def visualize_layout_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
co_text, co_graphic, co_sep, co_img, co_table, co_noise, y_len, x_len = get_layout_contours_for_visualization(xml_file)
|
co_text, co_graphic, co_sep, co_img, co_table, co_noise, y_len, x_len = get_layout_contours_for_visualization(xml_file)
|
||||||
|
|
||||||
|
|
||||||
added_image = visualize_image_from_contours_layout(co_text['paragraph'], co_text['header'], co_text['drop-capital'], co_sep, co_img, co_text['marginalia'], img)
|
added_image = visualize_image_from_contours_layout(co_text['paragraph'], co_text['header']+co_text['heading'], co_text['drop-capital'], co_sep, co_img, co_text['marginalia'], img)
|
||||||
|
|
||||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,7 @@ def get_layout_contours_for_visualization(xml_file):
|
||||||
co_noise=[]
|
co_noise=[]
|
||||||
|
|
||||||
types_text = []
|
types_text = []
|
||||||
|
types_graphic = []
|
||||||
|
|
||||||
for tag in region_tags:
|
for tag in region_tags:
|
||||||
if tag.endswith('}TextRegion') or tag.endswith('}Textregion'):
|
if tag.endswith('}TextRegion') or tag.endswith('}Textregion'):
|
||||||
|
@ -325,6 +326,9 @@ def get_layout_contours_for_visualization(xml_file):
|
||||||
if len(types_text_without_paragraph) == 0:
|
if len(types_text_without_paragraph) == 0:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
else:
|
||||||
|
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
|
||||||
elif len(types_text_without_paragraph) >= 1:
|
elif len(types_text_without_paragraph) >= 1:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
if nn.attrib['type'] in types_text_without_paragraph:
|
if nn.attrib['type'] in types_text_without_paragraph:
|
||||||
|
@ -332,10 +336,15 @@ def get_layout_contours_for_visualization(xml_file):
|
||||||
else:
|
else:
|
||||||
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
|
||||||
|
else:
|
||||||
|
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
if nn.attrib['type'] in all_defined_textregion_types:
|
if nn.attrib['type'] in all_defined_textregion_types:
|
||||||
c_t_in[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
else:
|
||||||
|
c_t_in['paragraph'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue