在MATLAB中,imrotate函数用于旋转图像。它的使用语法如下:
- 如果要旋转图像角度为theta度:
rotated_image = imrotate(image, theta);
其中,image是原始图像,theta是旋转角度。
- 如果要旋转图像角度为theta度,并指定旋转中心为(center_x, center_y):
rotated_image = imrotate(image, theta, ‘crop’, ‘center’, ‘center’);
其中,image是原始图像,theta是旋转角度,'crop’表示要裁剪旋转后图像的尺寸,'center’表示旋转中心为图像中心。
- 如果要旋转图像并保持图像尺寸不变:
rotated_image = imrotate(image, theta, ‘bilinear’, ‘crop’);
其中,image是原始图像,theta是旋转角度,'bilinear’表示使用双线性插值进行旋转,'crop’表示要裁剪旋转后图像的尺寸。
注意:imrotate函数默认旋转中心为图像左上角,旋转后可能会导致图像被裁剪。如需保持图像完整,可使用第2种或第3种形式的函数调用,并指定旋转中心为图像中心。
请根据实际需求选择合适的函数调用形式和参数配置。