-
-
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
Safely Rotate Images Without Cropping #888
Conversation
Greetings! Thanks for your PR. I believe it would be a valuable addition to Albumentations as it was also requested in past. Would you mind adding a few changes to your change-set, in order to ensure new code meets our coding conventions? In particular:
Overall, great work. Looking forward to get it merged. |
Good work! Thanks for PR.
Also please look to |
…nctions to Functional
…now and removes previously generated artifacts
@Dipet Thank you! I added the new feature into those unit tests. As for the test_rotate_interpolation test, I see what you mean. I just changed the implementation to work better with these tests, and SafeRotate supports border modes now. It uses one cv2 transformation rather than padding and rotating separately which gets rid of any artifacts it had before. |
@BloodAxe Thank you, I look forward to using this feature in Albumentations! I moved the internal functions for SafeRotate into functional.py, and I also moved the code for key points and bounding boxes into functional as well. I updated the readme, and It seems the PR is green. It's one commit behind the master, but I don't know if that matters. Let me know if there is anything else that should be done before the PR is approved. |
Albumentations SafeRotate
The goal of this feature is to allow rotations without cropping out important corners which may contain masks, bounding boxes, or keypoints.
Test Bounding Box
The Test Image
Transform Pipelines
A SafeRotated Image
Here the image is rotated and resized to fit the original size without cropping.
A Standard Rotated Image
Here the image is cropped out on the corners. This could be an issue for cropping out necessary bounding boxes, masks, and keypoints
Summary
This works very similarly to the Rotate class, except it pads the original image with a calculated value before the image is rotated.
Currently, it only supports cv2.BORDER_CONSTANT for its border mode. I can work on this for a fix in a future pull request, or include it in this one if required.
Also, I've run all the tests with pytest and added SafeRotate to the test_augmentations.py file.
Fixes
fixes #642
fixes #303