-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support image reading while ignoring EXIF orientation info #1091
Conversation
Add unit test for ignore_orientation flags in imread()
Codecov Report
@@ Coverage Diff @@
## master #1091 +/- ##
=======================================
Coverage 67.62% 67.62%
=======================================
Files 159 159
Lines 10283 10284 +1
Branches 1857 1858 +1
=======================================
+ Hits 6954 6955 +1
Misses 2964 2964
Partials 365 365
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
LGTM, see if @innerlee has any comments. |
How does turbo-jpeg handles orientation? |
Turbo-jpeg only supports "color" and "grayscale" mode now, but I found it always ignore EXIF information when loading images. So explicitly appending the "_ignore_orientation" suffix to both modes seems better? |
In this case, turbo-jpeg naturally supports |
There is also a tiff backend. You should take care of it. |
To be consistent, we can still add supports of |
By default, tifffile also ignores EXIF info. I've done few tests, and it seems tifffile backend hasn't been thoroughly tested beforehand. I'd recommend just leaving it as it is for now until bugs have been fixed. |
This is not needed. If you treat the current behavior of turbo-jpeg on color flag as a bug, then you can fix this bug by supporting the exif rotations for turbo-jpeg in later pr. |
Letting the same flag have different behaviors on different backends could be dangerous, but changing it can break users' code. I would say there are two possible ways to go:
The first choice seems safest to me |
You can do both. First do 1, and then do 2 and undo 1. Either 1 or 2 does not affect this pr |
Leave 2 as a future pr |
Motivation
Sometimes the orientation info in EXIF could lead to unexpected rotation of images, messing up the annotations in dataset. Current imread() would always take the info into account unless flagged with "unchanged", which sacrifices flexibility in data preprocessing.
Modification
Added support for ignoring the orientation info in both color and grayscale mode. It works for cv2 and pillow backend. Also added unit test for them.