【发布时间】:2018-05-26 10:49:28
【问题描述】:
matlab 中的imrotate 函数围绕中心旋转图像。如何通过自定义坐标旋转图像?
例如二进制掩码中的 blob 中心。如果使用 imcrop 并将 blob 放在中心,如何将其重塑为与原始图像相同?
代码
% create binary mask
clc;
clear;
mask= zeros(400,600,'logical');
positein = [280,480];
L = 40;
x = positein (1);
y = positein (2);
mask(x,y-L:y+L) = 1;
for i =1:8
mask(x+i,y-L:y+L) = 1;
mask(x-i,y-L:y+L) = 1;
end
Angle = 45;
mask_after_rotation = imrotate(mask,-Angle,'crop');
figure,
subplot(1,2,1),imshow(mask),title('before rotation');
subplot(1,2,2),imshow(mask_after_rotation),title('after rotate 45');
【问题讨论】:
标签: matlab image-processing image-rotation