www.gusucode.com > matlab编写的图像几何变换的程序源码 > imrot.m

    function [mat_ref_new, mat_m_new]=imrot(mat_ref, mat_m, theta)
%Revised image rotation function with proper resize such that the input and
%output will have the same size. Input: double image Output: double image
%confirmed!

[mo, no]=size(mat_ref); 
mat_m_new=imrotate(mat_m, theta, 'bilinear'); 
[m, n]=size(mat_m_new); 
mat_ref_new=zeros(m, n); 
mat_ref_new((floor(m/2)-floor(mo/2)+1):(floor(m/2)-floor(mo/2)+mo),...
    (floor(n/2)-floor(no/2)+1):(floor(n/2)-floor(no/2)+no))=mat_ref; 
end