Open
Conversation
bertsky
reviewed
Apr 1, 2022
Owner
bertsky
left a comment
There was a problem hiding this comment.
Please elaborate, or start with the error you were getting...
ocrd_detectron2/segment.py
Outdated
Comment on lines
-270
to
+272
| # get connected components to estimate scale | ||
| # get connected components to estimate ignorescale |
| page_image_bin.width, | ||
| page_image_bin.height - int(np.ceil(-diff / 2)))) | ||
| # check wether input image is binarized | ||
| if page_image_info.photometricInterpretation == "1": |
Owner
There was a problem hiding this comment.
That's a strange thing to query: it is only defined if the image was a TIFF (Pillow's TIFF plugin), and it does not even discern binarized vs others: binarized would be .mode == '1'. This signifies BlackIsZero, which could be true for
- binarized
- grayscale 8-bit
- grayscale 8-bit plus alpha 8-bit
- grayscale 16-bit int
- grayscale 32-bit int
- grayscale 32-bit float
I don't understand the purpose yet: what did go wrong before?
ocrd_detectron2/segment.py
Outdated
Comment on lines
-228
to
+230
| page_image_bin = page_image_bin.convert(mode='1') | ||
| page_image_bin = page_image_raw.convert(mode='1') |
Owner
There was a problem hiding this comment.
That's not going to work well: binarization is usually more than a simple conversion – you have to find the best threshold, ideally localized across the image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2
I dont know exactly if this is what you are expecting, but I tested it with RGB Images and was able to process those, even with postprocessing.