MATLAB: How to preserve edges when rotating images

image rotation

How can i make sure that my images dont cut off when using rotation in image augmentation
imageAugmenter = imageDataAugmenter('RandRotation',[0,360]);
In = imread('input_image.bmp');
Out = augment(imageAugmenter,In);
What additional parameters, do i need to set, to ensure the image dont get cut off at the edges

Best Answer

pad the image with nan so that it becomes sqrt(2) times its original size. Do the random rotation on that. Find the bounding box of non-nan elements and crop. Fill the remaining nan with something appropriate.
Or... don't use the image augmenter, and use imrotate with a random angle, specifying an appropriate padding strategy.
Related Question