I am trying to rotate a square image in Matlab in various angles without cropping the central object and having black regions to increase my dataset for object recognition purposes. Here is the original image:
With my current attempt,
function imF = my_im_rotate(img, angle) s = ceil(size(img)/2); imP = padarray(img, s(1:2), 'replicate', 'both'); imR = imrotate(imP, angle, 'bilinear', 'crop'); S = ceil(size(imR)/2); imF = imR(S(1)-s(1):S(1)+s(1)-1, S(2)-s(2):S(2)+s(2)-1, :); %// Final form end
A part of it is getting cropped. How do I prevent it?