MATLAB: Image rotate

image processing

Can I have rotate image with white background
By default if we use imrotate it rotate image with black background can I have rotated image with white background?

Best Answer

Irot = imrotate(I,theta);
Mrot = ~imrotate(true(size(I)),theta);
Irot(Mrot&~imclearborder(Mrot)) = 255;
%View 'er
imtool(Irot)
Edited to be more robust/simpler