diff --git a/print_materials/5_region_segmentation.pdf b/print_materials/5_region_segmentation.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0ed130660b13766036c388a486e7f4bac8d61949 Binary files /dev/null and b/print_materials/5_region_segmentation.pdf differ diff --git a/print_materials/5_region_segmentation.png b/print_materials/5_region_segmentation.png index 115b4ccff8d19e505ad551d30fb52cbda198639a..d75caa540bf95320903c237f360ff5a5680962dd 100644 Binary files a/print_materials/5_region_segmentation.png and b/print_materials/5_region_segmentation.png differ diff --git a/print_materials/5_region_segmentation.svg b/print_materials/5_region_segmentation.svg index 5974c3a767b45d5b1eeea0c2b8d6801f21128fa2..537cf28dcbb700fe11439ef1cda7c17a7078cded 100644 --- a/print_materials/5_region_segmentation.svg +++ b/print_materials/5_region_segmentation.svg @@ -9,11 +9,15 @@ id="svg1" inkscape:version="1.3 (0e150ed6c4, 2023-07-21)" sodipodi:docname="5_region_segmentation.svg" + xml:space="preserve" + inkscape:export-filename="5_region_segmentation.pdf" + inkscape:export-xdpi="171.429" + inkscape:export-ydpi="171.429" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" - xmlns:svg="http://www.w3.org/2000/svg"> - - - - Schritt 5: Region Segmentation - Schritt 5: Region Segmentation - - + y="113.633" /> diff --git a/print_materials/6_line_detection.pdf b/print_materials/6_line_detection.pdf new file mode 100644 index 0000000000000000000000000000000000000000..62d484b9cdd2e2ccd2cb6aa84ac092fba23230fb Binary files /dev/null and b/print_materials/6_line_detection.pdf differ diff --git a/print_materials/6_line_detection.png b/print_materials/6_line_detection.png index 389871d493db63e2bc483f7348bdf69fe38c341c..beb61dfb2157b06156dce7b62fed6a6b7ab0c27e 100644 Binary files a/print_materials/6_line_detection.png and b/print_materials/6_line_detection.png differ diff --git a/print_materials/6_line_detection.svg b/print_materials/6_line_detection.svg index e3366626f171898899d6e9cf4a7c65a64346dd93..8986e829ea2d3c3df873c7e268aaa53e5d58c426 100644 --- a/print_materials/6_line_detection.svg +++ b/print_materials/6_line_detection.svg @@ -9,11 +9,15 @@ id="svg1" inkscape:version="1.3 (0e150ed6c4, 2023-07-21)" sodipodi:docname="6_line_detection.svg" + xml:space="preserve" + inkscape:export-filename="6_line_detection.pdf" + inkscape:export-xdpi="171.429" + inkscape:export-ydpi="171.429" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" - xmlns:svg="http://www.w3.org/2000/svg"> - - - - Schritt 6: Line Detection - Schritt 6: Line Detection - - + y="113.633" /> diff --git a/print_materials/7_word_detection.pdf b/print_materials/7_word_detection.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5f9a066e93bf2acf267d2045b6b460a3d64cdc39 Binary files /dev/null and b/print_materials/7_word_detection.pdf differ diff --git a/print_materials/7_word_detection.png b/print_materials/7_word_detection.png index 389871d493db63e2bc483f7348bdf69fe38c341c..c25a8dfa1d1ba328ea36c5ea282dea177246a01b 100644 Binary files a/print_materials/7_word_detection.png and b/print_materials/7_word_detection.png differ diff --git a/print_materials/7_word_detection.svg b/print_materials/7_word_detection.svg index 110771175b885e6aa121d1b9e68f211e92e6ed24..0a9493a0524883bcfa03e2d19fecb8ce97f58b23 100644 --- a/print_materials/7_word_detection.svg +++ b/print_materials/7_word_detection.svg @@ -9,11 +9,15 @@ id="svg1" inkscape:version="1.3 (0e150ed6c4, 2023-07-21)" sodipodi:docname="7_word_detection.svg" + xml:space="preserve" + inkscape:export-filename="7_word_detection.pdf" + inkscape:export-xdpi="171.429" + inkscape:export-ydpi="171.429" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" - xmlns:svg="http://www.w3.org/2000/svg"> - - - - Schritt 7: Word Detection - Schritt 7: Word Detection - - + y="113.633" /> diff --git a/print_materials/ocr/draw_overlays.ipynb b/print_materials/ocr/draw_overlays.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..e5939a70d8345c1ea94a59cc08e94d0da304ffbd --- /dev/null +++ b/print_materials/ocr/draw_overlays.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from lxml import etree as et\n", + "from pathlib import Path\n", + "from PIL import Image, ImageDraw\n", + "\n", + "ns = {\n", + " 'tei': 'http://www.tei-c.org/ns/1.0',\n", + " 'xml': 'http://www.w3.org/XML/1998/namespace'\n", + "}\n", + "\n", + "tei_path = Path('anno-event-2023_tei.xml')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "root = et.parse(tei_path).getroot()\n", + "facs = root.find('.//tei:facsimile[@xml:id=\"facs_5\"]', namespaces=ns)\n", + "\n", + "root, facs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "colors = {\n", + " 'TextRegion': {\n", + " 'fill': '#d9e1f2',\n", + " 'outline': None\n", + " },\n", + " 'Image': {\n", + " 'fill': '#fce4d6',\n", + " 'outline': None\n", + " },\n", + " 'UnknownRegion': {\n", + " 'fill': '#fff2cc',\n", + " 'outline': None\n", + " },\n", + " 'Line': {\n", + " 'fill': '#f8cbad',\n", + " 'outline': 'grey'\n", + " },\n", + " 'Word': {\n", + " 'fill': '#bdd7ee',\n", + " 'outline': 'grey'\n", + " }\n", + "}\n", + "\n", + "def draw_annotations(image_path, rends):\n", + " img = Image.open(image_path)\n", + " width, height = img.size\n", + " converted = img.convert(\"RGBA\")\n", + " image_data = converted.tobytes()\n", + " img = Image.frombytes('RGBA', (width, height), image_data)\n", + " for facs in root.findall('.//tei:zone', namespaces=ns):\n", + " if facs.attrib['rendition'] in rends:\n", + " rect = ImageDraw.Draw(img)\n", + " shape = [\n", + " (int(facs.attrib['ulx']), int(facs.attrib['uly'])),\n", + " (int(facs.attrib['lrx']), int(facs.attrib['lry'])),\n", + " ]\n", + " fill = colors[facs.attrib['rendition']]['fill']\n", + " outline = colors[facs.attrib['rendition']]['outline']\n", + " rect = rect.rectangle(shape, fill=fill, outline=outline)\n", + " \n", + "\n", + "\n", + " img.save(image_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "draw_annotations(Path('../5_region_segmentation.png'), ['TextRegion', 'Image', 'UnknownRegion'])\n", + "draw_annotations(Path('../6_line_detection.png'), ['Line'])\n", + "draw_annotations(Path('../7_word_detection.png'), ['Word'])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/print_materials/ocr/requirements.txt b/print_materials/ocr/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8a390e2c668d34b8fd5e8440f6ab070cb0d6f1d7 --- /dev/null +++ b/print_materials/ocr/requirements.txt @@ -0,0 +1,2 @@ +lxml==4.9.2 +Pillow==10.1.0 \ No newline at end of file