Rotate images with automatic cropping

Version 1.0 (4,2 ko) par David Young
The blank triangles that appear in the corners of rotated images are cropped away.
891 téléchargements
Mise à jour 2 déc. 2014

Afficher la licence

When an image is rotated, using imrotate() for example, blank triangles appear in the corners of the output unless it is reduced in size. The triangles are the parts of the output image that correspond to regions outside the boundary of the input image. This function rotates an image about its centre using imrotate(), then crops the result sufficiently to remove the triangles. Of course, some data in the corners of the original image is lost.
By default the output has the maximum possible area (i,e,. number of pixels) and the crop is symmetrical, so the centre of the output is at the centre of the input image. In this case the function takes the same arguments as imrotate().
Optionally, the aspect ratio of the output may be set to a given value, or to be the same as that of the input. It may also be set so that the corners of the output all lie on the rotated sides of the input, though this is not always possible. In general, if the aspect ratio is set the cropped image will not have the maximum possible area.
When the position of the output is not fully constrained it may optionally be adjusted by a single parameter which sets the position of the centre of the output on the long axis of the rotated input.
Note that if you are using a version of MATLAB older than R2013b you will need to replace any calls to the addParameter method of the input parser with addParamValue.

Citation pour cette source

David Young (2024). Rotate images with automatic cropping (https://www.mathworks.com/matlabcentral/fileexchange/48624-rotate-images-with-automatic-cropping), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2014b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Geometric Transformation and Image Registration dans Help Center et MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0