OCR-D / ocrd_anybaseocr

DFKI Layout Detection for OCR-D
Apache License 2.0
47 stars 12 forks source link

Cropping Output #15

Closed mjenckel closed 4 years ago

mjenckel commented 5 years ago

With https://github.com/mjenckel/OCR-D-LAYoutERkennung/commit/44247abca930cbff6e0cfa2f259168a4ee7e2f5a we added the AlternativeImage functionality to Cropping. Since we expect all modules to be used in a pipeline (see README.md) we were wondering if simply storing the border coordinates is correct. If we use Deskewing previous to Cropping and add an alternative deskewed image to the list of AlternativeImages, shouldnt we apply the inverse rotation on the found border coordinates so they apply to the original image rather than the deskewed image?

wrznr commented 4 years ago

@bertsky?

bertsky commented 4 years ago

@mjenckel are you sure you are referring to the right commit? (You already used 44247ab in #16 as well. It does not contain what is described there either.) Remember, it's hard to talk about these things in the air without a formal description of what is meant.

If we use Deskewing previous to Cropping and add an alternative deskewed image to the list of AlternativeImages, shouldnt we apply the inverse rotation on the found border coordinates so they apply to the original image rather than the deskewed image?

You should definitely. But this is not specific to deskewing (or cropping, for that matter). Any operation that wants to add coordinates must be aware that its input could have been in non-original (relative) coordinates, whereas PAGE-XML coordinates are always absolute. As long as all processors consistently added @comments (feature descriptions) to the images they annotate, core can keep track of the respective coordinate transformations, and invert them if requested.

You can do that via coordinates_for_segment(polygon, parent_image, parent_coords), where

This will then give you the coordinates you can annotate via a new CoordsType(). See docstrings in core and ocrd_tesserocr/segment-region.py for examples.

mjenckel commented 4 years ago

as per @bertsky 's advice, all coordinates should now be absolute coordinates